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 Java 23 #5112

Merged
merged 21 commits into from
Aug 29, 2024
Merged

[java] Support Java 23 #5112

merged 21 commits into from
Aug 29, 2024

Conversation

adangel
Copy link
Member

@adangel adangel commented Jul 11, 2024

Describe the PR

This is ready now.

I pushed the branch is directly to our main repo on github: https://github.com/pmd/pmd/tree/issue-5062-support-java-23.

Java 23 is GA in September, which means it would be great, if we could finish this latest in August, so that in lands in PMD 7.5.0 to be released end of August.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@adangel adangel added this to the 7.5.0 milestone Jul 11, 2024
@pmd-test
Copy link

pmd-test commented Jul 12, 2024

1 Message
📖 Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 1 new errors and 0 new configuration errors,
removes 45 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 1 new errors and 0 new configuration errors,
removes 45 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 1 new errors and 0 new configuration errors,
removes 45 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 1 new errors and 0 new configuration errors,
removes 45 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 1 new errors and 0 new configuration errors,
removes 45 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 1 new errors and 0 new configuration errors,
removes 45 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 1 new errors and 0 new configuration errors,
removes 45 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 1 new errors and 0 new configuration errors,
removes 45 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 1 new errors and 0 new configuration errors,
removes 45 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 1 new errors and 0 new configuration errors,
removes 45 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to master:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Download full report as build artifact

Generated by 🚫 Danger

@garydgregory
Copy link

Also, 24-ea is available to GitHub actions, which we use over at Apache Commons as we do 23-ea, but all these fail due to the dependency on ASM 9.6.

@adangel adangel force-pushed the issue-5062-support-java-23 branch from 8353ccd to 3cb4c4a Compare July 31, 2024 19:39
adangel added 15 commits August 1, 2024 10:15
This is now possible, since java 21 preview is gone.
 ... and Instance Main Methods" (JEP 477)

 - language feature is renamed
 - update symbol table resolver
- new JModuleSymbol
- UnnecessaryImportRule also supports module imports
- module-info.class can be loaded by ClasspathClassLoader
- Support annotations on modules
- Verify that exported packages are loaded
Allow to use primitive types in patterns, instanceof, and
switch. This is a Java 23 Preview feature.
See JEP 455.
JEP 477: Implicitly Declared Classes and Instance Main Methods
(Third Preview)
Import by default module java.base
and java.io.IO.*
Reuse the classloader for auxclasspath
instead of creating a new one for every
single rule test case.
@adangel adangel force-pushed the issue-5062-support-java-23 branch from 3cb4c4a to f33e75c Compare August 1, 2024 09:47
@adangel adangel force-pushed the issue-5062-support-java-23 branch from f33e75c to 21d499d Compare August 1, 2024 09:53
@adangel adangel marked this pull request as ready for review August 1, 2024 10:02
@adangel adangel merged commit 537dab9 into master Aug 29, 2024
3 checks passed
@adangel adangel deleted the issue-5062-support-java-23 branch August 29, 2024 16:09
@Override
public @Nullable JTypeMirror resolveFirst(String simpleName) {
for (String module : moduleNames) {
JModuleSymbol moduleSymbol = symbolResolver.resolveModule(module);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be cached in the name resolver, otherwise it will perform a classloader lookup and parse the module file for every name that is requested (which is probably all the type identifiers in the compilation unit).

}

for (String packageName : moduleSymbol.getExportedPackages()) {
JClassSymbol sym = symbolResolver.resolveClassFromCanonicalName(packageName + "." + simpleName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should resolve from binary name instead of canonical name, otherwise it will try every package segment. But we know that these segments are packages and not outer classes. This is different from type import on demand, because these can import inner types too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[java] Support Java 23
5 participants