javajdb

JDB Print Global Variables


I have attached an application to the jdb debugger. I am trying to know the state of the global/class variables through jdb debugger.

Class MyClass() {

    private static String myString;

    public void myMethod() {
    // Some code
    }

}

Let's say my breakpoint is in myMethod() method. We can print the variables using print / dump command (Please refer here). I tried to print class variable myString using the command print myString when the breakpoint is in the method myMethod(). But it threw the exception - com.sun.tools.example.debug.expr.ParseException: Name unknown: myString. I am able to print/dump local variables present in the method myMethod().


Solution

  • Since myString is a static field on the class, you should be able to access it by using a static identifier:

    dump <full-classpath>.MyClass.myString