Skip to content

fix: Add GraalVM reachability metadata for non-plugin class instantiations #3800

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

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from

Conversation

ppkarwasz
Copy link
Contributor

The GraalVmProcessor currently only generates metadata for Log4j plugins, overlooking other reflection usages in Log4j Core. This change adds reachability metadata for additional reflection cases to improve compatibility with GraalVM native images.

Fixed Cases

This PR addresses the following reflective instantiations:

  • Context selectors and reliability strategies: Ensures proper instantiation under GraalVM.
  • Configuration instantiation in DefaultConfigurationBuilder: Fixes support for the log4j2.properties configuration format when running on GraalVM.
  • BlockingQueue instantiation in JSON Template Layout: Enables GraalVM compatibility. Note: MpmcArrayQueue is not supported on GraalVM and must be fixed in the JCTools project.

Known Limitations (Explicitly Ignored)

The following cases are not addressed in this PR:

  • JMX classes in log4j-1.2-api: While GraalVM supports JMX, usage of Log4j 1.x’s JMX interface is likely minimal.
  • MulticastDnsAdvertiser: This feature is probably unused and could pose a security risk by advertising log file locations via mDNS.

…tions**

The `GraalVmProcessor` currently only generates metadata for Log4j plugins, overlooking other reflection usages in Log4j Core. This change adds reachability metadata for additional reflection cases to improve compatibility with GraalVM native images.

### Fixed Cases

This PR addresses the following reflective instantiations:

* **Context selectors and reliability strategies:** Ensures proper instantiation under GraalVM.
* **`Configuration` instantiation in `DefaultConfigurationBuilder`:** Fixes support for the `log4j2.properties` configuration format when running on GraalVM.
* **`BlockingQueue` instantiation in JSON Template Layout:** Enables GraalVM compatibility. Note: `MpmcArrayQueue` is not supported on GraalVM and must be fixed in the JCTools project.

### Known Limitations (Explicitly Ignored)

The following cases are *not* addressed in this PR:

* **JMX classes in `log4j-1.2-api`:** While GraalVM supports JMX, usage of Log4j 1.x’s JMX interface is likely minimal.
* **`MulticastDnsAdvertiser`:** This feature is probably unused and could pose a security risk by advertising log file locations via mDNS.
@ppkarwasz ppkarwasz added this to the 2.25.1 milestone Jul 3, 2025
@ppkarwasz ppkarwasz requested a review from vy July 3, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To triage
Development

Successfully merging this pull request may close these issues.

1 participant