1 /*
2  * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.
8  *
9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 /*
25  * @test
26  * @bug 4762765
27  * @summary REGRESSION: jdb / jdi not stopping at some breakpoints and steps in j2sdk1.4.
28  * @comment converted from test/jdk/com/sun/jdi/JdbMissStep.sh
29  *
30  * @library /test/lib
31  * @compile -g JdbMissStep.java
32  * @run main/othervm JdbMissStep
33  */
34 
35 import jdk.test.lib.process.OutputAnalyzer;
36 import lib.jdb.JdbCommand;
37 import lib.jdb.JdbTest;
38 
39 class JdbMissStepTarg {
40 
main(String args[])41     public static void main(String args[]) {
42         JdbMissStepTarg dbb = new JdbMissStepTarg();
43         System.out.println("ANSWER IS: " + dbb.getIntVal());
44         jj2 gus = new jj2();
45         System.out.println("ANSWER2 IS: " + gus.getIntVal());
46     }
47 
48     static int statVal;
49     int intVal = 89;
getIntVal()50     public int getIntVal() {
51         return intVal;  //@ 1 breakpoint
52     }
53 
54     static class jj2 {
55         static int statVal;
56         int intVal = 89;
getIntVal()57         public int getIntVal() {
58             return intVal;  //@1 breakpoint  line 20
59         }
60     }
61 }
62 
63 public class JdbMissStep extends JdbTest {
main(String argv[])64     public static void main(String argv[]) {
65         new JdbMissStep().run();
66     }
67 
JdbMissStep()68     private JdbMissStep() {
69         super(DEBUGGEE_CLASS);
70     }
71 
72     private static final String DEBUGGEE_CLASS = JdbMissStepTarg.class.getName();
73 
74     @Override
runCases()75     protected void runCases() {
76         setBreakpoints(jdb, DEBUGGEE_CLASS + "$jj2", System.getProperty("test.src") + "/JdbMissStep.java", 1);
77 
78         jdb.command(JdbCommand.run());
79         jdb.command(JdbCommand.step());
80 
81         new OutputAnalyzer(jdb.getJdbOutput())
82                 .shouldContain("Breakpoint hit");
83     }
84 }
85