-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JDK-8261518: jpackage looks for main module in current dir when there is no module-path #2781
Conversation
… is no module-path
👋 Welcome back herrick! A progress list of the required criteria for merging this PR into |
@andyherrick The following label will be automatically applied to this pull request:
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. |
… is no module-path
Webrevs
|
… is no module-path
test/jdk/tools/jpackage/share/jdk/jpackage/tests/NoMPathRuntimeTest.java
Outdated
Show resolved
Hide resolved
ArrayList<Path> paths = new ArrayList<Path>(); | ||
paths.add(TKit.TEST_SRC_ROOT.resolve("apps/image/Hello.java")); | ||
|
||
// compile Hello.java again putting classes in tmpdir | ||
new Executor() | ||
.setToolProvider(JavaTool.JAVAC) | ||
.addArguments("-d", tmpdir.toString()) | ||
.addPathArguments(paths) | ||
.execute(); | ||
|
||
// make raw jar of just Hello.class from tmpdir. | ||
new Executor() | ||
.setToolProvider(JavaTool.JAR) | ||
.dumpOutput() | ||
.addArguments("-cvf", "junk.jar", | ||
"-C", tmpdir.toString(), "Hello.class") | ||
.execute(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single line HelloApp.createBundle("junk.jar:Hello", tmpdir);
would compile source class and put it into "junk.jar" in tmpdir
folder. It can be used to replace lines from [109, 125] range.
What is the point to build "junk.jar"? I don't see how it is used in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug is that when --module-path option is not used in a modular app, jpackage uses a module-path with "." on it.
Having a non-modular jar in the modular path is an error.
So with this non-modular Hello.jar in the current directory the jpackage command failed before the fix, and succeeds after the fix.
I can create the non-modular Hello.jar in the current directory with one line:
HelloApp.createBundle(JavaAppDesc.parse("junk.jar:Hello"), Path.of("."))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another precondition for the test is that Java runtime used with jpackage command should include module with app main class, right?
Test arguments are: List.of("Hello", "com.foo/com.foo.main.Aloha");
. The first argument is non-modular app, it is not used with jlink. What is the point to run the test for non-modular app?
public void test() throws IOException { | ||
final Path tmpdir = TKit.createTempDirectory("tmpdir"); | ||
try { | ||
Files.createFile(tmpdir.resolve("tmpfile")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this leftover from something or on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes - was leftover - removed
I don't quite understand what unit test is doing. It creates a runtime that includes app module. It builds "junk.jar". How these pieces are connected? |
… is no module-path
… is no module-path
jlink.execute(); | ||
|
||
// create a non-modular jar in the current directory | ||
HelloApp.createBundle(JavaAppDesc.parse("junk.jar:Hello"), Path.of(".")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test files must be created in test work directory (TKit.workDir()
) and not in the current directory. Test harness creates empty work directory for every test run. In case of running this test multiple times and if previous test execution was aborted "junk.jar" will be in the current directory from the previous test run and the next test run will fail.
Running test multiple times without running clean up is the case when the test is executed in IDE under debugger and debugging session is aborted.
If you absolutely must create "junk.jar" in the current directory, you need to remove it manually. Something like this:
Path junkJar = null;
try {
junkJar = HelloApp.createBundle(JavaAppDesc.parse("junk.jar:Hello"), Path.of("."));
...
cmd.executeAndAssertHelloAppImageCreated();
} finally {
if (junkJar != null) {
TKit.deleteIfExists(junkJar);
}
}
… is no module-path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Please don't forget to fix the trailing whitespaces problem in the test.
… is no module-path
@andyherrick This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 110 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
/integrate |
@andyherrick Since your change was applied there have been 110 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 109af7b. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
when the app modules have already been jlinked with the runtime, and there is no need for module-path, jpackage was acting as if the module-path was "." and picking up jars in the current directory.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/2781/head:pull/2781
$ git checkout pull/2781