-
Notifications
You must be signed in to change notification settings - Fork 71
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
Default output directory for module-info.class
should be META-INF/versions/9
#67
Comments
Can you try specifying the |
@gunnarmorling Sorry, I totally missed that option! But I just tried it, and the descriptor was still put in the root of the build. I have:
|
PS the docs are a bit hard to parse right now... this is not the first time I missed something important in the docs. I don't really know how I would format them differently though... PPS Based on Alan's recommendation, maybe the default for http://mail.openjdk.java.net/pipermail/jigsaw-dev/2018-September/013935.html This means that putting the module descriptor in |
And actually the
|
Ah, just realizing this feature is part of Beta2, which hasn't been
released yet. I can try and cut a release soon, until then you'd have to
build ModiTect from source in order to use this.
|
Ah, OK. No worries, I'll wait. Please consider the suggestion to default this option to 9 though. I know it seems weird on the surface to put just that one file into a version directory, but that provides maximum compatibility. |
Hum, hum. It seems a bit weird on first thought indeed, but perhaps it's really best compat-wise. The question then is how to use that option to put the file into root if really wanted. Perhaps |
I hear you. Open for any suggestions for re-organizing them. Or better yet, a PR :) |
Yes, I think The issues I have hit with a few users of my library (and I have hit it myself) is that older classpath scanners will throw an NPE when they run into the module descriptor. It's not necissarily true that older scanners will ignore classfiles in META-INF, but the thinking is that that's the best chance you have at putting classfiles somewhere that an older scanner might intentionally not scan. (And some scanners ignore classfiles whose packages don't match their path, which hopefully happens before the NPE or similar is thrown). |
Plus it's the location of the classfile we're talking about, not the Java source, so it doesn't matter if the target location is not where most humans would expect it to be, as long as it is the most robust location. |
Yes, the idea is growing on me. It's not what one might expect on first
thought, but then I can't see any downsides of putting it to
META-INF/versions/9 by default. Shouldn't change a thing for JPMS-aware
JDKs (Java 9 and newer), while at least increasing chances for
non-JPMS-aware tools to work as expected.
Perhaps you'd be willing to create a prepare with the change?
|
…dule descriptor in root package
This is to be in sync with jdeps which also uses this value.
Resolved via #68. |
In case anyone is referring back to this issue at some point, I found direct support for this in JEP 238:
|
@gunnarmorling Any idea when you plan to release Beta2? I have a user who has been hitting up against problems using ClassGraph because the Android build tools can't handle |
@gunnarmorling Any chance you can please push out a new release? I got yet another report of problems from third party runtime environments dying when they find a module-info.class in the root of the jar. (This time it's Tomcat BCEL, called by Apache Catalina.) This is probably the third or fourth time I have run into this. I could manually move the module-info.class into a versioned section of the jar, but I'd rather automate it with the new Moditect features. Thanks! |
Hey @lukehutch, thanks for the reminder! Apologies for the delay (and just ignoring your earlier question about the release, I somehow missed that). I'll try and push out a release over the weekend. |
Thank you! |
See the discussion in moditect#68 and related JDK bug https://bugs.openjdk.java.net/browse/JDK-8207162.
Agh, so I ran into some issues with the set-up for the release today :( I'll keep working on this in the course of the next days. |
|
Addong a JMPS 9 compliant (hopefully) subproject. This subproject needs the root project to work as source files are copied to this subproject before compilation. It assumes that tests are run from the root project and not against this subproject, the objective being only to release a compliant Java 9 JPMS module.
- Add org.beryx.jar plugin to allow META-INF/versions/9 folder to be created when doing a jar of this subproject. (see moditect/moditect#67 & https://dzone.com/articles/how-to-create-modular-jars-that-target-a-java-rele) - Change compatibility level to Java 1.8 to trigger the plugin. - Update of the Manifest title.
- Add org.beryx.jar plugin to allow META-INF/versions/9 folder to be created when doing a jar of this subproject. (see moditect/moditect#67 & https://dzone.com/articles/how-to-create-modular-jars-that-target-a-java-rele) - Change compatibility level to Java 1.8 to trigger the plugin. - Update of the Manifest title.
There are still a lot of old Java tools that choke when they hit a
module-info.class
file. It may take a long time for this problem to be solved, since old libraries pull in even older libraries in their transitive dependency graph.META-INF/versions/9
was the location recommended by Uwe Schindler as the maximally backwards-compatible location for the module descriptor, pointed out by Alan Bateman on the jigsaw-dev mailing list recently:http://mail.openjdk.java.net/pipermail/jigsaw-dev/2018-October/013940.html
Some tools (such as the Android toolchain) are being updated to ignore classes found in
META-INF/versions
for this reason:https://issuetracker.google.com/u/0/issues/77587908
I tried using
<outputDirectory>
to specify where the module descriptor would be saved, but that affects the output jarfiles, not the location ofmodule-info.class
. Is there a way to save the module descriptor anywhere other than the root of the build target? If so, it would be a good idea to have the default betarget/META-INF/versions/9
, at least for the foreseeable future.The text was updated successfully, but these errors were encountered: