-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 failure with Java 21 #2501
Comments
Thanks for letting us know! We are not likely to start building with Java 21 anytime soon, so for the purposes of the GitHub repo this isn't an immediate issue. On the other hand, the compilation warnings are easily suppressed with If you do suppress warnings, the build fails later anyway like this:
We're using the latest version of proguard-maven-plugin so that's probably a blocker for now. I see that the forthcoming ProGuard 7.4.0 will support Java 21, and presumably there'll be a new release of proguard-maven-plugin then. I sent #2502 to suppress the serialization warnings. |
Besides the issue with ProGuard one of the tests is also failing:
The shrinker-test also seems to fail because R8 does not support Java 21 classfiles yet. |
With Spring 6.1 with maven-compiler-plugin 3.12 and compileArg -parameters i get error like this [ERROR] bad class file: .m2/repository/com/google/code/gson/gson/2.10.1/gson-2.10.1.jar(/com/google/gson/JsonElement.class) |
@denAbramoff, a few questions:
|
However, could you please create a separate GitHub issue, @denAbramoff? This issue here is about building Gson itself (i.e. the source code of this repository) using JDK 21, and not about using Gson in a project which is built using JDK 21. |
Ok, i will check a few moments and do it |
@ebourg, it should now be possible to build Gson with JDK 21 (see pull request #2552). The only limitation is as you mentioned that JDK 21 does not support Java 7 as target version, therefore building with JDK 21 currently intentionally requires using Since changing the target version from 7 to something higher is a user-visible change, it does not seem to be justified to do this just to be able to build with JDK 21. There is however in other issues already the discussion about increasing the target version to Java 8. Could you please double-check just to make sure you can build with JDK 21 now as well? I guess we can keep this issue here open though to track the following remaining tasks once the target version is Java 8:
(effectively this undoes / adjusts some of the #2552 changes) |
If someones interested proguard-maven-plugin have released a new version 2.6.1 which integrates proguard 7.4.1. Seems to work with java21 now :) |
[INFO] BUILD FAILURE |
@Abhinavrajsrivastav, that seems to be unrelated to Gson. It looks like you are specifying Java 21 as release version, but the JDK you are using is older. For any follow-up questions on this, please ask them on Stack Overflow or similar, unless they are directly related to Gson, to not move the discussion here too far off-topic. |
@Marcono1234 yes, I was using the latest java 21 version which was not compatible with the curent mvm version which is 3.8.6, I uodated jdk version to 17 and now it's completely working fine. |
Gson fails to build with Java 21, for two reasons:
The source/target level 7 is no longer supported:
If the level is changed to 8, compiler warnings appear and break the build:
The text was updated successfully, but these errors were encountered: