Skip to content

Conversation

@ericdallo
Copy link
Contributor

This fix a graalvm compatibility with the logger api (only one I tested in my lib), this exports the graalvm config automatically for clients.

Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: An object of type 'io.opentelemetry.api.common.AttributeType' was found in the image heap. This type, however, is marked for initialization at image run time for the following reason: classes are initialized at run time by default.
This is not allowed for correctness reasons: All objects that are stored in the image heap must be initialized at build time.

You now have two options to resolve this:

1) If it is intended that objects of type 'io.opentelemetry.api.common.AttributeType' are persisted in the image heap, add

    '--initialize-at-build-time=io.opentelemetry.api.common.AttributeType'

to the native-image arguments. Note that initializing new types can store additional objects to the heap. It is advised to check the static fields of 'io.opentelemetry.api.common.AttributeType' to see if they are safe for build-time initialization,  and that they do not contain any sensitive data that should not become part of the image.

2) If these objects should not be stored in the image heap, you can use

    '--trace-object-instantiation=io.opentelemetry.api.common.AttributeType'

to find classes that instantiate these objects. Once you found such a class, you can mark it explicitly for run time initialization with

    '--initialize-at-run-time=<culprit>'

to prevent the instantiation of the object.

If you are seeing this message after upgrading to a new GraalVM release, this means that some objects ended up in the image heap without their type being marked with --initialize-at-build-time.
To fix this, include '--initialize-at-build-time=io.opentelemetry.api.common.AttributeType' in your configuration. If the classes do not originate from your code, it is advised to update all library or framework dependencies to the latest version before addressing this error.

The following detailed trace displays from which field in the code the object was reached.
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.classinitialization.ClassInitializationFeature.checkImageHeapInstance(ClassInitializationFeature.java:206)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisType.lambda$notifyObjectReachable$12(AnalysisType.java:659)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.util.ConcurrentLightHashSet.forEach(ConcurrentLightHashSet.java:149)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.meta.AnalysisType.notifyObjectReachable(AnalysisType.java:659)
        at org.graalvm.nativeimage.pointsto/com.oracle.graal.pointsto.heap.ImageHeapScanner.onObjectReachable(ImageHeapScanner.java:586)
        ... 11 more

@ericdallo ericdallo requested a review from a team as a code owner February 28, 2025 14:26
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 28, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@codecov
Copy link

codecov bot commented Feb 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.85%. Comparing base (cd1f617) to head (8499295).
⚠️ Report is 333 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #7160   +/-   ##
=========================================
  Coverage     89.85%   89.85%           
  Complexity     6622     6622           
=========================================
  Files           740      740           
  Lines         20007    20007           
  Branches       1968     1968           
=========================================
  Hits          17978    17978           
  Misses         1439     1439           
  Partials        590      590           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@trask
Copy link
Member

trask commented Feb 28, 2025

cc @jeanbisutti

@jack-berg
Copy link
Member

Hmm.. its not clear to me what the problem is with AttributeType that requires it to be handled with this special case.

Can you provide a repro of the issue? Would good to add it to our graal test suite.

@jeanbisutti
Copy link
Member

@ericdallo Could you please provide the GraalVM version for which the problem appears?

@ericdallo
Copy link
Contributor Author

@jeanbisutti

native-image 23.0.1 2024-10-15
GraalVM Runtime Environment GraalVM CE 23.0.1+11.1 (build 23.0.1+11-jvmci-b01)
Substrate VM GraalVM CE 23.0.1+11.1 (build 23.0.1+11, serial gc)

@jack-berg I reproed that using the log appender of timbre here on clojure-lsp, I can't spend more time on this though, so after this PR, I included on clojure-lsp here to fix my case meanwhile

@jeanbisutti
Copy link
Member

@jack-berg The native tests are executed with GraalVM 21:

It may be worth to run them with version 23 as well (the last one).

@jack-berg jack-berg mentioned this pull request Mar 4, 2025
@jack-berg
Copy link
Member

It may be worth to run them with version 23 as well (the last one).

See #7167

@jkwatson
Copy link
Contributor

Is this still needed/wanted? It's been open a while, and I don't have a problem with it, but let's either get it merged, or close it.

@ericdallo
Copy link
Contributor Author

It's still a improvement for default, I suggest merge it so users don't need to spend debugging I like I did

@jkwatson jkwatson merged commit 35cc474 into open-telemetry:main Sep 11, 2025
27 checks passed
@otelbot
Copy link
Contributor

otelbot bot commented Sep 11, 2025

Thank you for your contribution @ericdallo! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

the-clam pushed a commit to the-clam/opentelemetry-java that referenced this pull request Nov 6, 2025
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.

5 participants