--- old/src/jdk.management/share/classes/com/sun/management/ThreadMXBean.java 2019-08-28 07:32:54.000000000 -0700 +++ new/src/jdk.management/share/classes/com/sun/management/ThreadMXBean.java 2019-08-28 07:32:53.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 @@ -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. *

- * If the thread of the specified ID is not alive or does not exist, + * If thread memory allocation measurement is disabled, this method returns + * {@code -1}. + *

+ * If thread memory allocation measurement is enabled after the current thread + * has started, the Java virtual machine implementation may choose any time up + * to and including the time that the capability is enabled as the point + * where thread memory allocation measurement starts. + * + * @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 java.lang.UnsupportedOperationException if the Java virtual + * machine implementation does not support thread memory allocation + * measurement. + * + * @see #isThreadAllocatedMemorySupported + * @see #isThreadAllocatedMemoryEnabled + * @see #setThreadAllocatedMemoryEnabled + */ + 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 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,8 +158,8 @@ * * @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. *