Skip to content

Commit 30b3d58

Browse files
RafalSumislawskilrytz
authored andcommitted
Fix -Yprofile-enabled on java 9+
1 parent f8a5497 commit 30b3d58

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/compiler/scala/tools/nsc/profile/ExtendedThreadMxBean.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,14 @@ public SunThreadMxBean(ThreadMXBean underlying) {
260260
super(underlying);
261261
this.real = underlying;
262262
try {
263-
getThreadUserTimeMethod = real.getClass().getMethod("getThreadUserTime", long[].class);
264-
isThreadAllocatedMemoryEnabledMethod = real.getClass().getMethod("isThreadAllocatedMemoryEnabled");
265-
setThreadAllocatedMemoryEnabledMethod = real.getClass().getMethod("setThreadAllocatedMemoryEnabled", Boolean.TYPE);
266-
getThreadAllocatedBytesMethod1 = real.getClass().getMethod("getThreadAllocatedBytes", Long.TYPE);
267-
getThreadAllocatedBytesMethod2 = real.getClass().getMethod("getThreadAllocatedBytes", long[].class);
268-
isThreadAllocatedMemorySupportedMethod = real.getClass().getMethod("isThreadAllocatedMemorySupported");
269-
getThreadCpuTimeMethod = real.getClass().getMethod("getThreadCpuTime", long[].class);
263+
Class<?> cls = Class.forName("com.sun.management.ThreadMXBean");
264+
getThreadUserTimeMethod = cls.getMethod("getThreadUserTime", long[].class);
265+
isThreadAllocatedMemoryEnabledMethod = cls.getMethod("isThreadAllocatedMemoryEnabled");
266+
setThreadAllocatedMemoryEnabledMethod = cls.getMethod("setThreadAllocatedMemoryEnabled", Boolean.TYPE);
267+
getThreadAllocatedBytesMethod1 = cls.getMethod("getThreadAllocatedBytes", Long.TYPE);
268+
getThreadAllocatedBytesMethod2 = cls.getMethod("getThreadAllocatedBytes", long[].class);
269+
isThreadAllocatedMemorySupportedMethod = cls.getMethod("isThreadAllocatedMemorySupported");
270+
getThreadCpuTimeMethod = cls.getMethod("getThreadCpuTime", long[].class);
270271

271272
getThreadUserTimeMethod.setAccessible(true);
272273
isThreadAllocatedMemoryEnabledMethod.setAccessible(true);

0 commit comments

Comments
 (0)