--- old/src/jdk.management/share/classes/com/sun/management/ThreadMXBean.java 2019-09-15 02:47:49.000000000 -0700 +++ new/src/jdk.management/share/classes/com/sun/management/ThreadMXBean.java 2019-09-15 02:47:49.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,7 @@ * @throws NullPointerException if {@code ids} is {@code null} * @throws IllegalArgumentException if any element in the input array * {@code ids} is {@code <=} {@code 0}. - * @throws java.lang.UnsupportedOperationException if the Java + * @throws UnsupportedOperationException if the Java * virtual machine implementation does not support CPU time * measurement. * @@ -95,7 +95,7 @@ * @throws NullPointerException if {@code ids} is {@code null} * @throws IllegalArgumentException if any element in the input array * {@code ids} is {@code <=} {@code 0}. - * @throws java.lang.UnsupportedOperationException if the Java + * @throws UnsupportedOperationException if the Java * virtual machine implementation does not support CPU time * measurement. * @@ -109,13 +109,44 @@ /** * Returns an approximation of the total amount of memory, in bytes, - * allocated in heap memory for the thread of the specified ID. + * allocated in heap memory for the current thread. + * The returned value is an approximation because some Java virtual machine + * implementations may use object allocation mechanisms that result in a + * delay between the time an object is allocated and the time its size is + * recorded. + * + *

+ * This is a convenience method for local management use and is + * equivalent to calling: + *

+     *   {@link #getThreadAllocatedBytes getThreadAllocatedBytes}(Thread.currentThread().getId());
+     * 
+ * + * @return an approximation of the total memory allocated, in bytes, in + * heap memory for the current thread + * if thread memory allocation measurement is enabled; + * {@code -1} otherwise. + * + * @throws UnsupportedOperationException if the Java virtual + * machine implementation does not support thread memory allocation + * measurement. + * + * @see #isThreadAllocatedMemorySupported + * @see #isThreadAllocatedMemoryEnabled + * @see #setThreadAllocatedMemoryEnabled + * @since 14 + */ + public long getCurrentThreadAllocatedBytes(); + + /** + * Returns an approximation of the total amount of memory, in bytes, + * allocated in heap memory for the thread with the specified ID. * The returned value is an approximation because some Java virtual machine * implementations may use object allocation mechanisms that result in a * delay between the time an object is allocated and the time its size is * recorded. *

- * If the thread of the specified ID is not alive or does not exist, + * If the thread with the specified ID is not alive or does not exist, * this method returns {@code -1}. If thread memory allocation measurement * is disabled, this method returns {@code -1}. * A thread is alive if it has been started and has not yet died. @@ -127,13 +158,13 @@ * * @param id the thread ID of a thread * @return an approximation of the total memory allocated, in bytes, in - * heap memory for a thread of the specified ID - * if the thread of the specified ID exists, the thread is alive, + * heap memory for the thread with the specified ID + * if the thread with the specified ID exists, the thread is alive, * and thread memory allocation measurement is enabled; * {@code -1} otherwise. * * @throws IllegalArgumentException if {@code id} {@code <=} {@code 0}. - * @throws java.lang.UnsupportedOperationException if the Java virtual + * @throws UnsupportedOperationException if the Java virtual * machine implementation does not support thread memory allocation * measurement. * @@ -165,7 +196,7 @@ * @throws NullPointerException if {@code ids} is {@code null} * @throws IllegalArgumentException if any element in the input array * {@code ids} is {@code <=} {@code 0}. - * @throws java.lang.UnsupportedOperationException if the Java virtual + * @throws UnsupportedOperationException if the Java virtual * machine implementation does not support thread memory allocation * measurement. * @@ -194,7 +225,7 @@ * @return {@code true} if thread memory allocation measurement is enabled; * {@code false} otherwise. * - * @throws java.lang.UnsupportedOperationException if the Java virtual + * @throws UnsupportedOperationException if the Java virtual * machine does not support thread memory allocation measurement. * * @see #isThreadAllocatedMemorySupported @@ -208,10 +239,10 @@ * @param enable {@code true} to enable; * {@code false} to disable. * - * @throws java.lang.UnsupportedOperationException if the Java virtual + * @throws UnsupportedOperationException if the Java virtual * machine does not support thread memory allocation measurement. * - * @throws java.lang.SecurityException if a security manager + * @throws SecurityException if a security manager * exists and the caller does not have * ManagementPermission("control"). *