jdk
8344854: Modernize test/jdk/java/net/URLClassLoader/RemoveJar.java
#22319
Open

8344854: Modernize test/jdk/java/net/URLClassLoader/RemoveJar.java #22319

eirbjo wants to merge 3 commits into openjdk:master from eirbjo:removejar-cleanup
eirbjo
eirbjo48 days ago (edited 48 days ago)

Can I get a review of this test-only cleanup/speedup PR which modernizes the test RemoveJar.java.

This test attempts a variety of class loading scenarios on a URLClassLoader and verifies that when the loader is closed, it has released its JAR file (such that it may be deleted on Windows).

Changes in this PR include:

  • Converting the test to JUnit 5
  • Making it @Parameterized instead of using multiple jtreg runs
  • Producing the sample class file using the ClassFile API instead calling out to javac via ToolProvider
  • Packaging the JAR using JarOutputStream instead of calling out to the jar tool.
  • Adding some code and method comments to support understading of what this test does and why

A nice benefit of this change is that it speeds up the runtime from ~15 seconds to ~1 second on my laptop.

Unfortunately, this test relies on Windows to fail, that is something I plan to look into separately.

Verification: GHA tests pending. (No local Windows dev environment)


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8344854: Modernize test/jdk/java/net/URLClassLoader/RemoveJar.java (Enhancement - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22319/head:pull/22319
$ git checkout pull/22319

Update a local copy of the PR:
$ git checkout pull/22319
$ git pull https://git.openjdk.org/jdk.git pull/22319/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22319

View PR using the GUI difftool:
$ git pr show -t 22319

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22319.diff

Using Webrev

Link to Webrev Comment

eirbjo Convert RemoveJar to a parameterized JUnit 5 test
b49bc034
bridgekeeper
bridgekeeper48 days ago

👋 Welcome back eirbjo! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

openjdk
openjdk48 days ago

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

openjdk
openjdk48 days ago

@eirbjo The following label will be automatically applied to this pull request:

  • net

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

openjdk openjdk added net
eirbjo eirbjo marked this pull request as ready for review 48 days ago
openjdk openjdk added rfr
mlbridge
mlbridge48 days ago (edited 21 days ago)

Webrevs

dfuch
dfuch48 days ago

Hi Eirik, IIRC the cache is global - so I don't think running the test in the same VM will work. I mean, I don't think we will be testing the same thing.

eirbjo
eirbjo48 days ago (edited 48 days ago)

Hi Eirik, IIRC the cache is global - so I don't think running the test in the same VM will work. I mean, I don't think we will be testing the same thing.

If the test should fail because of a regression, then yes, the next parameterized run of the test may start with a non-empty cache. I could add an assertEmptyJarFileCaches method to the start of the test execution, this will verify that all test runs starting with a non-empty cache fails.

eirbjo Sanity check that the JarFileFactory caches are unpopulated at start …
5d0be877
eirbjo
eirbjo47 days ago

I could add an assertEmptyJarFileCaches method to the start of the test execution, this will verify that all test runs starting with a non-empty cache fails.

I went ahead and added a sanity check verifying that the JarFileFactory caches are unpopulated at the beginning of each test run.

turbanoff
turbanoff commented on 2024-12-19
Conversation is marked as resolved
Show resolved
test/jdk/java/net/URLClassLoader/RemoveJar.java
104 // Create JAR and URLClassLoader
105 Path jar = createJar();
106 String path = jar.toAbsolutePath().toString();
107
URL url = new URL("jar", "", "file:" +path + "!/" + subPath);
turbanoff21 days ago
Suggested change
URL url = new URL("jar", "", "file:" +path + "!/" + subPath);
URL url = new URL("jar", "", "file:" + path + "!/" + subPath);
eirbjo Update test/jdk/java/net/URLClassLoader/RemoveJar.java
bd6c6dbb

Login to write a write a comment.

Login via GitHub

Reviewers
Assignees
No one assigned
Labels
Milestone