jdk.jfr.internal.instrument.JDKEvents Java Examples
The following examples show how to use
jdk.jfr.internal.instrument.JDKEvents.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlatformRecorder.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public PlatformRecorder() throws Exception { repository = Repository.getRepository(); Logger.log(JFR_SYSTEM, INFO, "Initialized disk repository"); repository.ensureRepository(); jvm.createNativeJFR(); Logger.log(JFR_SYSTEM, INFO, "Created native"); JDKEvents.initialize(); Logger.log(JFR_SYSTEM, INFO, "Registered JDK events"); JDKEvents.addInstrumentation(); startDiskMonitor(); SecuritySupport.registerEvent(ActiveRecordingEvent.class); activeRecordingEvent = EventType.getEventType(ActiveRecordingEvent.class); SecuritySupport.registerEvent(ActiveSettingEvent.class); activeSettingEvent = EventType.getEventType(ActiveSettingEvent.class); shutdownHook = SecuritySupport.createThreadWitNoPermissions("JFR: Shutdown Hook", new ShutdownHook(this)); SecuritySupport.setUncaughtExceptionHandler(shutdownHook, new ShutdownHook.ExceptionHandler()); SecuritySupport.registerShutdownHook(shutdownHook); timer = createTimer(); }
Example #2
Source File: JVMUpcalls.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Called by the JVM when a retransform happens on a tagged class * * @param traceId * Id of the class * @param dummy * (not used but needed since invoke infrastructure in native * uses same signature bytesForEagerInstrumentation) * @param clazz * class being retransformed * @param oldBytes * byte code * @return byte code to use * @throws Throwable */ static byte[] onRetransform(long traceId, boolean dummy, Class<?> clazz, byte[] oldBytes) throws Throwable { try { if (Event.class.isAssignableFrom(clazz) && !Modifier.isAbstract(clazz.getModifiers())) { EventHandler handler = Utils.getHandler(clazz.asSubclass(Event.class)); if (handler == null) { Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "No event handler found for " + clazz.getName() + ". Ignoring instrumentation request."); // Probably triggered by some other agent return oldBytes; } Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Adding instrumentation to event class " + clazz.getName() + " using retransform"); EventInstrumentation ei = new EventInstrumentation(clazz.getSuperclass(), oldBytes, traceId); byte[] bytes = ei.buildInstrumented(); ASMToolkit.logASM(clazz.getName(), bytes); return bytes; } return JDKEvents.retransformCallback(clazz, oldBytes); } catch (Throwable t) { Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Unexpected error when adding instrumentation to event class " + clazz.getName()); } return oldBytes; }
Example #3
Source File: PlatformRecorder.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public PlatformRecorder() throws Exception { repository = Repository.getRepository(); Logger.log(JFR_SYSTEM, INFO, "Initialized disk repository"); repository.ensureRepository(); jvm.createNativeJFR(); Logger.log(JFR_SYSTEM, INFO, "Created native"); JDKEvents.initialize(); Logger.log(JFR_SYSTEM, INFO, "Registered JDK events"); JDKEvents.addInstrumentation(); startDiskMonitor(); SecuritySupport.registerEvent(ActiveRecordingEvent.class); activeRecordingEvent = EventType.getEventType(ActiveRecordingEvent.class); SecuritySupport.registerEvent(ActiveSettingEvent.class); activeSettingEvent = EventType.getEventType(ActiveSettingEvent.class); shutdownHook = SecuritySupport.createThreadWitNoPermissions("JFR: Shutdown Hook", new ShutdownHook(this)); SecuritySupport.setUncaughtExceptionHandler(shutdownHook, new ShutdownHook.ExceptionHandler()); SecuritySupport.registerShutdownHook(shutdownHook); timer = createTimer(); }
Example #4
Source File: JVMUpcalls.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Called by the JVM when a retransform happens on a tagged class * * @param traceId * Id of the class * @param dummy * (not used but needed since invoke infrastructure in native * uses same signature bytesForEagerInstrumentation) * @param clazz * class being retransformed * @param oldBytes * byte code * @return byte code to use * @throws Throwable */ static byte[] onRetransform(long traceId, boolean dummy, Class<?> clazz, byte[] oldBytes) throws Throwable { try { if (Event.class.isAssignableFrom(clazz) && !Modifier.isAbstract(clazz.getModifiers())) { EventHandler handler = Utils.getHandler(clazz.asSubclass(Event.class)); if (handler == null) { Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "No event handler found for " + clazz.getName() + ". Ignoring instrumentation request."); // Probably triggered by some other agent return oldBytes; } Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Adding instrumentation to event class " + clazz.getName() + " using retransform"); EventInstrumentation ei = new EventInstrumentation(clazz.getSuperclass(), oldBytes, traceId); byte[] bytes = ei.buildInstrumented(); ASMToolkit.logASM(clazz.getName(), bytes); return bytes; } return JDKEvents.retransformCallback(clazz, oldBytes); } catch (Throwable t) { Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Unexpected error when adding instrumentation to event class " + clazz.getName()); } return oldBytes; }
Example #5
Source File: PlatformRecorder.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public PlatformRecorder() throws Exception { repository = Repository.getRepository(); Logger.log(JFR_SYSTEM, INFO, "Initialized disk repository"); repository.ensureRepository(); jvm.createNativeJFR(); Logger.log(JFR_SYSTEM, INFO, "Created native"); JDKEvents.initialize(); Logger.log(JFR_SYSTEM, INFO, "Registered JDK events"); JDKEvents.addInstrumentation(); startDiskMonitor(); SecuritySupport.registerEvent(ActiveRecordingEvent.class); activeRecordingEvent = EventType.getEventType(ActiveRecordingEvent.class); SecuritySupport.registerEvent(ActiveSettingEvent.class); activeSettingEvent = EventType.getEventType(ActiveSettingEvent.class); shutdownHook = SecuritySupport.createThreadWitNoPermissions("JFR: Shutdown Hook", new ShutdownHook(this)); SecuritySupport.setUncaughtExceptionHandler(shutdownHook, new ShutdownHook.ExceptionHandler()); SecuritySupport.registerShutdownHook(shutdownHook); timer = createTimer(); }
Example #6
Source File: JVMUpcalls.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Called by the JVM when a retransform happens on a tagged class * * @param traceId * Id of the class * @param dummy * (not used but needed since invoke infrastructure in native * uses same signature bytesForEagerInstrumentation) * @param clazz * class being retransformed * @param oldBytes * byte code * @return byte code to use * @throws Throwable */ static byte[] onRetransform(long traceId, boolean dummy, Class<?> clazz, byte[] oldBytes) throws Throwable { try { if (Event.class.isAssignableFrom(clazz) && !Modifier.isAbstract(clazz.getModifiers())) { EventHandler handler = Utils.getHandler(clazz.asSubclass(Event.class)); if (handler == null) { Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "No event handler found for " + clazz.getName() + ". Ignoring instrumentation request."); // Probably triggered by some other agent return oldBytes; } Logger.log(LogTag.JFR_SYSTEM, LogLevel.INFO, "Adding instrumentation to event class " + clazz.getName() + " using retransform"); EventInstrumentation ei = new EventInstrumentation(clazz.getSuperclass(), oldBytes, traceId); byte[] bytes = ei.buildInstrumented(); ASMToolkit.logASM(clazz.getName(), bytes); return bytes; } return JDKEvents.retransformCallback(clazz, oldBytes); } catch (Throwable t) { Logger.log(LogTag.JFR_SYSTEM, LogLevel.WARN, "Unexpected error when adding instrumentation to event class " + clazz.getName()); } return oldBytes; }
Example #7
Source File: ManagementSupport.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static List<EventType> getEventTypes() { // would normally be checked when a Flight Recorder instance is created Utils.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return new ArrayList<>(); } JDKEvents.initialize(); // make sure JDK events are available return Collections.unmodifiableList(MetadataRepository.getInstance().getRegisteredEventTypes()); }
Example #8
Source File: ManagementSupport.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static List<EventType> getEventTypes() { // would normally be checked when a Flight Recorder instance is created Utils.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return new ArrayList<>(); } JDKEvents.initialize(); // make sure JDK events are available return Collections.unmodifiableList(MetadataRepository.getInstance().getRegisteredEventTypes()); }
Example #9
Source File: ManagementSupport.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static List<EventType> getEventTypes() { // would normally be checked when a Flight Recorder instance is created Utils.checkAccessFlightRecorder(); if (JVMSupport.isNotAvailable()) { return new ArrayList<>(); } JDKEvents.initialize(); // make sure JDK events are available return Collections.unmodifiableList(MetadataRepository.getInstance().getRegisteredEventTypes()); }