-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Support Java 16 #13481
Comments
I would love to evaluate project loom for my library (https://github.com/jobrunr/jobrunr) but since that is only available in jdk 16 and I also use gradle this is difficult now. |
@rdehuyss you can use different JVMs for running Gradle and compiling/running tests, see https://docs.gradle.org/current/userguide/building_java_projects.html#sec:java_cross_compilation |
@eskatos , thanks! I did not know that... |
@rdehuyss were you able to test Loom using Gradle or did you switch to Maven? |
I put it on my backlog for the moment... |
@lppedd Thx for your feedback. It indeed wasn't that much work. I'm testing JobRunr now with Project Loom and all seems ok. I still need to do further performance testing. @eskatos I also have automated tests (it's a test where JobRunr is tested against 12 different JVM's - see also https://www.jobrunr.io/blog/testing-jobrunr-against-12-different-jvms/) where the approach mentioned above is difficult. Since ASM 9 is now available in beta with support for JDK 16, what are the plans for gradle? |
This problem really needs to be fixed in a more general way than just bumping ASM versions and doing a new Gradle release. The problem is that Gradle (sometimes via Groovy) really wants to analyse bytecode in various ways at various points, and pukes when it can't. This is very hard to fix directly because bytecode is not forwards compatible, so you can't analyse versions from the future. There is therefore only one robust solution: javac must be told to emit old bytecode versions. This it can easily do via the This behaviour makes no sense. If Gradle must analyse bytecode then it has only one option it it wants to be compatible with the latest JVMs: it has to cap the target release of any non-user controlled javac invocations at whatever version of Java was the latest supported version at the time of release. This would allow it to be run with the JVM versions "from the future" and still be able to build projects. That would stem the bleeding, but of course what people want is to be able to use new Java features with old Gradles. They could do so as long as the new feature didn't require new bytecode features (i.e. new APIs but usually not new language features). To support all new Java features with old Gradles implies one of two things:
The latter approach is definitely the most work, but it would kill the problem once and for all. At any rate, I hope the Gradle team read this message and think about how to avoid this problem cropping up every six months. As Gradle is not always backwards compatible, the current approach is basically increasing the cost of Java upgrades for Gradle users - now a Java upgrade costs $JAVA_BACKCOMPAT_BREAKS + $GRADLE_BACKCOMPAT_BREAKS. Although I'm sure the Gradle team would love it if everyone upgraded Gradle immediately on upgrade, the world is full of old projects that are parked and no longer receiving significant work. Yet users wish to have a single JDK and still build and work on those old codebases, without upgrading that project's Gradle build. So this feature would help a lot of people over the coming years. |
@eskatos mind elaborating what you set as java {
toolchain {
languageVersion = JavaLanguageVersion.of('16-panama+3-385')
}
} which causes an error because |
@hugmanrique what works for me is the following: gradle.properties:
build.gradle:
You may need to add JVM args to
build with:
(e.g.: |
Thank you! Changing from manually specifying the path with |
Hello @hugmanrique @eskatos @iotamudelta, re: "Changing from manually specifying the path with org.gradle.java.installations.paths to org.gradle.java.installations.fromEnv did the trick", if task Update1: Both java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
withJavadocJar()
withSourcesJar()
} I have When I run the build, the Java project is compiled using the JDK11 as expected, however, the task
Did I miss anything here? |
JDK 16 will be released in just over 1 month. Is there any progress on this issue that the gradle team can share? |
Is Java 16 support planned for 6.x or is it in 7.x only? What about Java 17 support? I hope both will come to 6.x, ASM is already capable of handling both Java 16 and Java 17. In fact, there was even a new release tagged for ASM (9.1) with Java 16 and Java 17 support just last week. |
As mentioned before by others, ASM (which causes the error) is already able to handle Java 16. |
Fwiw, #16193 has been merged, so Groovy 3 is there, and available in 7.0-M2. |
Any updates to the issue? Java 16 will be released in a week. |
I think Java 16 will be released in a day now. |
7.0 milestone 3 works fine with jdk16 |
@LifeIsStrange In this particular case, you must also set the preview flag on any test tasks that will execute the code compiled with preview features enabled:
Note, that the same applies if you use Gradle to execute such code with For reference: https://docs.gradle.org/current/userguide/building_java_projects.html#sec:feature_preview |
You'll be able to run Gradle with Java 16 in 7.0, but you can already sort of use JDK16 with 6.8.3: https://melix.github.io/blog/2021/03/gradle-java16.html We may backport better support for compiling/testing with Java 16 in a future 6.8.x, but you won't be able to run Gradle 6.8.x on Java 16. |
This is closed as the last opened ticket for milestone 7.0-RC1. Does that mean this RC version will be available soon? |
Current attempts to use Gradle 6.5 with
openjdk version "16-ea" 2021-03-16
result in a failure along the lines of:Please add support for Java 16.
Note, however, that the above failure is due to lack of support for Java 16 in ASM.
The text was updated successfully, but these errors were encountered: