jdk.jfr.internal.handlers.EventHandler Java Examples

The following examples show how to use jdk.jfr.internal.handlers.EventHandler. 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: SettingsManager.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void updateRetransform(List<Class<? extends Event>> eventClasses) {
    List<Class<?>> classes = new ArrayList<>();
    for(Class<? extends Event> eventClass: eventClasses) {
        EventHandler eh = Utils.getHandler(eventClass);
        if (eh != null ) {
            PlatformEventType eventType = eh.getPlatformEventType();
            if (eventType.isMarkedForInstrumentation()) {
                classes.add(eventClass);
                eventType.markForInstrumentation(false);
                // A bit premature to set it here, but hard to check
                // after call to retransformClasses.
                eventType.setInstrumented();
            }
        }
    }
    if (!classes.isEmpty()) {
        JVM.getJVM().retransformClasses(classes.toArray(new Class<?>[0]));
    }
}
 
Example #2
Source File: MetadataRepository.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private EventHandler makeHandler(Class<? extends Event> eventClass, List<AnnotationElement> dynamicAnnotations, List<ValueDescriptor> dynamicFields) throws InternalError {
    SecuritySupport.addHandlerExport(eventClass);
    PlatformEventType pEventType = (PlatformEventType) TypeLibrary.createType(eventClass, dynamicAnnotations, dynamicFields);
    EventType eventType = PrivateAccess.getInstance().newEventType(pEventType);
    EventControl ec = new EventControl(pEventType, eventClass);
    Class<? extends EventHandler> handlerClass = null;
    try {
        String eventHandlerName = EventHandlerCreator.makeEventHandlerName(eventType.getId());
        handlerClass = Class.forName(eventHandlerName, false, Event.class.getClassLoader()).asSubclass(EventHandler.class);
        // Created eagerly on class load, tag as instrumented
        pEventType.setInstrumented();
        Logger.log(JFR_SYSTEM, DEBUG, "Found existing event handler for " + eventType.getName());
   } catch (ClassNotFoundException cne) {
       EventHandlerCreator ehc = new EventHandlerCreator(eventType.getId(),  ec.getSettingInfos(), eventType, eventClass);
       handlerClass = ehc.makeEventHandlerClass();
       Logger.log(LogTag.JFR_SYSTEM, DEBUG, "Created event handler for " + eventType.getName());
   }
    EventHandler handler = EventHandlerCreator.instantiateEventHandler(handlerClass, true, eventType, ec);
    Utils.setHandler(eventClass, handler);
    return handler;
}
 
Example #3
Source File: MetadataRepository.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public synchronized EventType register(Class<? extends Event> eventClass, List<AnnotationElement> dynamicAnnotations, List<ValueDescriptor> dynamicFields) {
    Utils.checkRegisterPermission();
    EventHandler handler = getHandler(eventClass);
    if (handler == null) {
        handler = makeHandler(eventClass, dynamicAnnotations, dynamicFields);
    }
    handler.setRegistered(true);
    typeLibrary.addType(handler.getPlatformEventType());
    if (jvm.isRecording()) {
        storeDescriptorInJVM(); // needed for emergency dump
        settingsManager.setEventControl(handler.getEventControl());
        settingsManager.updateRetransform(Collections.singletonList((eventClass)));
    } else {
        setStaleMetadata();
    }
    return handler.getEventType();
}
 
Example #4
Source File: JVMUpcalls.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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: SettingsManager.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void updateRetransform(List<Class<? extends Event>> eventClasses) {
    List<Class<?>> classes = new ArrayList<>();
    for(Class<? extends Event> eventClass: eventClasses) {
        EventHandler eh = Utils.getHandler(eventClass);
        if (eh != null ) {
            PlatformEventType eventType = eh.getPlatformEventType();
            if (eventType.isMarkedForInstrumentation()) {
                classes.add(eventClass);
                eventType.markForInstrumentation(false);
                // A bit premature to set it here, but hard to check
                // after call to retransformClasses.
                eventType.setInstrumented();
            }
        }
    }
    if (!classes.isEmpty()) {
        JVM.getJVM().retransformClasses(classes.toArray(new Class<?>[0]));
    }
}
 
