Skip to content

fix: Fix Java type for annotated array parameters #3797

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

Merged
merged 3 commits into from
Jul 3, 2025

Conversation

ppkarwasz
Copy link
Contributor

@ppkarwasz ppkarwasz commented Jul 1, 2025

This update fixes the GraalVM reachability metadata generation for methods with annotated array parameters, such as @Nullable String[].

Previously, the code computed the fully qualified class name for the parameter using the raw type, which retained the annotations (e.g., @org.jspecify.annotations.Nullable java.lang.String). This resulted in incorrect metadata that was ignored by GraalVM.

The issue is resolved by transforming the DeclaredType into a TypeElement, effectively removing any annotations, and then calling getQualifiedName() to correctly generate the fully qualified class name without annotations.

Closes #3796

This update fixes the GraalVM reachability metadata generation for methods with annotated array parameters, such as `@Nullable String[]`.

Previously, the code computed the fully qualified class name for the parameter using the **raw** type, which retained the annotations (e.g., `@org.jspecify.annotations.Nullable java.lang.String`). This resulted in incorrect metadata that was ignored by GraalVM.

The issue is resolved by transforming the `DeclaredType` into a `TypeElement`, effectively removing any annotations, and then calling `getQualifiedName()` to correctly generate the fully qualified class name without annotations.
When compiling with JDK 8 an "unknown enum constant java.lang.annotation.ElementType.MODULE" warning appears.
@ppkarwasz ppkarwasz enabled auto-merge (squash) July 3, 2025 14:07
@ppkarwasz ppkarwasz merged commit 7da8450 into 2.x Jul 3, 2025
7 checks passed
@ppkarwasz ppkarwasz deleted the fix/2.x/3796_annotated-array-parameters branch July 3, 2025 14:55
@github-project-automation github-project-automation bot moved this from To triage to Done in Log4j bug tracker Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Invalid Java type for annotated array parameters
2 participants