xtf-cz / xtf

MIT License
12 stars 55 forks source link

Enable xtf build on jdk 21 #590

Open mchoma opened 1 month ago

mchoma commented 1 month ago

Experiencing

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project core: Fatal error compiling: java.lang.NoSuchFieldError: Class com.sun.tools.javac.tree.JCTree$JCImport does not have member field 'com.sun.tools.javac.tree.JCTree qualid' -> [Help 1]

with

java -version
openjdk version "21.0.4" 2024-07-16
OpenJDK Runtime Environment (Red_Hat-21.0.4.0.7-2) (build 21.0.4+7)
OpenJDK 64-Bit Server VM (Red_Hat-21.0.4.0.7-2) (build 21.0.4+7, mixed mode, sharing)
mchoma commented 1 month ago

@dosu do you know what the solution for this problem could be?

dosubot[bot] commented 1 month ago

The error you're encountering is due to the use of internal JDK classes, specifically com.sun.tools.javac.tree.JCTree, which have changed in JDK 21. These internal APIs are not guaranteed to be stable across JDK versions.

To resolve this issue, consider the following steps:

  1. Update Dependencies: Check if any third-party libraries or plugins you are using have been updated to support JDK 21. Update them to the latest versions if available.

  2. Avoid Internal APIs: Refactor the code to avoid using internal JDK classes. Look for alternatives in the public API that can achieve the same functionality.

  3. Use a Compatible Compiler Plugin: Ensure that the maven-compiler-plugin or any other tools you are using are compatible with JDK 21. You might need to upgrade to a newer version if available.

  4. Check for Updates: Look for any updates or patches in the xtf project or related documentation that address compatibility with JDK 21.

These steps should help you address the compatibility issues with JDK 21.

To continue talking to Dosu, mention @dosu.

mchoma commented 1 month ago

@dosu are you able to find out which particular dependency need update?

dosubot[bot] commented 1 month ago

The specific dependency that needs to be updated is the maven-compiler-plugin. The current version is 3.8.1, and it should be updated to a version that supports JDK 21, such as 3.10.1 or later [1].

To continue talking to Dosu, mention @dosu.

mchoma commented 1 month ago

For reference looking around on internet it could be also lombok. https://stackoverflow.com/questions/77171270/compilation-error-after-upgrading-to-jdk-21-nosuchfielderror-jcimport-does-n