Example #6
Source File: JVMUpcalls.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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: MetadataRepository.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private EventHandler makeHandler(Class<? extends Event> eventClass, List<AnnotationElement> dynamicAnnotations, List<ValueDescriptor> dynamicFields) throws InternalError {
    PlatformEventType pEventType = (PlatformEventType) TypeLibrary.createType(eventClass, dynamicAnnotations, dynamicFields);
    EventType eventType = PrivateAccess.getInstance().newEventType(pEventType);
    EventControl ec = new EventControl(pEventType, eventClass);
    Class<? extends EventHandler> handlerClass = null;
    try {
        String eventHandlerName = EventHandlerCreator.makeEventHandlerName(eventType.getId());
        handlerClass = Class.forName(eventHandlerName, false, Event.class.getClassLoader()).asSubclass(EventHandler.class);
        // Created eagerly on class load, tag as instrumented
        pEventType.setInstrumented();
        Logger.log(JFR_SYSTEM, DEBUG, "Found existing event handler for " + eventType.getName());
   } catch (ClassNotFoundException cne) {
       EventHandlerCreator ehc = new EventHandlerCreator(eventType.getId(),  ec.getSettingInfos(), eventType, eventClass);
       handlerClass = ehc.makeEventHandlerClass();
       Logger.log(LogTag.JFR_SYSTEM, DEBUG, "Created event handler for " + eventType.getName());
   }
    EventHandler handler = EventHandlerCreator.instantiateEventHandler(handlerClass, true, eventType, ec);
    Utils.setHandler(eventClass, handler);
    return handler;
}
 
Example #8
Source File: MetadataRepository.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public synchronized EventType register(Class<? extends Event> eventClass, List<AnnotationElement> dynamicAnnotations, List<ValueDescriptor> dynamicFields) {
    Utils.checkRegisterPermission();
    EventHandler handler = getHandler(eventClass);
    if (handler == null) {
        handler = makeHandler(eventClass, dynamicAnnotations, dynamicFields);
    }
    handler.setRegistered(true);
    typeLibrary.addType(handler.getPlatformEventType());
    if (jvm.isRecording()) {
        storeDescriptorInJVM(); // needed for emergency dump
        settingsManager.setEventControl(handler.getEventControl());
        settingsManager.updateRetransform(Collections.singletonList((eventClass)));
    } else {
        setStaleMetadata();
    }
    return handler.getEventType();
}
 
Example #9
Source File: MetadataRepository.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private EventHandler makeHandler(Class<? extends Event> eventClass, List<AnnotationElement> dynamicAnnotations, List<ValueDescriptor> dynamicFields) throws InternalError {
    SecuritySupport.addHandlerExport(eventClass);
    PlatformEventType pEventType = (PlatformEventType) TypeLibrary.createType(eventClass, dynamicAnnotations, dynamicFields);
    EventType eventType = PrivateAccess.getInstance().newEventType(pEventType);
    EventControl ec = new EventControl(pEventType, eventClass);
    Class<? extends EventHandler> handlerClass = null;
    try {
        String eventHandlerName = EventHandlerCreator.makeEventHandlerName(eventType.getId());
        handlerClass = Class.forName(eventHandlerName, false, Event.class.getClassLoader()).asSubclass(EventHandler.class);
        // Created eagerly on class load, tag as instrumented
        pEventType.setInstrumented();
        Logger.log(JFR_SYSTEM, DEBUG, "Found existing event handler for " + eventType.getName());
   } catch (ClassNotFoundException cne) {
       EventHandlerCreator ehc = new EventHandlerCreator(eventType.getId(),  ec.getSettingInfos(), eventType, eventClass);
       handlerClass = ehc.makeEventHandlerClass();
       Logger.log(LogTag.JFR_SYSTEM, DEBUG, "Created event handler for " + eventType.getName());
   }
    EventHandler handler = EventHandlerCreator.instantiateEventHandler(handlerClass, true, eventType, ec);
    Utils.setHandler(eventClass, handler);
    return handler;
}
 
Example #10
Source File: JVMUpcalls.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #11
Source File: SettingsManager.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void updateRetransform(List<Class<? extends Event>> eventClasses) {
    List<Class<?>> classes = new ArrayList<>();
    for(Class<? extends Event> eventClass: eventClasses) {
        EventHandler eh = Utils.getHandler(eventClass);
        if (eh != null ) {
            PlatformEventType eventType = eh.getPlatformEventType();
            if (eventType.isMarkedForInstrumentation()) {
                classes.add(eventClass);
                eventType.markForInstrumentation(false);
                // A bit premature to set it here, but hard to check
                // after call to retransformClasses.
                eventType.setInstrumented();
            }
        }
    }
    if (!classes.isEmpty()) {
        JVM.getJVM().retransformClasses(classes.toArray(new Class<?>[0]));
    }
}
 
