Skip to content

Commit

Permalink
Fix ClassCastException on J9
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbarny committed Mar 1, 2019
1 parent 65e229e commit bb7f771
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ public double get() {

try {
// only refer to hotspot specific class via reflection to avoid linkage errors
Class.forName("com.sun.management.ThreadMXBean");
// in reference to JMH's GC profiler (gc.alloc.rate)
registry.add("jvm.gc.alloc", Collections.<String, String>emptyMap(),
(DoubleSupplier) Class.forName(getClass().getName() + "$HotspotAllocationSupplier").getEnumConstants()[0]);
final Class<?> sunBeanClass = Class.forName("com.sun.management.ThreadMXBean");
if (sunBeanClass.isInstance(ManagementFactory.getThreadMXBean())) {
// in reference to JMH's GC profiler (gc.alloc.rate)
registry.add("jvm.gc.alloc", Collections.<String, String>emptyMap(),
(DoubleSupplier) Class.forName(getClass().getName() + "$HotspotAllocationSupplier").getEnumConstants()[0]);
}
} catch (ClassNotFoundException ignore) {
}
}
Expand Down

0 comments on commit bb7f771

Please sign in to comment.