Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8130940

JDK needs to allow debuggers to step into ClassLoader consistently

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P3
    • Resolution: Won't Fix
    • Affects Version/s: 8u45
    • Fix Version/s: None
    • Component/s: core-svc
    • Labels:

      Description


      JDK does not allow debuggers to step into ClassLoader.loadClass consistently.
       Stepping into a code line where class loading happens (on first use of
      class) sometimes goes into ClassLoader and sometimes not.

      The only way we've found to consistently get JDK to allow debuggers to step
      into ClassLoader is to call a constructor.

      This behavior is seen across many debuggers. Those tested: jdb, Netbeans
      8.0.2, IDEA, Eclipse 4.4.2 (Luna Service Release 2)

      The following is a jdb session where debugger does not step into ClassLoader:

      >jdb org.StartClass
      Initializing jdb ...
      > stop at org.StartClass:6
      Deferring breakpoint org.StartClass:6.
      It will be set after the class is loaded.
      > run
      run org.StartClass
      Set uncaught java.lang.Throwable
      Set deferred uncaught java.lang.Throwable
      >
      VM Started: Set deferred breakpoint org.StartClass:6

      Breakpoint hit: "thread=main", org.StartClass.main(), line=6 bci=0

      main[1] exclude "none"
      main[1] step
      >
      Step completed: "thread=main", org.StartClass.main(), line=7 bci=4



      The following is a jdb session where debugger steps into ClassLoader (on
      constructor):

      > jdb org.StartClass
      Initializing jdb ...
      > stop at org.StartClass:5
      Deferring breakpoint org.StartClass:5.
      It will be set after the class is loaded.
      > run
      run org.StartClass
      Set uncaught java.lang.Throwable
      Set deferred uncaught java.lang.Throwable
      >
      VM Started: Set deferred breakpoint org.StartClass:5

      Breakpoint hit: "thread=main", org.StartClass.main(), line=5 bci=0

      main[1] exclude "none"
      main[1] step
      >
      Step completed: "thread=main", java.lang.ClassLoader.loadClass(), line=357
      bci=0


      Java Development has analyzed the issue and requested this enhancement
      request based on the following:

      Javap output differs between the two cases.

      When we use the static instance:

      javap -v org.StartClass:
      public static void main(java.lang.String[]);
        Code:
         Stack=1, Locals=2, Args_size=1
         0: getstatic #2; //Field org/Constants.INSTANCE:Lorg/Constants;
         3: astore_1
         4: return
        LineNumberTable:
         line 6: 0
         line 7: 4
      }

      When we use the constructor:

      javap -v org.StartClass:
      public static void main(java.lang.String[]);
        Code:
         Stack=2, Locals=2, Args_size=1
         0: new #2; //class org/Constants
         3: dup
         4: invokespecial #3; //Method org/Constants."<init>":()V
         7: astore_1
         8: return
        LineNumberTable:
         line 5: 0
         line 7: 8
      }

      The debuggers "step" command can step into an invokespecial, but
      unfortunately it currently can't for getstatic.

      Implementing this facility will require an enhancement that could potentially
      be backported.


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dtitov Daniil Titov (Inactive)
              Reporter:
              shadowbug Shadow Bug
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: