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

Upgrading to graal-sdk 22.1.0 resulting in MXBean issue: UnsupportedFeatureException #4543

Open
mpeddada1 opened this issue May 5, 2022 · 5 comments
Assignees

Comments

@mpeddada1
Copy link

mpeddada1 commented May 5, 2022

Describe the issue
Upgrading to the latest graal-sdk (22.1.0) is causing a failure at image build time. Note that this used to work fine with 22.0.0.2.

Describe GraalVM and your environment:

The code experiencing the issue transitively brings in a dependency that contains the following pom.xml setup:

 </dependencies>
<dependency>
      <groupId>org.graalvm.nativeimage</groupId>
      <artifactId>svm</artifactId>
      <version>22.0.0.2</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.graalvm.sdk</groupId>
      <artifactId>graal-sdk</artifactId>
      <version>22.1.0</version>
      <scope>provided</scope>
    </dependency>
 </dependencies>

Java setup:

openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment GraalVM CE 22.1.0 (build 11.0.15+10-jvmci-22.1-b06)
OpenJDK 64-Bit Server VM GraalVM CE 22.1.0 (build 11.0.15+10-jvmci-22.1-b06, mixed mode, sharing)
  • OS: Linux

More details
Running the native image build with the --trace-class-initialization=com.sun.management.internal.HotSpotDiagnostic results in:

INFO] Executing: .../.sdkman/candidates/java/22.1.0.r11-grl/bin/native-image @/tmp/native-image5789583573657594787args org.graalvm.junit.platform.NativeImageJUnitLauncher
...
Fatal error: org.graalvm.compiler.debug.GraalError: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected a PlatformManagedObject (a MXBean defined by the virtual machine) in the image heap. This bean is introspecting the VM that runs the image builder, i.e., a VM instance that is no longer available at image runtime. Class of disallowed object: com.sun.management.internal.HotSpotDiagnostic  Object has been initialized by the com.oracle.svm.hosted.jfr.JfrFeature class initializer with a trace: 
 	at com.sun.management.internal.HotSpotDiagnostic.<init>(HotSpotDiagnostic.java:42)
	at com.sun.management.internal.PlatformMBeanProviderImpl.getDiagnosticMXBean(PlatformMBeanProviderImpl.java:274)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Unknown Source)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:566)
	at com.oracle.svm.hosted.jfr.JfrFeature.getDiagnosticBean(JfrFeature.java:154)
	at com.oracle.svm.hosted.jfr.JfrFeature.<clinit>(JfrFeature.java:125)
. Try to avoid initializing the class that stores the object in a static field The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
	at com.oracle.graal.pointsto.util.AnalysisFuture.setException(AnalysisFuture.java:49)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:269)
	at com.oracle.graal.pointsto.util.AnalysisFuture.ensureDone(AnalysisFuture.java:63)
	at com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$postTask$9(ImageHeapScanner.java:611)
	at com.oracle.graal.pointsto.util.CompletionExecutor.executeCommand(CompletionExecutor.java:193)
	at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$executeService$0(CompletionExecutor.java:177)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: Detected a PlatformManagedObject (a MXBean defined by the virtual machine) in the image heap. This bean is introspecting the VM that runs the image builder, i.e., a VM instance that is no longer available at image runtime. Class of disallowed object: com.sun.management.internal.HotSpotDiagnostic  Object has been initialized by the com.oracle.svm.hosted.jfr.JfrFeature class initializer with a trace: 
 	at com.sun.management.internal.HotSpotDiagnostic.<init>(HotSpotDiagnostic.java:42)
	at com.sun.management.internal.PlatformMBeanProviderImpl.getDiagnosticMXBean(PlatformMBeanProviderImpl.java:274)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Unknown Source)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:566)
	at com.oracle.svm.hosted.jfr.JfrFeature.getDiagnosticBean(JfrFeature.java:154)
	at com.oracle.svm.hosted.jfr.JfrFeature.<clinit>(JfrFeature.java:125)
. Try to avoid initializing the class that stores the object in a static field The object was probably created by a class initializer and is reachable from a static field. You can request class initialization at image runtime by using the option --initialize-at-run-time=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
	at com.oracle.svm.hosted.image.DisallowedImageHeapObjectFeature.error(DisallowedImageHeapObjectFeature.java:173)
	at com.oracle.svm.hosted.image.DisallowedImageHeapObjectFeature.checkDisallowedMBeanObjects(DisallowedImageHeapObjectFeature.java:162)
	at com.oracle.svm.hosted.image.DisallowedImageHeapObjectFeature.replacer(DisallowedImageHeapObjectFeature.java:119)
	at com.oracle.graal.pointsto.meta.AnalysisUniverse.replaceObject(AnalysisUniverse.java:582)
	at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.replaceObject(AnalysisConstantReflectionProvider.java:257)
	at com.oracle.svm.hosted.ameta.AnalysisConstantReflectionProvider.interceptValue(AnalysisConstantReflectionProvider.java:228)
	at com.oracle.svm.hosted.heap.SVMImageHeapScanner.transformFieldValue(SVMImageHeapScanner.java:126)
	at com.oracle.graal.pointsto.heap.ImageHeapScanner.onFieldValueReachable(ImageHeapScanner.java:331)
	at com.oracle.graal.pointsto.heap.ImageHeapScanner.onFieldValueReachable(ImageHeapScanner.java:310)
	at com.oracle.graal.pointsto.heap.ImageHeapScanner.lambda$computeTypeData$1(ImageHeapScanner.java:153)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

I was wondering if anyone had seen this error message before? There were a couple of recent changes made to JfrFeature.class, which may be related?
This issue from a previous GraalVM version looks similar: #2669.

@mpeddada1 mpeddada1 changed the title Upgrading to graal-sdk 22.1.0 results in UnsupportedFeatureException Upgrading to graal-sdk 22.1.0 resulting in MXBean issue: UnsupportedFeatureException May 6, 2022
zakkak added a commit to zakkak/quarkus that referenced this issue May 16, 2022
zakkak added a commit to zakkak/quarkus that referenced this issue May 17, 2022
zakkak added a commit to zakkak/quarkus that referenced this issue May 17, 2022
@zakkak
Copy link
Collaborator

zakkak commented May 17, 2022

FTR @mpeddada1 found that this issue is caused by registering java.lang.management.ManagementFactory and java.lang.management.RuntimeMXBean for reflection, removing these registrations seems to fix the issue (see GoogleCloudPlatform/native-image-support-java#395). Note however that it might still be worth fixing this issue since there might be some legitimate case that requires those classes to be registered for reflection.

@cyw3
Copy link
Contributor

cyw3 commented Jul 1, 2022

I have the same error, is there any solution?

@gad2103
Copy link

gad2103 commented Jul 11, 2022

same issue here

@hemalatha2808
Copy link

Any update on this issue, please as we are still observing the issue with graal version 22.1.0?

@zliu9125
Copy link

zliu9125 commented Aug 8, 2022

same issue +1

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

No branches or pull requests

7 participants