Example #12
Source File: MetadataRepository.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public synchronized EventType register(Class<? extends Event> eventClass, List<AnnotationElement> dynamicAnnotations, List<ValueDescriptor> dynamicFields) {
    Utils.checkRegisterPermission();
    EventHandler handler = getHandler(eventClass);
    if (handler == null) {
        handler = makeHandler(eventClass, dynamicAnnotations, dynamicFields);
    }
    handler.setRegistered(true);
    typeLibrary.addType(handler.getPlatformEventType());
    if (jvm.isRecording()) {
        storeDescriptorInJVM(); // needed for emergency dump
        settingsManager.setEventControl(handler.getEventControl());
        settingsManager.updateRetransform(Collections.singletonList((eventClass)));
    } else {
        setStaleMetadata();
    }
    return handler.getEventType();
}
 
Example #13
Source File: EventHandlerProxyCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void buildConstructor() {
    MethodVisitor mv = classWriter.visitMethod(0x0, METHOD_EVENT_HANDLER_CONSTRUCTOR.getName(), makeConstructorDescriptor(), null, null);
    mv.visitVarInsn(Opcodes.ALOAD, 0); // this
    mv.visitVarInsn(Opcodes.ILOAD, 1); // registered
    mv.visitVarInsn(Opcodes.ALOAD, 2); // event type
    mv.visitVarInsn(Opcodes.ALOAD, 3); // event control
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(EventHandler.class), METHOD_EVENT_HANDLER_CONSTRUCTOR.getName(), METHOD_EVENT_HANDLER_CONSTRUCTOR.getDescriptor(), false);
    mv.visitInsn(Opcodes.RETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
 
Example #14
Source File: Utils.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static synchronized EventHandler getHandler(Class<? extends Event> eventClass) {
    Utils.ensureValidEventSubclass(eventClass);
    try {
        Field f = eventClass.getDeclaredField(EventInstrumentation.FIELD_EVENT_HANDLER);
        SecuritySupport.setAccessible(f);
        return (EventHandler) f.get(null);
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        throw new InternalError("Could not access event handler");
    }
}
 
Example #15
Source File: MetadataRepository.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public synchronized List<EventControl> getEventControls() {
    List<EventControl> controls = new ArrayList<>();
    controls.addAll(nativeControls);
    for (EventHandler eh : getEventHandlers()) {
        controls.add(eh.getEventControl());
    }
    return controls;
}
 
Example #16
Source File: MetadataRepository.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static List<EventHandler> getEventHandlers() {
    List<Class<? extends Event>> allEventClasses = jvm.getAllEventClasses();
    List<EventHandler> eventHandlers = new ArrayList<>(allEventClasses.size());
    for (Class<? extends Event> clazz : allEventClasses) {
        EventHandler eh = Utils.getHandler(clazz);
        if (eh != null) {
            eventHandlers.add(eh);
        }
    }
    return eventHandlers;
}
 
Example #17
Source File: MetadataRepository.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static List<EventHandler> getEventHandlers() {
    List<Class<? extends Event>> allEventClasses = jvm.getAllEventClasses();
    List<EventHandler> eventHandlers = new ArrayList<>(allEventClasses.size());
    for (Class<? extends Event> clazz : allEventClasses) {
        EventHandler eh = Utils.getHandler(clazz);
        if (eh != null) {
            eventHandlers.add(eh);
        }
    }
    return eventHandlers;
}
 
Example #18
Source File: Utils.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static synchronized EventHandler getHandler(Class<? extends Event> eventClass) {
    Utils.ensureValidEventSubclass(eventClass);
    try {
        Field f = eventClass.getDeclaredField(EventInstrumentation.FIELD_EVENT_HANDLER);
        SecuritySupport.setAccessible(f);
        return (EventHandler) f.get(null);
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        throw new InternalError("Could not access event handler");
    }
}
 
Example #19
Source File: Utils.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static synchronized void setHandler(Class<? extends Event> eventClass, EventHandler handler) {
    Utils.ensureValidEventSubclass(eventClass);
    try {
        Field field = eventClass.getDeclaredField(EventInstrumentation.FIELD_EVENT_HANDLER);
        SecuritySupport.setAccessible(field);
        field.set(null, handler);
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        throw new InternalError("Could not access event handler");
    }
}
 
Example #20
Source File: EventHandlerProxyCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static Class<? extends EventHandler> makeEventHandlerProxyClass() {
    buildClassInfo();
    buildConstructor();
    buildTimestampMethod();
    buildDurationMethod();
    byte[] bytes = classWriter.toByteArray();
    ASMToolkit.logASM(className, bytes);
    return SecuritySupport.defineClass(className, bytes, Event.class.getClassLoader()).asSubclass(EventHandler.class);
}
 
Example #21
Source File: EventHandlerProxyCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void buildTimestampMethod() {
    MethodVisitor mv = classWriter.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, METHOD_TIME_STAMP.getName(), METHOD_TIME_STAMP.getDescriptor(), null, null);
    mv.visitCode();
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(EventHandler.class), METHOD_TIME_STAMP.getName(), METHOD_TIME_STAMP.getDescriptor(), false);
    mv.visitInsn(Opcodes.LRETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
 
Example #22
Source File: EventHandlerProxyCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void buildDurationMethod() {
    MethodVisitor mv = classWriter.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, METHOD_DURATION.getName(), METHOD_DURATION.getDescriptor(), null, null);
    mv.visitCode();
    mv.visitVarInsn(Opcodes.LLOAD, 0);
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, Type.getInternalName(EventHandler.class), METHOD_DURATION.getName(), METHOD_DURATION.getDescriptor(), false);
    mv.visitInsn(Opcodes.LRETURN);
    mv.visitMaxs(0, 0);
    mv.visitEnd();
}
 
