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

Incorrect stepping after redefine

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 14
    • Fix Version/s: tbd
    • Component/s: core-svc
    • Labels:
      None

      Description

      Consider this sample code:
      public class HotswapJdkBug {
          static void x() {
              //System.out.println(2);
              int y = 3; // line 4, set breakpoint here
              int z = 4;
          }
          public static void main(String[] args) {
              x();
              x();
              System.out.println("Hey!!");
          }
      }

      Steps to reproduce:
      - set a breakpoint on line 4
      - step over
      - uncomment line 3, recompile and redefine the class
      - reset breakpoint on the line 4
      - resume to stop in the next (not obsolete) x invocation
      - do step over

      Here debugger does not stop on the line 5 as expected.

      jdb console to reproduce:
      >jdb HotswapJdkBug
      Initializing jdb ...
      > stop at HotswapJdkBug:4
      Deferring breakpoint HotswapJdkBug:4.
      It will be set after the class is loaded.
      > run
      run HotswapJdkBug
      Set uncaught java.lang.Throwable
      Set deferred uncaught java.lang.Throwable
      >
      VM Started: Set deferred breakpoint HotswapJdkBug:4

      Breakpoint hit: "thread=main", HotswapJdkBug.x(), line=4 bci=0

      main[1] next
      >
      Step completed: "thread=main", HotswapJdkBug.x(), line=5 bci=2

      main[1] redefine HotswapJdkBug HotswapJdkBug.class
      main[1] stop at HotswapJdkBug:4
      Set breakpoint HotswapJdkBug:4
      main[1] cont
      > 2

      Breakpoint hit: "thread=main", HotswapJdkBug.x(), line=4 bci=7

      main[1] next
      >
      Step completed: "thread=main", HotswapJdkBug.main(), line=10 bci=6

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              eushakov Egor Ushakov
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: