Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8152859

Move com.sun.management.ThreadMXBean contents to java.lang.management.ThreadMXBean

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P3 P3
    • 10
    • 9
    • core-svc
    • 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.

            hb Harsha Wardhana B (Inactive)
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: