Java Code Examples for jdk.jfr.internal.Utils#ensureValidEventSubclass()

The following examples show how to use jdk.jfr.internal.Utils#ensureValidEventSubclass() . 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: Recording.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
RecordingSettings(Recording r, Class<? extends Event> eventClass) {
    Utils.ensureValidEventSubclass(eventClass);
    this.recording = r;
    this.identifier = String.valueOf(Type.getTypeId(eventClass));
}
 
Example 2
Source File: Recording.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
RecordingSettings(Recording r, Class<? extends Event> eventClass) {
    Utils.ensureValidEventSubclass(eventClass);
    this.recording = r;
    this.identifier = String.valueOf(Type.getTypeId(eventClass));
}
 
Example 3
Source File: Recording.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
RecordingSettings(Recording r, Class<? extends Event> eventClass) {
    Utils.ensureValidEventSubclass(eventClass);
    this.recording = r;
    this.identifier = String.valueOf(Type.getTypeId(eventClass));
}
 
Example 4
Source File: FlightRecorder.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Registers an event class.
 * <p>
 * If the event class is already registered, then the invocation of this method is
 * ignored.
 *
 * @param eventClass the event class to register, not {@code null}
 *
 * @throws IllegalArgumentException if class is abstract or not a subclass
 *         of {@link Event}
 * @throws SecurityException if a security manager exists and the caller
 *         does not have {@code FlightRecorderPermission("registerEvent")}
 */
public static void register(Class<? extends Event> eventClass) {
    Objects.requireNonNull(eventClass);
    if (JVMSupport.isNotAvailable()) {
        return;
    }
    Utils.ensureValidEventSubclass(eventClass);
    MetadataRepository.getInstance().register(eventClass);
}
 
Example 5
Source File: FlightRecorder.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Unregisters an event class.
 * <p>
 * If the event class is not registered, then the invocation of this method is
 * ignored.
 *
 * @param eventClass the event class to unregistered, not {@code null}
 * @throws IllegalArgumentException if a class is abstract or not a subclass
 *         of {@link Event}
 *
 * @throws SecurityException if a security manager exists and the caller
 *         does not have {@code FlightRecorderPermission("registerEvent")}
 */
public static void unregister(Class<? extends Event> eventClass) {
    Objects.requireNonNull(eventClass);
    if (JVMSupport.isNotAvailable()) {
        return;
    }
    Utils.ensureValidEventSubclass(eventClass);
    MetadataRepository.getInstance().unregister(eventClass);
}
 
Example 6
Source File: FlightRecorder.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds a callback for a periodic event.
 * <p>
 * The implementation of the hook should return as soon as possible, to
 * avoid blocking other Flight Recorder operations. The hook should emit
 * one or more events of the specified type. When a hook is added, the
 * interval at which the call is invoked is configurable using the
 * {@code "period"} setting.
 *
 * @param eventClass the class that the hook should run for, not {@code null}
 * @param hook the hook, not {@code null}
 * @throws IllegalArgumentException if a class is not a subclass of
 *         {@link Event}, is abstract, or the hook is already added
 * @throws IllegalStateException if the event class has the
 *         {@code Registered(false)} annotation and is not registered manually
 * @throws SecurityException if a security manager exists and the caller
 *         does not have {@code FlightRecorderPermission("registerEvent")}
 */
public static void addPeriodicEvent(Class<? extends Event> eventClass, Runnable hook) throws SecurityException {
    Objects.requireNonNull(eventClass);
    Objects.requireNonNull(hook);
    if (JVMSupport.isNotAvailable()) {
        return;
    }

    Utils.ensureValidEventSubclass(eventClass);
    Utils.checkRegisterPermission();
    AccessControlContext acc = AccessController.getContext();
    RequestEngine.addHook(acc, EventType.getEventType(eventClass).getPlatformEventType(), hook);
}
 
