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
[BUILD] update build to require Java 11+ for building #228
Comments
Fixes moditect#228 This PR shows that Java 9+ methods were already used and the Java 8 bytecode uses Java 9+ APIs. This can be fixed by using Multi-Release-JARs.
Really fixes moditect#228. This will also show the NPE everyone is talking about in moditect#91.
Really fixes moditect#228. This will also show the NPE everyone is talking about in moditect#91.
Really fixes moditect#228. This will also show the NPE everyone is talking about in moditect#91.
ModiTect must remain Java8 compatible as that's kind of the point of configuring the plugin in a build that has not migrated past Java8. |
I am not sure what you mean 🤷♂️ |
Fixes moditect#228 This PR shows that Java 9+ methods were already used and the Java 8 bytecode uses Java 9+ APIs. This can be fixed by using Multi-Release-JARs.
Really fixes moditect#228. This will also show the NPE everyone is talking about in moditect#91.
@aalmiray it never worked on Java 8. https://github.com/bmarwell/moditect-java8example/actions/runs/7836458897/job/21384161711 |
So,, an actual fix would be to use my PR as a base (#229) and rework parts of it in a way that for Java 8 no module / ToolProvider import is being used. Maybe split into ModuleInfo and ModuleInfoSource generator. Or we could drop Java 8 support as no-one ever used it (or complained about it). |
@bmarwell, not all functionality of ModiTect can be used with Java 8, but some can, and that's one of its key features. See the README:
In that build you are using |
Where do I do that? |
Module info source doesn't work on 8, because the same class imports Java 9 classes. It never worked. In the title I explicitly mention to require Java 11 only for building. And in the first comment I said: use "release=8". I'm not sure how to phrase it otherwise. I really think it's clear I'm not changing any runtime requirements here, nor any existing functionality. As my demo shows, moduleInfoSource never worked on Java 8, because of the Java 9 imports. You don't have an IT for this, nad you were using neither the release parameter nor the animal sniffer plugin. It's untested. The readme is wrong, sadly. Or maybe it worked in a previous version. The commits I did only moved the classes with Java 9+ code to the Java11 folder. This way you can get compile errors. If you have any questions, let me know. |
Where do I do that?
This was in reply to "Or we could drop Java 8 support".
Module info source doesn't work on 8, because the same class imports Java
9 classes. It never worked.
Have you actually tried it? The imports of a class don't matter for its
compatibility (they do not even exist from the perspective of a class
file). The actual code path at runtime matters, and if a certain feature
doesn't trigger the loading of a Java 9+ class, then it will work with Java
8. If this doesn't work any more, it is a regression which should be fixed.
I have used this functionality of ModiTect on Java 8 in the past.
|
If this doesn't work any more, it is a regression which should be fixed. I have used this functionality of ModiTect on Java 8 in the past. I haven't look through the git history of that file, but ToolProvider (Java 9) is used in the constructor:
and here:
This is the actual root cause:
This is also the code path I see in my demo project in the exception:
I really think it would make sense to create a new Code Path where no Java 9+ classes are even imported. This, create a Apart from this, I find it much nicer to throw specific exceptions with a helpful message: |
All these references shouldn't matter for the case where we just compile a module descriptor (see here) either from an external source file ( I just tried the latter with Java 8, and it works as expected.
Yes, agreed. Not sure though whether it's worth the hassle of moving to a multi-release JAR, though. How is the devexp with that in IDEs for us these days? Does Eclipse support it well, or would there be lots of "duplicate source file" errors? If so, then I'd suggest to just add a manual version check at a suitable place (probably the constructors of the command classes in the core module). |
Can you tell me what's wrong with this project then? |
See above:
|
…va 8; move GenerateModuleList to Java 12
Yup. Just created a PR to my repo with the fix. Thanks. I think it is worth investigating where #229 goes (sorry for a bit of a mess in the commits… will squash later). Not sure why the vert.x test doesn't find the META-INF/java9 dir, though. Will investigate next week. I honestly don't think MR-Jars are a hazzle at all. |
As said before, my main question is around dev-exp for the ModiTect maintainers: how does this look like in IDEs, how can the different variants be tested, etc. In general, it helps to discuss these things based on actual facts an observations as much as possible, rather than assumptions. The next question is: what is the actual advantage we perceive from doing this change? Is it actually going to be any simpler than just putting version checks into the four command classes, as suggested before? Note I don't mean to push back on this just because I don't want to change things. I'd like to make sure though we understand what problem we actually want to solve, and whether any solution we come up with is advantageous in terms of effort/additional complexity vs. gain. What I wouldn't like us to do is moving to MR JARs just for the sake of exploring this technique. |
Fair point! Yes, IDE support could be better. But IntelliJ told me (recently on twitter) they are working on IDE support. The benefits are:
Disadvantages:
|
Ok, gotcha. Thanks for clarifying! So tbh. if the choice is between doing nothing and keep things as they are (after all, nothing actually is broken here), do a four line change across those command classes, or doing this substantial change here with its implications on our productivity, I am clearly favoring options one or two. |
Can see why. This also means, we can never use the animal sniffer plugin nor the --release javac parameter. For this reason, I'd love to see tests running on a Java 8 JVM. That makes the four line change a bit longer, but I honestly don't mind. |
Options:
|
Currently, these options will not work (easily), as the license-format plugin MUST be run and requires 11+. A configured skip won't help here, obviously, we would need a parent update. Otherwise a new integration-tests directory which is a new maven project (I personally don't like that option either). The easiest way in terms of "lines needed to configure a Java 8 test" is (in my opinion) to combine toolchains with the invoker-plugin. Drawback: Worse IDE support and still a bit to set up. |
hello, just came to this issue after proposing #237 that requires Java 11 at minimum since it is required by Jakarta EE 10 and Weld. |
AFAICT the build currently requires Java 9 for running. The maven plugin targets Java 8 for most operations, some operations do require running the target build with Java 9+. |
It is hard to say for sure without using the |
replace
maven.compiler.source
andmaven.compiler.target
withmaven.compiler.release
(still pointing to 8), which brings better API checks, Javadoc linting, compilation performance, etc.PR inc
The text was updated successfully, but these errors were encountered: