google / gson

A Java serialization/deserialization library to convert Java Objects into JSON and back
Apache License 2.0
23.13k stars 4.27k forks source link

Support building with JDK 21. #2690

Open eamonnmcmanus opened 1 month ago

eamonnmcmanus commented 1 month ago

I think the main reason we weren't doing this before is that the ProGuard plugin didn't support it. Apparently it does now.

eamonnmcmanus commented 1 month ago

Hmm, this is looking more complicated than I thought.

We are not planning to build using JDK 21 for releases any time soon, but it would be more convenient for testing if we supported building there. The current failures don't prevent testing but make for an awkward setup.

Marcono1234 commented 1 month ago

I think all plugins should support JDK 21 now. The main problem with JDK 21 is that it does not support Java 7 as target version. That is why the pom.xml currently increases the target version to Java 8 when building with JDK 21. And it is also the reason why building with JDK 21 is artificially prevented with the Enforcer Plugin at the moment, to avoid that users accidentally build a Gson release version which targets Java 8 instead of 7. See also #2552.

Most likely the check-api-compatibility failure is unrelated; maybe #2685 introduced some issues I forgot to consider, I will have a look. The problem with the current check-api-compatibility setup is that these issues often only occur for the next pull request..., sorry.

Marcono1234 commented 1 month ago

Also to clarify, CI is already building with JDK 21, see #2552. It just disables the Enforcer Plugin check which intentionally prevents this by default.