Example 7
Source File: EventType.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the event type for an event class, or {@code null} if it doesn't
 * exist.
 *
 * @param eventClass the event class, not {@code null}
 * @return the event class, or null if class doesn't exist
 *
 * @throws IllegalArgumentException if {@code eventClass} is an abstract class
 *
 * @throws IllegalStateException if the class is annotated with
 *         {@code Registered(false)}, but not manually registered
 */
public static EventType getEventType(Class<? extends Event> eventClass) {
    Objects.requireNonNull(eventClass);
    Utils.ensureValidEventSubclass(eventClass);
    JVMSupport.ensureWithInternalError();
    return MetadataRepository.getInstance().getEventType(eventClass);
}
 
Example 8
Source File: FlightRecorder.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Registers an event class.
 * <p>
 * If the event class is already registered, then the invocation of this method is
 * ignored.
 *
 * @param eventClass the event class to register, not {@code null}
 *
 * @throws IllegalArgumentException if class is abstract or not a subclass
 *         of {@link Event}
 * @throws SecurityException if a security manager exists and the caller
 *         does not have {@code FlightRecorderPermission("registerEvent")}
 */
public static void register(Class<? extends Event> eventClass) {
    Objects.requireNonNull(eventClass);
    if (JVMSupport.isNotAvailable()) {
        return;
    }
    Utils.ensureValidEventSubclass(eventClass);
    MetadataRepository.getInstance().register(eventClass);
}
 
Example 9
Source File: FlightRecorder.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Unregisters an event class.
 * <p>
 * If the event class is not registered, then the invocation of this method is
 * ignored.
 *
 * @param eventClass the event class to unregistered, not {@code null}
 * @throws IllegalArgumentException if a class is abstract or not a subclass
 *         of {@link Event}
 *
 * @throws SecurityException if a security manager exists and the caller
 *         does not have {@code FlightRecorderPermission("registerEvent")}
 */
public static void unregister(Class<? extends Event> eventClass) {
    Objects.requireNonNull(eventClass);
    if (JVMSupport.isNotAvailable()) {
        return;
    }
    Utils.ensureValidEventSubclass(eventClass);
    MetadataRepository.getInstance().unregister(eventClass);
}
 
Example 10
Source File: FlightRecorder.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds a hook for a periodic event.
 * <p>
 * The implementation of the hook should return as soon as possible, to
 * avoid blocking other Flight Recorder operations. The hook should emit
 * one or more events of the specified type. When a hook is added, the
 * interval at which the call is invoked is configurable using the
 * {@code "period"} setting.
 *
 * @param eventClass the class that the hook should run for, not {@code null}
 * @param hook the hook, not {@code null}
 * @throws IllegalArgumentException if a class is not a subclass of
 *         {@link Event}, is abstract, or the hook is already added
 * @throws IllegalStateException if the event class has the
 *         {@code Registered(false)} annotation and is not registered manually
 * @throws SecurityException if a security manager exists and the caller
 *         does not have {@code FlightRecorderPermission("registerEvent")}
 */
public static void addPeriodicEvent(Class<? extends Event> eventClass, Runnable hook) throws SecurityException {
    Objects.requireNonNull(eventClass);
    Objects.requireNonNull(hook);
    if (JVMSupport.isNotAvailable()) {
        return;
    }

    Utils.ensureValidEventSubclass(eventClass);
    Utils.checkRegisterPermission();
    AccessControlContext acc = AccessController.getContext();
    RequestEngine.addHook(acc, EventType.getEventType(eventClass).getPlatformEventType(), hook);
}
 
Example 11
Source File: EventType.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the event type for an event class, or {@code null} if it doesn't
 * exist.
 *
 * @param eventClass the event class, not {@code null}
 * @return the event class, or null if class doesn't exist
 *
 * @throws IllegalArgumentException if {@code eventClass} is an abstract class
 *
 * @throws IllegalStateException if the class is annotated with
 *         {@code Registered(false)}, but not manually registered
 */
