Skip to content

Commit d3cdbe0

Browse files
conditionally substitute JMX#createProxy if jmxserver feature is not built into the image.
1 parent 0208ffd commit d3cdbe0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

core/runtime/src/main/java/io/quarkus/runtime/graal/Target_javax_management_JMX.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package io.quarkus.runtime.graal;
22

3+
import java.util.function.BooleanSupplier;
4+
35
import javax.management.JMX;
46
import javax.management.MBeanServerConnection;
57
import javax.management.ObjectName;
68

79
import com.oracle.svm.core.annotate.Substitute;
810
import com.oracle.svm.core.annotate.TargetClass;
911

10-
@TargetClass(JMX.class)
12+
@TargetClass(value = JMX.class, onlyWith = Target_javax_management_JMX.JmxServerNotIncluded.class)
1113
final class Target_javax_management_JMX {
1214

1315
@Substitute
@@ -19,4 +21,18 @@ private static <T> T createProxy(MBeanServerConnection connection,
1921
throw new IllegalStateException("Not Implemented in native mode");
2022
}
2123

24+
public static class JmxServerNotIncluded implements BooleanSupplier {
25+
26+
@Override
27+
public boolean getAsBoolean() {
28+
try {
29+
Class<?> clazz = Class.forName("javax.management.remote.rmi.RMIServer");
30+
clazz.getDeclaredMethod("getVersion");
31+
Class.forName("com.sun.jmx.remote.protocol.rmi.ServerProvider");
32+
return false;
33+
} catch (Exception e) {
34+
return true;
35+
}
36+
}
37+
}
2238
}

0 commit comments

Comments
 (0)