I would like to emit custom events in jmc -I've came across the blog post about jfr custom events - http://hirt.se/blog/?p=444 . The author however stressed that this feature may be depracted in the future. Since the jmc is not open source I am unable to check it. Is the information in the blogpost still up to date?
Asked
Active
Viewed 828 times
2 Answers
4
JDK 9 has been released and it contains a supported API to create custom events. Example,
@Label("Hello World!")
class HelloWorld extends jdk.jfr.Event {
@Label("Message")
String message;
}
class App {
public static void main(String... args) {
HelloWorld e = new HelloWorld();
e.message = "hello, world!";
e.commit();
}
}

AlBlue
- 23,254
- 14
- 71
- 91

Kire Haglin
- 6,569
- 22
- 27
2
The Blogposter here! :) I've started hacking together a few small plug-ins for JFR during the Hackergarten meetings in Luzern, to showcase how these APIs can be used. I've open sourced them here:
https://github.com/thegreystone
When JDK 9 is released, I will submit updates that will make them support both JDK7/8 and JDK 9 transparently, to showcase how it can be done. Note that using the JDK7/8 JFR API is NOT supported, and never will be. That said, it's nevertheless pretty useful. ;)

Hirt
- 1,664
- 10
- 12