Can't debug javax.management.NotificationListener code
Answered
In my application I monitor memory usage with java.lang.management.MemoryMXBean and java.lang.management.MemoryPoolMXBean (similarly to http://www.javaspecialists.co.za/archive/newsletter.do?issue=092&locale=en_US).
I set javax.management.NotificationListener to MemoryMXBean - to be informed when memory usage exceeds a threshold limit. The problem is when this listener invokes a method having some breakpoints inside - neither of them ever works for me, i.e debugger never stops on any of them. So I can't debug NotificationListener code ..
Please sign in to leave a comment.
Have you found any way to debug NotificationListener classes?
I think it is difficult to do, because NotificationListener is implemented by JVM underlying Java code through JNI. I guess it bypasses JDI. It is really a challenging problem.
Hi,
I've debug the IDEA community source code com.intellij.openapi.util.LowMemoryWatcherManager and it's just stoped at a breakpoint:
Could you provide a sample project for this?
Sure, I just have a simple Spring Boot Application like this, I want to break at
System.out.println("hello world");
,however I couldn't.Did you tried to limit your application's run memory? It should be set to a very low memory to enable the trigger. Also did you run it using maven/gradle runner or the IDEA one? I can debug it normally.
I can indeed debug in JDK17. Unfortunately it does not work in JDK8. I am using azul version 1.8.0_412: