-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
…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.
Since we can't add inline comments to JSON files, it's worth providing a detailed explanation of this PR here. There are two main types of non-plugin reflection usage in the codebase:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances GraalVM native image support by adding reflection reachability metadata for non-plugin class instantiations in Log4j.
- Introduces a changelog entry documenting the GraalVM fixes.
- Adds
reflect-config.json
for JSON Template Layout (blocking queue constructors). - Adds
reflect-config.json
for Log4j Core (configuration builders, context selectors, reliability strategies).
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/changelog/.2.x.x/3800_graalvm-misc-reflection.xml | New entry to document GraalVM compatibility fixes |
log4j-layout-template-json/.../reflect-config.json | Registers MpmcArrayQueue and ArrayBlockingQueue constructors |
log4j-core/.../reflect-config.json | Registers constructors for core config builders, selectors, strategies |
Comments suppressed due to low confidence (4)
src/changelog/.2.x.x/3800_graalvm-misc-reflection.xml:10
- [nitpick] The changelog description is quite general; consider listing the specific reflection cases fixed (context selectors, reliability strategies, DefaultConfigurationBuilder, BlockingQueue) to give users clearer guidance.
Resolves `PropertiesConfiguration` compatibility issues with GraalVM and addresses additional minor reflection-related problems.
log4j-core/src/main/resources/META-INF/native-image/org.apache.logging.log4j/log4j-core/reflect-config.json:1
- There are no tests verifying that these GraalVM reflect-config metadata entries are actually picked up; consider adding integration or CI tests to validate native image reachability for the newly added classes.
[
log4j-core/src/main/resources/META-INF/native-image/org.apache.logging.log4j/log4j-core/reflect-config.json:1
- [nitpick] Indentation in this JSON file differs from the project's standard (2 spaces here vs. 4 elsewhere); normalizing formatting will improve consistency.
[
src/changelog/.2.x.x/3800_graalvm-misc-reflection.xml:1
- [nitpick] The changelog directory is named
.2.x.x
with a leading dot, which may be unintentional; aligning it with other version directories (e.g.,2.x.x
without a dot) will follow project conventions.
<?xml version="1.0" encoding="UTF-8"?>
...ETA-INF/native-image/org.apache.logging.log4j/log4j-layout-template-json/reflect-config.json
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks for the elaborate explanation, much appreciated.
The explanation might come handy in a couple of years after we have all forgotten why this was added. 😉 |
…tions (#3800) 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.
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:
Configuration
instantiation inDefaultConfigurationBuilder
: Fixes support for thelog4j2.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:
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.