public static EventType getEventType(Class<? extends Event> eventClass) {
    Objects.requireNonNull(eventClass);
    Utils.ensureValidEventSubclass(eventClass);
    JVMSupport.ensureWithInternalError();
    return MetadataRepository.getInstance().getEventType(eventClass);
}
 
Example 12
Source File: FlightRecorder.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Registers an event class.
 * <p>
 * If the event class is already registered, then the invocation of this method is
 * ignored.
 *
 * @param eventClass the event class to register, not {@code null}
 *
 * @throws IllegalArgumentException if class is abstract or not a subclass
 *         of {@link Event}
 * @throws SecurityException if a security manager exists and the caller
 *         does not have {@code FlightRecorderPermission("registerEvent")}
 */
public static void register(Class<? extends Event> eventClass) {
    Objects.requireNonNull(eventClass);
    if (JVMSupport.isNotAvailable()) {
        return;
    }
    Utils.ensureValidEventSubclass(eventClass);
    MetadataRepository.getInstance().register(eventClass);
}
 
Example 13
Source File: FlightRecorder.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Unregisters an event class.
 * <p>
 * If the event class is not registered, then the invocation of this method is
 * ignored.
 *
 * @param eventClass the event class to unregistered, not {@code null}
 * @throws IllegalArgumentException if a class is abstract or not a subclass
 *         of {@link Event}
 *
 * @throws SecurityException if a security manager exists and the caller
 *         does not have {@code FlightRecorderPermission("registerEvent")}
 */
public static void unregister(Class<? extends Event> eventClass) {
    Objects.requireNonNull(eventClass);
    if (JVMSupport.isNotAvailable()) {
        return;
    }
    Utils.ensureValidEventSubclass(eventClass);
    MetadataRepository.getInstance().unregister(eventClass);
}
 
Example 14
Source File: FlightRecorder.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds a hook for a periodic event.
 * <p>
 * The implementation of the hook should return as soon as possible, to
 * avoid blocking other Flight Recorder operations. The hook should emit
 * one or more events of the specified type. When a hook is added, the
 * interval at which the call is invoked is configurable using the
 * {@code "period"} setting.
 *
 * @param eventClass the class that the hook should run for, not {@code null}
 * @param hook the hook, not {@code null}
 * @throws IllegalArgumentException if a class is not a subclass of
 *         {@link Event}, is abstract, or the hook is already added
 * @throws IllegalStateException if the event class has the
 *         {@code Registered(false)} annotation and is not registered manually
 * @throws SecurityException if a security manager exists and the caller
 *         does not have {@code FlightRecorderPermission("registerEvent")}
 */
public static void addPeriodicEvent(Class<? extends Event> eventClass, Runnable hook) throws SecurityException {
    Objects.requireNonNull(eventClass);
    Objects.requireNonNull(hook);
    if (JVMSupport.isNotAvailable()) {
        return;
    }

    Utils.ensureValidEventSubclass(eventClass);
    Utils.checkRegisterPermission();
    AccessControlContext acc = AccessController.getContext();
    RequestEngine.addHook(acc, EventType.getEventType(eventClass).getPlatformEventType(), hook);
}
 
Example 15
Source File: EventType.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the event type for an event class, or {@code null} if it doesn't
 * exist.
 *
 * @param eventClass the event class, not {@code null}
 * @return the event class, or null if class doesn't exist
 *
 * @throws IllegalArgumentException if {@code eventClass} is an abstract class
 *
 * @throws IllegalStateException if the class is annotated with
 *         {@code Registered(false)}, but not manually registered
 */
public static EventType getEventType(Class<? extends Event> eventClass) {
    Objects.requireNonNull(eventClass);
    Utils.ensureValidEventSubclass(eventClass);
    JVMSupport.ensureWithInternalError();
    return MetadataRepository.getInstance().getEventType(eventClass);
}