Example #23
Source File: EventHandlerCreator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Class<? extends EventHandler> makeEventHandlerClass() {
    buildClassInfo();
    buildConstructor();
    buildWriteMethod();
    byte[] bytes = classWriter.toByteArray();
    ASMToolkit.logASM(className, bytes);
    return SecuritySupport.defineClass(className, bytes, Event.class.getClassLoader()).asSubclass(EventHandler.class);
}
 
Example #24
Source File: Utils.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static synchronized void setHandler(Class<? extends Event> eventClass, EventHandler handler) {
    Utils.ensureValidEventSubclass(eventClass);
    try {
        Field field = eventClass.getDeclaredField(EventInstrumentation.FIELD_EVENT_HANDLER);
        SecuritySupport.setAccessible(field);
        field.set(null, handler);
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        throw new InternalError("Could not access event handler");
    }
}
 
Example #25
Source File: MetadataRepository.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public synchronized List<EventControl> getEventControls() {
    List<EventControl> controls = new ArrayList<>();
    controls.addAll(nativeControls);
    for (EventHandler eh : getEventHandlers()) {
        controls.add(eh.getEventControl());
    }
    return controls;
}
 
Example #26
Source File: MetadataRepository.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public synchronized List<EventType> getRegisteredEventTypes() {
    List<EventHandler> handlers = getEventHandlers();
    List<EventType> eventTypes = new ArrayList<>(handlers.size() + nativeEventTypes.size());
    for (EventHandler h : handlers) {
        if (h.isRegistered()) {
            eventTypes.add(h.getEventType());
        }
    }
    eventTypes.addAll(nativeEventTypes);
    return eventTypes;
}
 
Example #27
Source File: MetadataRepository.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public synchronized EventType getEventType(Class<? extends Event> eventClass) {
    EventHandler h = getHandler(eventClass);
    if (h != null && h.isRegistered()) {
        return h.getEventType();
    }
    throw new IllegalStateException("Event class " + eventClass.getName() + " is not registered");
}
 
Example #28
Source File: MetadataRepository.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public synchronized void unregister(Class<? extends Event> eventClass) {
    Utils.checkRegisterPermission();
    EventHandler handler = getHandler(eventClass);
    if (handler != null) {
        handler.setRegistered(false);
    }
    // never registered, ignore call
}
 
Example #29
Source File: MetadataRepository.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public synchronized void unregister(Class<? extends Event> eventClass) {
    Utils.checkRegisterPermission();
    EventHandler handler = getHandler(eventClass);
    if (handler != null) {
        handler.setRegistered(false);
    }
    // never registered, ignore call
}
 
Example #30
Source File: EventHandlerCreator.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Class<? extends EventHandler> makeEventHandlerClass() {
    buildClassInfo();
    buildConstructor();
    buildWriteMethod();
    byte[] bytes = classWriter.toByteArray();
    ASMToolkit.logASM(className, bytes);
    return SecuritySupport.defineClass(className, bytes, Event.class.getClassLoader()).asSubclass(EventHandler.class);
}