APIdia Launch Partner
Top Description Methods
jdk.jfr.events

public @Interface StackFilter

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

Event annotation, specifies method names or classes to exclude in a stack trace.

The following example illustrates how the StackFilter annotation can be used to remove the Logger::log method in a stack trace:

package com.example; @Name("example.LogMessage") @Label("Log Message") @StackFilter("com.example.Logger::log") class LogMessage extends Event { @Label("Message") String message; } public class Logger { public static void log(String message) { System.out.print(Instant.now() + " : " + message); LogMessage event = new LogMessage(); event.message = message; event.commit(); } }
package com.example;

@Name("example.LogMessage")
@Label("Log Message")
@StackFilter("com.example.Logger::log")
class LogMessage extends Event {
    @Label("Message")
    String message;
}

public class Logger {

    public static void log(String message) {
        System.out.print(Instant.now() + " : " + message);
        LogMessage event = new LogMessage();
        event.message = message;
        event.commit();
    }
}
Since
22

Method Summary

Modifier and TypeMethod and Description
public String[]

Returns:

the method names, not null
value
()

The methods or classes that should not be part of an event stack trace.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public String[] value()

The methods or classes that should not be part of an event stack trace.

A filter is formed by using the fully qualified class name concatenated with the method name using "::" as separator, for example "java.lang.String::toString"

If only the name of a class is specified, for example "java.lang.String", all methods in that class are filtered out.

Methods can't be qualified using method parameters or return types.

Instance methods belonging to an interface can't be filtered out.

Wilcards are not permitted.

Returns:String[]

the method names, not null