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

com.oracle.svm.core.jdk.UnsupportedFeatureError: OperatingSystemMXBean #3289

Closed
RafaelCavazza opened this issue Mar 18, 2021 · 6 comments · Fixed by #4383
Closed

com.oracle.svm.core.jdk.UnsupportedFeatureError: OperatingSystemMXBean #3289

RafaelCavazza opened this issue Mar 18, 2021 · 6 comments · Fixed by #4383
Assignees

Comments

@RafaelCavazza
Copy link

We are trying to collect some runtime and system metrics using the com.sun.management.OperatingSystemMXBean.

Stack Trace:

com.oracle.svm.core.jdk.UnsupportedFeatureError: OperatingSystemMXBean methods
        at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:87)
        at com.oracle.svm.core.jdk.management.SubstrateOperatingSystemMXBean.getFreePhysicalMemorySize(SubstrateOperatingSystemMXBean.java:109)
        at arch.monitoring.opentelemetry.metric.enviroment.SystemMetrics.lambda$initCollectors$3(SystemMetrics.java:49)
        at arch.monitoring.opentelemetry.metric.observer.OpenTelemetryDoubleValueObserver$Builder.lambda$setUpdater$0(OpenTelemetryDoubleValueObserver.java:34)
        at io.opentelemetry.sdk.metrics.AsynchronousInstrumentAccumulator.lambda$doubleAsynchronousAccumulator$2(AsynchronousInstrumentAccumulator.java:40)
        at io.opentelemetry.sdk.metrics.AsynchronousInstrumentAccumulator.collectAll(AsynchronousInstrumentAccumulator.java:74)
        at io.opentelemetry.sdk.metrics.AbstractAsynchronousInstrument.collectAll(AbstractAsynchronousInstrument.java:23)
        at io.opentelemetry.sdk.metrics.SdkMeter.collectAll(SdkMeter.java:102)
        at io.opentelemetry.sdk.metrics.SdkMeterProvider.collectAllMetrics(SdkMeterProvider.java:69)
        at arch.monitoring.opentelemetry.metric.MyIntervalMetricReader$Exporter.run(MyIntervalMetricReader.java:79)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.lang.Thread.run(Thread.java:834)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)

Our code:

var operatingSystemMXBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();

var freeMemory = operatingSystemMXBean.getFreePhysicalMemorySize();

GraalVM Version
openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment GraalVM CE 21.0.0.2 (build 11.0.10+8-jvmci-21.0-b06)
OpenJDK 64-Bit Server VM GraalVM CE 21.0.0.2 (build 11.0.10+8-jvmci-21.0-b06, mixed mode, sharing)

Enviroment:

  • OS: macOS Catalina - 10.15.7 (19H15)
  • Architecture: AMD64
@munishchouhan
Copy link
Contributor

@RafaelCavazza thanks for reporting the issue
we will take a look and get back to you

@munishchouhan
Copy link
Contributor

munishchouhan commented Mar 22, 2021

@RafaelCavazza I tried a simple sysout with GraalVM CE 21.0.0.2 and it worked
please provide specific reproduer :

import java.lang.management.ManagementFactory;
class Main{
    public static void main(String[] args) {
        var operatingSystemMXBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
        var freeMemory = operatingSystemMXBean.getFreePhysicalMemorySize();
        System.out.println(freeMemory);
    }
}

output

$ java Main.java 
861347840

@munishchouhan munishchouhan self-assigned this Mar 22, 2021
@RafaelCavazza
Copy link
Author

Hi @mcraj017!

Thanks for the response.

I built the native-image using:
mvn clean package -DskipTests -Pnative

Then a ran the binary using: ./target/MY_PROJECT

My code:

public class App {
    public static void main(String[] args) {

        var operatingSystemMXBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
        var freeMemory = operatingSystemMXBean.getFreePhysicalMemorySize();
        System.out.println("Free memory:" + freeMemory);
    }
}

The error:

Exception in thread "main" com.oracle.svm.core.jdk.UnsupportedFeatureError: OperatingSystemMXBean methods
        at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:87)
        at com.oracle.svm.core.jdk.management.SubstrateOperatingSystemMXBean.getFreePhysicalMemorySize(SubstrateOperatingSystemMXBean.java:109)
        at inter.App.main(App.java:13)

@munishchouhan
Copy link
Contributor

@RafaelCavazza thanks I am able to reproduce it and it will be resolved in future releases

@RafaelCavazza
Copy link
Author

RafaelCavazza commented May 12, 2021

Hi guys!

Any update on this issue?

This will enable us to send environment metrics with OpenTelemetry using the native image.

@ade90036
Copy link

hi @mcraj017 any ETA of this fix? Is there a potential work around?

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

Successfully merging a pull request may close this issue.

4 participants