graal icon indicating copy to clipboard operation
graal copied to clipboard

[GR-40463] Add initial support for JMX to Native Image

Open roberttoyonaga opened this issue 3 years ago • 0 comments

Related issue: https://github.com/oracle/graal/issues/4732

Currently, a native image JMX server can be started and a java client can connect. Methods can be invoked on managed beans remotely. The server will start automatically if JMX is specified at executable runtime (ie. -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.port=9999). JMX should work with password authentication and SSL for both client and server.

To build a native image as a JMX server use the option --enable-monitoring=jmxserver. To build as a JMX client use --enable-monitoring=jmxclient

Question/Problem [Resolved: https://github.com/oracle/graal/pull/4786#discussion_r960554175]

There is a problem exclusive to native image JMX clients (using JmxClientFeature). It has to do with the distributed garbage collection calling native method sun.rmi.transport.GC.maxObjectInspectionAge() which itself calls JVM_MaxObjectInspectionAge. Since it seems like JVM_MaxObjectInspectionAge is unimplemented in SubstrateVM, this operation fails with JVM_MaxObjectInspectionAge called: Unimplemented.

Current solution

This method has been substituted here as a work around: Target_sun_rmi_transport_GC.java. Can someone please advise what the best way to handle this is? It seems like the distributed GC invokes a client local garbage collection periodically, if one hasn't already happened within a specified window of time (if one is even specified). This enforces an upper bound on the time to find remote objects that have become unreachable. It appears that this is meant to be supplemental to the normal GC operations. Could it be ok to not do this?

Reproduction

To reproduce the error, just comment out the method substitution, build and run a native image JMX client. You can use the client here. ./tester <portnumber> false This tester app assumes running everything on localhost.

Here are some simple apps I have been using as JMX client / servers : https://github.com/roberttoyonaga/jfr-tests/tree/addJavaMonitorEnterTests/src/main/java/com/redhat/jfr/tests/jmx

roberttoyonaga avatar Aug 03 '22 13:08 roberttoyonaga