APIdia Launch Partner
Top Description Fields Methods
jdk.jfr

public @Interface Enabled

extends Annotation
Annotations
@Target:TYPE
@Retention:RUNTIME
@Inherited
@MetadataDefinition
Imports
java.lang.annotation.ElementType, .Inherited, .Retention, .RetentionPolicy, .Target

Event annotation, determines if an event should be enabled by default.

If an event doesn't have the annotation, then by default the event is enabled.

The following example shows how the Enabled annotation can be used to create a disabled event. A disabled event will at most have the overhead of an allocation, or none if the runtime JIT compiler is able to eliminate it.

@Name("StopWatch") @Label("Stop Watch") @Category("Debugging") @StackTrace(false) @Enabled(false) public static class StopWatchEvent extends Event { } public void update() { StopWatchEvent e = new StopWatchEvent(); e.begin(); code: e.commit(); }
@Name("StopWatch")
@Label("Stop Watch")
@Category("Debugging")
@StackTrace(false)
@Enabled(false)
public static class StopWatchEvent extends Event {
}

public void update() {
    StopWatchEvent e = new StopWatchEvent();
    e.begin();
    ...
    e.commit();
}
The event can be enabled programmatically, or on command line when needed, for example:
java -XX:StartFlightRecording:StopWatch#enabled=true ...
java -XX:StartFlightRecording:StopWatch#enabled=true ...
Since
9

Field Summary

Modifier and TypeField and Description
public static final String
NAME

Setting name "enabled", signifies that the event should be recorded.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if by default the event should be enabled, false otherwise
value
()

Returns true if by default the event should be enabled, false otherwise.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Field Detail

NAMEback to summary
public static final String NAME

Setting name "enabled", signifies that the event should be recorded.

Method Detail

valueback to summary
public boolean value()

Returns true if by default the event should be enabled, false otherwise.

Returns:boolean

true if by default the event should be enabled, false otherwise