204 } |
204 } |
205 return globalTimeStamp.get(); |
205 return globalTimeStamp.get(); |
206 } |
206 } |
207 |
207 |
208 /** |
208 /** |
209 * Access to thread specific information made available via Java Management Extensions (JMX). |
|
210 * Using this abstraction enables avoiding a dependency to the {@code java.management} and |
|
211 * {@code jdk.management} modules on JDK 9 and later. |
|
212 */ |
|
213 public abstract static class JMXService { |
|
214 protected abstract long getThreadAllocatedBytes(long id); |
|
215 |
|
216 protected abstract long getCurrentThreadCpuTime(); |
|
217 |
|
218 protected abstract boolean isThreadAllocatedMemorySupported(); |
|
219 |
|
220 protected abstract boolean isCurrentThreadCpuTimeSupported(); |
|
221 |
|
222 protected abstract List<String> getInputArguments(); |
|
223 |
|
224 // Placing this static field in JMXService (instead of GraalServices) |
|
225 // allows for lazy initialization. |
|
226 static final JMXService instance = loadSingle(JMXService.class, false); |
|
227 } |
|
228 |
|
229 /** |
|
230 * Returns an approximation of the total amount of memory, in bytes, allocated in heap memory |
209 * Returns an approximation of the total amount of memory, in bytes, allocated in heap memory |
231 * for the thread of the specified ID. The returned value is an approximation because some Java |
210 * for the thread of the specified ID. The returned value is an approximation because some Java |
232 * virtual machine implementations may use object allocation mechanisms that result in a delay |
211 * virtual machine implementations may use object allocation mechanisms that result in a delay |
233 * between the time an object is allocated and the time its size is recorded. |
212 * between the time an object is allocated and the time its size is recorded. |
234 * <p> |
213 * <p> |