Skip to content
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

[java] Support JDK 22 #4794

Closed
11 tasks done
adangel opened this issue Jan 11, 2024 · 2 comments · Fixed by #4824
Closed
11 tasks done

[java] Support JDK 22 #4794

adangel opened this issue Jan 11, 2024 · 2 comments · Fixed by #4824
Assignees
Labels
an:enhancement An improvement on existing features / rules
Milestone

Comments

@adangel
Copy link
Member

adangel commented Jan 11, 2024

OpenJDK 22 GA is scheduled for 2024/03/19.

The following JEPs are important for us:

In summary: https://javaalmanac.io/jdk/22/

This issue is similar to the previous: #4583

EA Release of JDK22 is available here: https://jdk.java.net/22/

Tasks:

@adangel adangel added the an:enhancement An improvement on existing features / rules label Jan 11, 2024
@adangel
Copy link
Member Author

adangel commented Jan 11, 2024

Note: Java 22 includes JEP 457: Class-File API (Preview), which can replace ASM in the future...

@adangel adangel added this to the 7.0.0 milestone Feb 2, 2024
@adangel adangel self-assigned this Feb 15, 2024
adangel added a commit to adangel/pmd that referenced this issue Feb 15, 2024
@adangel
Copy link
Member Author

adangel commented Feb 15, 2024

Make sure, we can build PMD with JDK22

We can basically build PMD with java 22, but we need to skip pmd/cpd execution. E.g.

./mvnw clean install -Dpmd.skip=true -Dcpd.skip=true

I assume, that m-pmd-p doesn't provide the Java Runtime for the auxclasspath and we fall back to load java classfiles from the current runtime, which is Java 22 and we can't read the classfiles (Unsupported class file major version 66). This can be worked around by overriding the asm dependency for m-pmd-p:

                        <dependency>
                            <groupId>org.ow2.asm</groupId>
                            <artifactId>asm</artifactId>
                            <version>9.6</version>
                        </dependency>

However, I didn't add a profile or so, as once PMD 7.0.0 is released, this problem is gone.

In order to make the combination work (Running PMD with Java 22, analyzing source code for Java 8) through maven-pmd-plugin, we probably need to enhance the plugin to provide one more option to explicitly configure the Java Runtime classpath for auxclasspath/type resolution. I'm pretty sure, it would work when configuring Java 8 via toolchains (but then PMD would be executed with Java 8).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
an:enhancement An improvement on existing features / rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant