8231968: getCurrentThreadAllocatedBytes default implementation s/b getThreadAllocatedBytes
authorphh
Wed, 23 Oct 2019 18:43:18 -0700
changeset 58773 5bb426e9acc4
parent 58772 24c5cad4dbfb
child 58775 ba524a5f7cc2
8231968: getCurrentThreadAllocatedBytes default implementation s/b getThreadAllocatedBytes Summary: Pass Thread.currentThread().getId() to getThreadAllocatedBytes, remove its implSpec Reviewed-by: dholmes, mchung, sspitsyn
src/jdk.management/share/classes/com/sun/management/ThreadMXBean.java
--- a/src/jdk.management/share/classes/com/sun/management/ThreadMXBean.java	Thu Oct 24 02:58:29 2019 +0200
+++ b/src/jdk.management/share/classes/com/sun/management/ThreadMXBean.java	Wed Oct 23 18:43:18 2019 -0700
@@ -122,9 +122,6 @@
      *   {@link #getThreadAllocatedBytes getThreadAllocatedBytes}(Thread.currentThread().getId());
      * </pre></blockquote>
      *
-     * @implSpec The default implementation throws
-     * {@code UnsupportedOperationException}.
-     *
      * @return an approximation of the total memory allocated, in bytes, in
      * heap memory for the current thread
      * if thread memory allocation measurement is enabled;
@@ -141,7 +138,7 @@
      * @since 14
      */
     public default long getCurrentThreadAllocatedBytes() {
-        throw new UnsupportedOperationException();
+        return getThreadAllocatedBytes(Thread.currentThread().getId());
     }
 
     /**