changeset 16943:eadd7f013eb9

8177507: line number sensitive tests for jdi should be unified Reviewed-by: dholmes, mseledtsov, sspitsyn
author iignatyev
date Mon, 03 Apr 2017 17:07:27 -0700
parents e9325773dd96
children d584006ddd5d
files test/com/sun/jdi/ArgumentValuesTest.java test/com/sun/jdi/BreakpointTest.java test/com/sun/jdi/FetchLocals.java test/com/sun/jdi/GetLocalVariables.java test/com/sun/jdi/GetSetLocalTest.java test/com/sun/jdi/LambdaBreakpointTest.java test/com/sun/jdi/LineNumberOnBraceTest.java test/com/sun/jdi/PopAndStepTest.java
diffstat 8 files changed, 314 insertions(+), 144 deletions(-) [+]
line wrap: on
line diff
--- a/test/com/sun/jdi/ArgumentValuesTest.java	Mon Apr 03 16:40:49 2017 -0700
+++ b/test/com/sun/jdi/ArgumentValuesTest.java	Mon Apr 03 17:07:27 2017 -0700
@@ -1,13 +1,38 @@
-/** hard coded linenumbers in other tests - DO NOT CHANGE
- *  @test/nodynamiccopyright/
- *  @bug 4490824
- *  @summary JDI: provide arguments when no debug attributes present
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- *  @author jjh
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//    THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4490824
+ * @summary JDI: provide arguments when no debug attributes present
  *
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile ArgumentValuesTest.java
- *  @run driver ArgumentValuesTest
+ * @author jjh
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile ArgumentValuesTest.java
+ * @run driver ArgumentValuesTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
@@ -35,26 +60,26 @@
     static List<Integer> intList;
 
     public static void noArgs() {
-        int index = 0;     // line 38
+        int index = 0;     // line NO_ARGS_LINE_1
     }
 
     public static void allArgs(char p_char, byte p_byte, short p_short,
                                int p_int, long p_long, float p_float,
                                double p_double, int p_iarray[], int p_marray[][],
                                String p_sarray1[], String p_string) {
-        int index = 0;      // line 45
+        int index = 0;      // line ALL_ARGS_LINE_1
     }
 
     public static void varArgs(String ... p1) {
-        int index = 0;     // line 49
+        int index = 0;     // line VAR_ARGS_LINE_1
     }
 
     public static void genericArgs(List<Integer> p1) {
-        int index = 0;     // line 53
+        int index = 0;     // line GENERIC_ARGS_LINE_1
     }
 
     public void instanceMethod(char p_char, byte p_byte) {
-        int index = 0;     // line 57
+        int index = 0;     // line INSTANCE_METHOD_LINE_1
     }
 
     public static void main(String[] args) {
@@ -81,6 +106,12 @@
  /********** test program **********/
 
 public class ArgumentValuesTest extends TestScaffold {
+    static final int NO_ARGS_LINE_1 = 63;
+    static final int ALL_ARGS_LINE_1 = 70;
+    static final int VAR_ARGS_LINE_1 = 74;
+    static final int GENERIC_ARGS_LINE_1 = 78;
+    static final int INSTANCE_METHOD_LINE_1 = 82;
+
     // Must be in same order as args to allArgs(....)
     String fieldNames[] = {"s_char1",   "s_byte1",   "s_short1",  "s_int1",
                            "s_long1",   "s_float1",  "s_double1", "s_iarray1",
@@ -118,7 +149,7 @@
 
         {
             System.out.println("----- Testing each type of arg");
-            bpe = resumeTo("ArgumentValuesTarg", 45);
+            bpe = resumeTo("ArgumentValuesTarg", ALL_ARGS_LINE_1);
             StackFrame frame = bpe.thread().frame(0);
 
             Method mmm = frame.location().method();
@@ -147,7 +178,7 @@
         // a method with no params
         {
             System.out.println("----- Testing no args");
-            bpe = resumeTo("ArgumentValuesTarg", 38);
+            bpe = resumeTo("ArgumentValuesTarg", NO_ARGS_LINE_1);
             StackFrame frame = bpe.thread().frame(0);
 
             Method mmm = frame.location().method();
@@ -165,7 +196,7 @@
         // as a String[3] in the method.
         {
             System.out.println("----- Testing var args");
-            bpe = resumeTo("ArgumentValuesTarg", 49);
+            bpe = resumeTo("ArgumentValuesTarg", VAR_ARGS_LINE_1);
             StackFrame frame = bpe.thread().frame(0);
 
             Method mmm = frame.location().method();
@@ -199,7 +230,7 @@
         // a method with with one generic param
         {
             System.out.println("----- Testing generic args");
-            bpe = resumeTo("ArgumentValuesTarg", 53);
+            bpe = resumeTo("ArgumentValuesTarg", GENERIC_ARGS_LINE_1);
             StackFrame frame = bpe.thread().frame(0);
 
             Method mmm = frame.location().method();
@@ -224,7 +255,7 @@
         // test instance method call
         {
             System.out.println("----- Testing instance method call");
-            bpe = resumeTo("ArgumentValuesTarg", 57);
+            bpe = resumeTo("ArgumentValuesTarg", INSTANCE_METHOD_LINE_1);
             StackFrame frame = bpe.thread().frame(0);
 
             Method mmm = frame.location().method();
--- a/test/com/sun/jdi/BreakpointTest.java	Mon Apr 03 16:40:49 2017 -0700
+++ b/test/com/sun/jdi/BreakpointTest.java	Mon Apr 03 17:07:27 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,19 +21,20 @@
  * questions.
  */
 
+//    THIS TEST IS LINE NUMBER SENSITIVE
+
 /**
- *  @test
- *  @bug 6496524
- *  @summary Setting breakpoint in jdb crashes Hotspot JVM
- *
- *  @author jjh
+ * @test
+ * @bug 6496524
+ * @key intermittent
+ * @summary Setting breakpoint in jdb crashes Hotspot JVM
+ * @author jjh
  *
- *  @key intermittent
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g BreakpointTest.java
- *  @run driver BreakpointTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g BreakpointTest.java
+ * @run driver BreakpointTest
  */
+
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
 import com.sun.jdi.request.*;
@@ -47,7 +48,6 @@
 
 class BreakpointTarg {
     public final static int BKPT_LINE = 56;
-            // LINE NUMBER SENSITIVE
 
     public static long count;
     static void doit() {
--- a/test/com/sun/jdi/FetchLocals.java	Mon Apr 03 16:40:49 2017 -0700
+++ b/test/com/sun/jdi/FetchLocals.java	Mon Apr 03 17:07:27 2017 -0700
@@ -1,13 +1,37 @@
-/** hard coded linenumbers in test - DO NOT CHANGE
- *  @test/nodynamiccopyright/
- *  @bug 4386002 4429245
- *  @summary Test fix for: Incorrect values reported for some locals of type long
+/*
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
  *
- *  @author Tim Bell
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g FetchLocals.java
- *  @run driver FetchLocals
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//    THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4386002 4429245
+ * @summary Test fix for: Incorrect values reported for some locals of type long
+ * @author Tim Bell
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g FetchLocals.java
+ * @run driver FetchLocals
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
@@ -59,7 +83,7 @@
         System.out.println(f);
         System.out.print("d is: ");
         System.out.println(d);
-        System.out.println();   // Thie is Line 63...
+        System.out.println();   // This is FetchLocals::LINE
         if (w == 0xde00ad00be00ef00L) {
           System.out.print  ("The debugger was here.  w modified to: 0x");
           System.out.println(Long.toHexString(w));
@@ -87,6 +111,7 @@
 }
 
 public class FetchLocals extends TestScaffold {
+    static final int LINE = 86;
 
     FetchLocals (String args[]) {
         super(args);
@@ -355,7 +380,7 @@
          * Get to the bottom of testMethod():
          */
         try {
-            BreakpointEvent bpe = resumeTo("FetchLocalsDebugee", 63);
+            BreakpointEvent bpe = resumeTo("FetchLocalsDebugee", LINE);
             /*
              * Fetch values from fields; what did we get?
              */
--- a/test/com/sun/jdi/GetLocalVariables.java	Mon Apr 03 16:40:49 2017 -0700
+++ b/test/com/sun/jdi/GetLocalVariables.java	Mon Apr 03 17:07:27 2017 -0700
@@ -1,14 +1,39 @@
-/** hard coded linenumbers in this test - DO NOT CHANGE
- *  @test/nodynamiccopyright/
- *  @bug 4359312 4450091
- *  @summary Test PTR 1421 JVM exceptions making a call to LocalVariable.type().name()
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- *  @author Tim Bell (based on the PTR 1421 report submitted by IBM).
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//    THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4359312 4450091
+ * @summary Test PTR 1421 JVM exceptions making a call to LocalVariable.type().name()
+ * @author Tim Bell (based on the PTR 1421 report submitted by IBM).
  *
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g GetLocalVariables.java
- *  @run driver GetLocalVariables
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g GetLocalVariables.java
+ * @run driver GetLocalVariables
  */
+
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
 import com.sun.jdi.request.*;
@@ -194,7 +219,7 @@
                                      l_long, l_float, l_double, l_iarray,
                                      l_marray, l_string);
 
-        e1.test_1();            // <-- this is line 197
+        e1.test_1();            // RESUME_TO_LINE
         e3.test_1();
         e4.test_1();
         e5.test_1();
@@ -231,6 +256,7 @@
  /********** test program **********/
 
 public class GetLocalVariables extends TestScaffold {
+    static final int RESUME_TO_LINE = 222;
     ReferenceType targetClass;
     ThreadReference mainThread;
 
@@ -257,7 +283,7 @@
         mainThread = bpe.thread();
         EventRequestManager erm = vm().eventRequestManager();
 
-        bpe = resumeTo("GetLocalVariablesTarg", 197);
+        bpe = resumeTo("GetLocalVariablesTarg", RESUME_TO_LINE);
         /*
          * We've arrived.  Look around at some variables.
          */
--- a/test/com/sun/jdi/GetSetLocalTest.java	Mon Apr 03 16:40:49 2017 -0700
+++ b/test/com/sun/jdi/GetSetLocalTest.java	Mon Apr 03 17:07:27 2017 -0700
@@ -1,13 +1,37 @@
-/** hard coded linenumbers in other tests - DO NOT CHANGE
- *  @test/nodynamiccopyright/
- *  @bug 4300412
- *  @summary Test GetLocal* and SetLocal* functions
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
  *
- *  @author Serguei Spitsyn
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g GetSetLocalTest.java
- *  @run driver GetSetLocalTest
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//    THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4300412
+ * @summary Test GetLocal* and SetLocal* functions
+ * @author Serguei Spitsyn
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g GetSetLocalTest.java
+ * @run driver GetSetLocalTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
@@ -35,7 +59,7 @@
         int result;
         {
              { boolean bool_1 = false;
-               intArg++;
+               intArg++; // START_LINE
              }
 
              boolean bool_2 = true;
@@ -111,7 +135,7 @@
              }
 
              Object obj_2 = new Object();
-             intArg++;  // <-- Last stop is at this point.
+             intArg++;  // STOP_LINE. Last stop is at this point.
                         //     Only obj_2 and intArg are valid
                         // Note: even result is not valid here!
         }
@@ -125,6 +149,8 @@
     /********** test program **********/
 
 public class GetSetLocalTest extends TestScaffold {
+    static final int START_LINE = 62;
+    static final int STOP_LINE = 138;
     ReferenceType targetClass;
     ThreadReference mainThread;
 
@@ -635,7 +661,7 @@
         println("EventRequestManager");
         StackFrame frame = null;
 
-        for (int line = 38; line < 118; line += 4) {
+        for (int line = START_LINE; line <= STOP_LINE; line += 4) {
             println("\n resumeTo(GetSetLocalTarg, " + line + ")");
             bpe = resumeTo("GetSetLocalTarg", line);
             frame = bpe.thread().frame(0);
--- a/test/com/sun/jdi/LambdaBreakpointTest.java	Mon Apr 03 16:40:49 2017 -0700
+++ b/test/com/sun/jdi/LambdaBreakpointTest.java	Mon Apr 03 17:07:27 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,19 +21,18 @@
  * questions.
  */
 
-/********** LINE NUMBER SENSITIVE! *****************************************************************/
+//    THIS TEST IS LINE NUMBER SENSITIVE
 
 /**
- *  @test
- *  @summary Test setting breakpoints on lambda calls
- *
- *  @author Staffan Larsen
+ * @test
+ * @summary Test setting breakpoints on lambda calls
+ * @author Staffan Larsen
  *
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g LambdaBreakpointTest.java
- *  @run driver LambdaBreakpointTest
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g LambdaBreakpointTest.java
+ * @run driver LambdaBreakpointTest
  */
+
 import java.util.List;
 
 import com.sun.jdi.LocalVariable;
@@ -50,22 +49,17 @@
  /********** target program **********/
 
 class LambdaBreakpointTestTarg {
-
-    static int[] breakpointLines = {
-            63, 67, 64, 65, 66, 68
-    };
-
     public static void main(String[] args) {
         test();
     }
 
     private static void test() {
-        Runnable r = () -> {                          // B1: L62
-            String from = "lambda";                   // B3: L63
-            System.out.println("Hello from " + from); // B4: L64
-        };                                            // B5: L65
-        r.run();                                      // B2: L66
-        System.out.println("Goodbye.");               // B6: L67
+        Runnable r = () -> {                          // LambdaBreakpointTest::TEST_LINE_1, BKPT_LINES[0]
+            String from = "lambda";                   // LambdaBreakpointTest::TEST_LINE_2, BKPT_LINES[2]
+            System.out.println("Hello from " + from); // LambdaBreakpointTest::TEST_LINE_3, BKPT_LINES[3]
+        };                                            // LambdaBreakpointTest::TEST_LINE_4, BKPT_LINES[4]
+        r.run();                                      // LambdaBreakpointTest::TEST_LINE_5, BKPT_LINES[1]
+        System.out.println("Goodbye.");               // LambdaBreakpointTest::TEST_LINE_6, BKPT_LINES[5]
     }
 }
 
@@ -73,6 +67,21 @@
  /********** test program **********/
 
 public class LambdaBreakpointTest extends TestScaffold {
+    private static final int TEST_LINE_1 = 57;
+    private static final int TEST_LINE_2 = TEST_LINE_1 + 1;
+    private static final int TEST_LINE_3 = TEST_LINE_1 + 2;
+    private static final int TEST_LINE_4 = TEST_LINE_1 + 3;
+    private static final int TEST_LINE_5 = TEST_LINE_1 + 4;
+    private static final int TEST_LINE_6 = TEST_LINE_1 + 5;
+
+    private static final int[] BKPT_LINES = {
+        TEST_LINE_1,
+        TEST_LINE_5,
+        TEST_LINE_2,
+        TEST_LINE_3,
+        TEST_LINE_4,
+        TEST_LINE_6,
+    };
 
     LambdaBreakpointTest (String args[]) {
         super(args);
@@ -92,7 +101,7 @@
         startToMain("LambdaBreakpointTestTarg");
 
         // Put a breakpoint on each location in the order they should happen
-        for (int line : LambdaBreakpointTestTarg.breakpointLines) {
+        for (int line : BKPT_LINES) {
             System.out.println("Running to line: " + line);
             BreakpointEvent be = resumeTo("LambdaBreakpointTestTarg", line);
             int stoppedAt = be.location().lineNumber();
--- a/test/com/sun/jdi/LineNumberOnBraceTest.java	Mon Apr 03 16:40:49 2017 -0700
+++ b/test/com/sun/jdi/LineNumberOnBraceTest.java	Mon Apr 03 17:07:27 2017 -0700
@@ -1,13 +1,37 @@
-/**
- *  @test/nodynamiccopyright/
- *  @bug 4952629 4870514
- *  @summary REGRESSION: javac generates a spurious line number entry on } else {
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
  *
- *  @author jjh
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- *  @run build VMConnection TargetListener TargetAdapter
- *  @run compile -g LineNumberOnBraceTest.java
- *  @run driver LineNumberOnBraceTest
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//    THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4952629 4870514
+ * @summary REGRESSION: javac generates a spurious line number entry on } else {
+ * @author jjh
+ *
+ * @run build VMConnection TargetListener TargetAdapter
+ * @run compile -g LineNumberOnBraceTest.java
+ * @run driver LineNumberOnBraceTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
@@ -15,29 +39,27 @@
 
 import java.util.*;
 
-    /********** LINE NUMBER SENSITIVE! *****************************************************************/
 class LineNumberOnBraceTarg {
 
-    public final static int stopLine = 29;   // THIS MUST BE THE LINE NUMBER OF THE // stopline LINE
-    public final static int stopLine2 = 35;  // THIS MUST BE THE LINE NUMBER OF THE // stopline2 LINE
-
+    public final static int STOP_LINE = 50;    // THIS MUST BE THE LINE NUMBER OF // STOP_LINE LINE
+    public final static int STOP_LINE_2 = 56;  // THIS MUST BE THE LINE NUMBER OF // STOP_LINE_2 LINE
 
     public static void main(String[] args){
         System.out.println("Howdy!");
         if (args.length == 0) {
-            System.out.println("No args to debuggee");             // stopLine
+            System.out.println("No args to debuggee");             // STOP_LINE
         } else {
             System.out.println("Some args to debuggee");
         }
-        if (args.length == 0) {
+        if (args.length == 0) {                                    // STOP_LINE + 4
             boolean b1 = false;
-            if (b1) {                                              // stopLine2
+            if (b1) {                                              // STOP_LINE_2
                 System.out.println("In 2nd else");                 // bug 4870514 is that we stop here.
             }
         } else {
             System.out.println("In 2nd else");
         }
-        System.out.println("Goodbye from LineNumberOnBraceTarg!");  // stopLine2 + 6
+        System.out.println("Goodbye from LineNumberOnBraceTarg!");
     }
 
     // This isn't part of the test; it is just here
@@ -78,7 +100,7 @@
         targetClass = bpe.location().declaringType();
         mainThread = bpe.thread();
 
-        resumeTo("LineNumberOnBraceTarg", LineNumberOnBraceTarg.stopLine);
+        resumeTo("LineNumberOnBraceTarg", LineNumberOnBraceTarg.STOP_LINE);
         StepEvent stepev = stepOverLine(mainThread);       // step to 2nd if (args.length
 
         // Bug 4952629 is that javac outputs a line number
@@ -87,24 +109,23 @@
 
         int ln = stepev.location().lineNumber();
         System.out.println("Debuggee is stopped at line " + ln);
-        if (ln != LineNumberOnBraceTarg.stopLine + 4) {
+        if (ln != LineNumberOnBraceTarg.STOP_LINE + 4) {
             failure("FAIL: Bug 4952629: Should be at line " +
-                    (LineNumberOnBraceTarg.stopLine + 4) +
+                    (LineNumberOnBraceTarg.STOP_LINE + 4) +
                     ", am at " + ln);
         } else {
             System.out.println("Passed test for 4952629");
         }
 
         // Test for bug 4870514
-        System.out.println("Resuming to " + LineNumberOnBraceTarg.stopLine2);
-        resumeTo("LineNumberOnBraceTarg", LineNumberOnBraceTarg.stopLine2);
-        System.out.println("Stopped at " + LineNumberOnBraceTarg.stopLine2);
+        System.out.println("Resuming to " + LineNumberOnBraceTarg.STOP_LINE_2);
+        resumeTo("LineNumberOnBraceTarg", LineNumberOnBraceTarg.STOP_LINE_2);
+        System.out.println("Stopped at " + LineNumberOnBraceTarg.STOP_LINE_2);
         stepev = stepOverLine(mainThread);
         ln = stepev.location().lineNumber();
         System.out.println("Debuggee is stopped at line " + ln);
-        if (ln == LineNumberOnBraceTarg.stopLine2 + 1) {
-            failure("FAIL: bug 4870514: Incorrectly stopped at " +
-                    (LineNumberOnBraceTarg.stopLine2 + 1));
+        if (ln <= LineNumberOnBraceTarg.STOP_LINE_2 + 1) {
+            failure("FAIL: bug 4870514: Incorrectly stopped at " + ln);
         } else {
             System.out.println("Passed test for 4870514");
         }
--- a/test/com/sun/jdi/PopAndStepTest.java	Mon Apr 03 16:40:49 2017 -0700
+++ b/test/com/sun/jdi/PopAndStepTest.java	Mon Apr 03 17:07:27 2017 -0700
@@ -1,17 +1,39 @@
-/* /nodynamiccopyright/ */  // DO NOT DELETE ANY LINES!!!!
-//    THIS TEST IS LINE NUMBER SENSITIVE
-/**
- *  @test
- *  @bug 4530424
- *  @summary Hin says that doing a step over after a popframe acts like a resume.
+/*
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- *  @author jjh
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//    THIS TEST IS LINE NUMBER SENSITIVE
+
+/**
+ * @test
+ * @bug 4530424
+ * @summary Hin says that doing a step over after a popframe acts like a resume.
+ * @author jjh
  *
- *  @library ..
- *  @modules jdk.jdi
- *  @run build TestScaffold VMConnection TargetListener TargetAdapter
- *  @run compile -g PopAndStepTest.java
- *  @run driver PopAndStepTest
+ * @library ..
+ *
+ * @run build TestScaffold VMConnection TargetListener TargetAdapter
+ * @run compile -g PopAndStepTest.java
+ * @run driver PopAndStepTest
  */
 import com.sun.jdi.*;
 import com.sun.jdi.event.*;
@@ -19,25 +41,23 @@
 
 import java.util.*;
 
-    /********** LINE NUMBER SENSITIVE! *****************************************************************/
-
 class PopAndStepTarg {
     public void B() {
-        System.out.println("debuggee: in B");
-        System.out.println("debuggee: in B, back to A");   // add line breakpoint here line 27 !!!
+        System.out.println("debuggee: in B");             // B_LINE_1
+        System.out.println("debuggee: in B, back to A");  // B_LINE_2
     }
 
     public void A() {
-        System.out.println("debuggee: in A, about to call B");  // line 31
-        B();
-        System.out.println("debuggee: in A, back from B");      // line 33
-        throw new RuntimeException("debuggee: Got to line 34");
+        System.out.println("debuggee: in A, about to call B");  // A_LINE_1
+        B();                                                    // A_LINE_2
+        System.out.println("debuggee: in A, back from B");      // A_LINE_3
+        throw new RuntimeException("debuggee: Got to line A_LINE_4:" + PopAndStepTest.A_LINE_4); // A_LINE_4
     }
 
     public static void main(String[] args) {
-        System.out.println("debuggee: Howdy!");      // line 38
-        PopAndStepTarg xxx = new PopAndStepTarg();   // line 40
-        xxx.A();                                     // line 41
+        System.out.println("debuggee: Howdy!");      // MAIN_LINE_1
+        PopAndStepTarg xxx = new PopAndStepTarg();   // MAIN_LINE_2
+        xxx.A();                                     // MAIN_LINE_3
         System.out.println("debugee: Goodbye from PopAndStepTarg!");
     }
 }
@@ -46,6 +66,18 @@
     /********** test program **********/
 
 public class PopAndStepTest extends TestScaffold {
+    static final int B_LINE_1 = 46;
+    static final int B_LINE_2 = B_LINE_1 + 1;
+
+    static final int A_LINE_1 = 51;
+    static final int A_LINE_2 = A_LINE_1 + 1;
+    static final int A_LINE_3 = A_LINE_1 + 2;
+    static final int A_LINE_4 = A_LINE_1 + 3;
+
+    static final int MAIN_LINE_1 = 58;
+    static final int MAIN_LINE_2 = MAIN_LINE_1 + 1;
+    static final int MAIN_LINE_3 = MAIN_LINE_1 + 2;
+
     ReferenceType targetClass;
     ThreadReference mainThread;
 
@@ -116,10 +148,10 @@
         BreakpointEvent bpe = startToMain("PopAndStepTarg");
         targetClass = bpe.location().declaringType();
         mainThread = bpe.thread();
-        getDebuggeeLineNum(38);
+        getDebuggeeLineNum(MAIN_LINE_1);
 
-        println("Resuming to line 27");
-        bpe = resumeTo("PopAndStepTarg", 27); getDebuggeeLineNum(27);
+        println("Resuming to line B_LINE_2 : " + B_LINE_2);
+        bpe = resumeTo("PopAndStepTarg", B_LINE_2); getDebuggeeLineNum(B_LINE_2);
 
         // The failure is this:
         //   create step request
@@ -141,21 +173,21 @@
         srInto.enable(); // This fails
         mainThread.popFrames(frameFor("A"));
         //srInto.enable();   // if the enable is moved here, it passes
-        println("Popped back to line 41 in main, the call to A()");
-        println("Stepping into line 31");
-        waitForRequestedEvent(srInto);   // println
+        println("Popped back to line MAIN_LINE_3(" + MAIN_LINE_3 + ") in main, the call to A()");
+        println("Stepping into line A_LINE_1:" + A_LINE_1);
+        waitForRequestedEvent(srInto);  // println
         srInto.disable();
 
-        getDebuggeeLineNum(31);
+        getDebuggeeLineNum(A_LINE_1);
 
         // The failure occurs here.
-        println("Stepping over to line 32");
-        stepOverLine(mainThread);   // println
-        getDebuggeeLineNum(32);
+        println("Stepping over to line A_LINE_2:" + A_LINE_2);
+        stepOverLine(mainThread);       // println
+        getDebuggeeLineNum(A_LINE_2);
 
-        println("Stepping over to line 33");
-        stepOverLine(mainThread);        // call to B()
-        getDebuggeeLineNum(33);
+        println("Stepping over to line A_LINE_3:" + A_LINE_3);
+        stepOverLine(mainThread);       // call to B()
+        getDebuggeeLineNum(A_LINE_3);
 
         vm().exit(0);