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

Breakpoint in parallel code does not work

XMLWordPrintable

    • 20
    • b04

        Steps to reproduce:
        - use the code:
        class A {
            static void foo(int k) {
                if (k == 2) {
                    System.out.println("HIT = " + k); // set breakpoint here
                }
            }
        }


        public class HelloWorld {
            public static void main(String[] args) throws InterruptedException {
                System.out.println("Start");
                for (int i = 1; i <= 100; i++) {
                    int k = i;
                    Thread t = new Thread(() -> {
                        System.out.println("i = " + k);
                        A.foo(k);
                    });
                    t.start();
                }

                Thread.sleep(2000);

                System.out.println("Finish");
            }
        }
        - compile
        - use jdb to set a breakpoint and run:
        >jdb HelloWorld
        Initializing jdb ...
        > stop at A:4
        Deferring breakpoint A:4.
        It will be set after the class is loaded.
        > run
        run HelloWorld
        Set uncaught java.lang.Throwable
        Set deferred uncaught java.lang.Throwable
        >
        VM Started: Start
        i = 21
        i = 45
        i = 11
        i = 16
        i = 23
        i = 7
        i = 51
        i = 39
        i = 20
        i = 40
        i = 31
        i = 5
        i = 6
        i = 4
        i = 41
        i = 53
        i = 9
        i = 2
        i = 13
        i = 1
        i = 3
        i = 15
        i = 22
        HIT = 2
        i = 10
        i = 8
        i = 14
        i = 12
        i = 17
        i = 52
        i = 19
        i = 24
        i = 44
        i = 18
        i = 55
        i = 25
        i = 56
        i = 26
        i = 34
        i = 43
        i = 37
        i = 33
        i = 28
        i = 30
        i = 32
        i = 35
        i = 38
        i = 27
        i = 47
        i = 49
        i = 59
        i = 60
        i = 48
        i = 62
        i = 54
        i = 58
        i = 64
        i = 67
        i = 68
        i = 70
        i = 73
        i = 69
        i = 29
        i = 75
        i = 77
        i = 76
        i = 74
        i = 84
        i = 81
        i = 80
        i = 85
        i = 36
        i = 86
        i = 87
        i = 91
        i = 93
        i = 92
        i = 95
        i = 99
        i = 90
        i = 96
        Set deferred breakpoint A:4
        i = 46
        i = 61
        i = 42
        i = 50
        i = 57
        i = 63
        i = 65
        i = 66
        i = 71
        i = 72
        i = 79
        i = 78
        i = 83
        i = 82
        i = 88
        i = 89
        i = 94
        i = 98
        i = 97
        i = 100
        Finish

        The application exited

        The breakpoint is fully skipped.
        This was working in version before 20.

              coleenp Coleen Phillimore
              eushakov Egor Ushakov
              Votes:
              1 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: