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

Stepping in static initializer always by byte-code and always setp-into

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.1.6
    • core-svc
    • x86
    • windows_nt



      Name: diC59631 Date: 06/18/98


      It seems impossible to do a normal step-over by line when in a static initializer. The VM always behaves as if you're doing a step-into by byte code.

      I created a jdb testcase that shows the problem. I compiled
      these two simple Java classes (with -g) and then did a jdb session, a log
      of which I also included in this email.

      Note that the jdb command 'step' means "step into, step by line number",
      and "next" means "step over, step by line number". OK. You can see the
      problem by looking at the log when I enter MyOtherClass.<clinit> (the
      static initializer). You'll see that I keep entering "next" but that it is
      stepping per byte code and then it steps into foo(), when it should be
      stepping by line number and stepping over the foo call.

      This is exactly the same behavior that is happening in my CodeWarrior
      debugger plugin. It is very annoying.

      I wonder if this doesn't have something to do with the class lock that
      occurs when inside a static initializer (the reason why you can't do a
      source listing or class dump while you're in a static initializer). I've
      seen this in another bug report and I wonder if that is the reason why the
      VM must do a step by bytecode when in the clinit.

      John

      Let me know if you have any questions.

      MyClass.java
      --------------
      public class MyClass
      {
              public static void main(String args[])
              {
                      int i = MyOtherClass.s1;
                      MyOtherClass.s1 = 300;
                      MyOtherClass.s2 = MyOtherClass.foo();
              }
      }

      MyOtherClass.java
      --------------
      public class MyOtherClass
      {
              public static int s1 = 100;
              public static int s2 = foo();

              static int foo()
              {
                      return 500;
              }
      }

      C:\TEMP>jdb MyClass
      Initializing jdb...
      Warning: JIT compiler "symcjit" not found. Will use interpreter.
      0xf981f0:class(MyClass)
      > stop in MyClass.main
      Breakpoint set in MyClass.main
      > run
      run MyClass
      running ...
      main[1]
      Breakpoint hit: MyClass.main (MyClass:5)
      main[1] list
      1 public class MyClass
      2 {
      3 public static void main(String args[])
      4 {
      5 => int i = MyOtherClass.s1;
      6 MyOtherClass.s1 = 300;
      7 MyOtherClass.s2 = MyOtherClass.foo();
      8 }
      9 }
      main[1] step
      main[1]
      Breakpoint hit: MyOtherClass.<clinit> (MyOtherClass:3)
      main[1] next
      main[1]
      Breakpoint hit: MyOtherClass.<clinit> (MyOtherClass:3)
      main[1] next
      main[1]
      Breakpoint hit: MyOtherClass.<clinit> (MyOtherClass:3)
      main[1] next
      main[1]
      Breakpoint hit: MyOtherClass.<clinit> (MyOtherClass:4)
      main[1] next

      Breakpoint hit: MyOtherClass.<clinit> (MyOtherClass:4)
      main[1] main[1] next
      main[1]
      Breakpoint hit: MyOtherClass.foo (MyOtherClass:8)
      main[1] next
      main[1]
      Breakpoint hit: MyOtherClass.<clinit> (MyOtherClass:4)
      main[1] next
      main[1]
      Breakpoint hit: MyOtherClass.<clinit> (MyOtherClass:4)
      main[1] next
      main[1]
      Breakpoint hit: MyOtherClass.<clinit> (MyOtherClass:1)
      main[1] next

      Breakpoint hit: MyClass.main (MyClass:5)
      main[1] main[1] next
      main[1]
      Breakpoint hit: MyClass.main (MyClass:6)
      main[1] next
      main[1]
      Breakpoint hit: MyClass.main (MyClass:7)
      main[1] next
      main[1]
      Breakpoint hit: MyClass.main (MyClass:3)
      main[1]


      (Review ID: 33675)
      ======================================================================

            Unassigned Unassigned
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: