While investigating the behaviour of JFR Exception and Error events I produced a small program:
public class ExceptionProducer {
private static Throwable THIS_THROWABLE;
public static void main(String[] args) {
while (true) {
THIS_THROWABLE = new NullPointerException();
THIS_THROWABLE = new InstantiationError();
}
}
}
Doing a small (3 s) recording I get 523072 Java Error events, all stacktraces going from java.lang.Error.<init>() up to ExceptionProducer.main(String[]).
At the same time I get 1569219 Java Exception events:
# events 1st frame 2nd frame 3rd frame
523073 java.lang.Throwable.<init>() java.lang.Exception.<init>() java.lang.RuntimeException.<init>()
523072 java.lang.Throwable.<init>() java.lang.Error.<init>() java.lang.LinkageError.<init>()
523072 java.lang.Error.<init>() java.lang.LinkageError.<init>() java.lang.IncompatibleClassChangeError.<init>()
While it is correct that Java Exception events should be created errors, it seems like every error creation alse creates two JFR events - one from the constructor of java.lang.Throwable and on from the constructor of java.lang.Error.
Are we somehow doing an extra event creation because of the Java Error event creation?
public class ExceptionProducer {
private static Throwable THIS_THROWABLE;
public static void main(String[] args) {
while (true) {
THIS_THROWABLE = new NullPointerException();
THIS_THROWABLE = new InstantiationError();
}
}
}
Doing a small (3 s) recording I get 523072 Java Error events, all stacktraces going from java.lang.Error.<init>() up to ExceptionProducer.main(String[]).
At the same time I get 1569219 Java Exception events:
# events 1st frame 2nd frame 3rd frame
523073 java.lang.Throwable.<init>() java.lang.Exception.<init>() java.lang.RuntimeException.<init>()
523072 java.lang.Throwable.<init>() java.lang.Error.<init>() java.lang.LinkageError.<init>()
523072 java.lang.Error.<init>() java.lang.LinkageError.<init>() java.lang.IncompatibleClassChangeError.<init>()
While it is correct that Java Exception events should be created errors, it seems like every error creation alse creates two JFR events - one from the constructor of java.lang.Throwable and on from the constructor of java.lang.Error.
Are we somehow doing an extra event creation because of the Java Error event creation?