Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit e22699c

Browse files
Ekaterina VergizovaYuri Nesterenko
authored andcommitted
8231968: getCurrentThreadAllocatedBytes default implementation s/b getThreadAllocatedBytes
Pass Thread.currentThread().getId() to getThreadAllocatedBytes, remove its implSpec Backport-of: 68e5c40
1 parent 4881f8e commit e22699c

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/jdk.management/share/classes/com/sun/management/ThreadMXBean.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ public interface ThreadMXBean extends java.lang.management.ThreadMXBean {
122122
* {@link #getThreadAllocatedBytes getThreadAllocatedBytes}(Thread.currentThread().getId());
123123
* </pre></blockquote>
124124
*
125-
* @implSpec The default implementation throws
126-
* {@code UnsupportedOperationException}.
127-
*
128125
* @return an approximation of the total memory allocated, in bytes, in
129126
* heap memory for the current thread
130127
* if thread memory allocation measurement is enabled;
@@ -141,7 +138,7 @@ public interface ThreadMXBean extends java.lang.management.ThreadMXBean {
141138
* @since 13.0.6
142139
*/
143140
public default long getCurrentThreadAllocatedBytes() {
144-
throw new UnsupportedOperationException();
141+
return getThreadAllocatedBytes(Thread.currentThread().getId());
145142
}
146143

147144
/**

0 commit comments

Comments
 (0)