-
Enhancement
-
Resolution: Not an Issue
-
P3
-
9
-
None
In pre-modular world, some tools (e.g. JMH -prof gc) used ThreadMXBean to gain access to interesting methods like getThreadAllocatedBytes. In post-modular world, trying to do the usual trick fails either on setAccessible on non-exported method, or later during the invocation.
ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
try {
getBytes = threadMXBean.getClass().getMethod("getThreadAllocatedBytes", long[].class);
getBytes.setAccessible(true);
} catch (Throwable e) {
...
}
While -XaddExports:jdk.management/com.sun.management.internal=ALL-UNNAMED works as workaround, it seems better to just move the contents of ThreadMXBean from internal to public interface.
ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
try {
getBytes = threadMXBean.getClass().getMethod("getThreadAllocatedBytes", long[].class);
getBytes.setAccessible(true);
} catch (Throwable e) {
...
}
While -XaddExports:jdk.management/com.sun.management.internal=ALL-UNNAMED works as workaround, it seems better to just move the contents of ThreadMXBean from internal to public interface.
- relates to
-
CODETOOLS-7901645 -prof gc fails with post-Jigsaw JDK 9 EA
-
- Resolved
-