< prev index next >

test/com/sun/jdi/GetLocalVariables.java

Print this page
rev 16922 : 8177507: line number sensitive tests for jdi should be unified
Reviewed-by: duke
   1 /** hard coded linenumbers in this test - DO NOT CHANGE
   2  *  @test/nodynamiccopyright/

























   3  *  @bug 4359312 4450091
   4  *  @summary Test PTR 1421 JVM exceptions making a call to LocalVariable.type().name()
   5  *
   6  *  @author Tim Bell (based on the PTR 1421 report submitted by IBM).
   7  *
   8  *  @run build TestScaffold VMConnection TargetListener TargetAdapter
   9  *  @run compile -g GetLocalVariables.java
  10  *  @run driver GetLocalVariables
  11  */

  12 import com.sun.jdi.*;
  13 import com.sun.jdi.event.*;
  14 import com.sun.jdi.request.*;
  15 
  16 import java.util.*;
  17 
  18  /********** target program **********/
  19 
  20 class GetLocalVariablesTarg {
  21     private static char s_char1 = 'a';
  22     private static char s_char2 = (char) 0;
  23     private static char s_char3 = (char) 1;
  24     private static char s_char4 = (char) 32;
  25     private static char s_char5 = '\u7ffe';
  26     private static char s_char6 = '\u7fff';
  27     private static char s_char7 = '\u8000';
  28     private static char s_char8 = '\u8001';
  29     private static char s_char9 = '\ufffe';
  30     private static char s_char10 = '\uffff';
  31 


 177         int l_int = s_int1 + s_int2 + s_int3 + s_int4 + s_int5 +
 178         s_int6 + s_int7 + s_int8 + s_int9 + s_int10;
 179         long l_long = s_long1 + s_long2 + s_long3 + s_long4 + s_long5 +
 180         s_long6 + s_long7 + s_long8 + s_long9 + s_long10;
 181         float l_float = s_float1 + s_float2;
 182         double l_double = s_double1 + s_double2;
 183         int[] l_iarray = null;
 184         int[][] l_marray = null;
 185         String l_string = s_string1 + s_string3 + s_sarray1[0];
 186 
 187         if (s_sarray2 == null)
 188             l_string += "?";
 189 
 190         if (s_sarray3 instanceof String[])
 191             l_string += "<io>";
 192 
 193         Object e6 = new GetLocalVariablesTarg(l_char, l_byte, l_short, l_int,
 194                                      l_long, l_float, l_double, l_iarray,
 195                                      l_marray, l_string);
 196 
 197         e1.test_1();            // <-- this is line 197
 198         e3.test_1();
 199         e4.test_1();
 200         e5.test_1();
 201         ((GetLocalVariablesTarg) e6).test_1();
 202 
 203         e3 = null;
 204         if (e3 == e1)
 205             e3.test_1();
 206         e3 = e4;
 207         if (e3 == e2)
 208             e3 = e5;
 209         e3.test_1();
 210 
 211     }
 212 
 213     public void test_1()
 214     {
 215         double l_add = i_double + i_short;
 216         long l_subtract = i_long - i_int;
 217         long l_multiply = i_byte * i_int;
 218 
 219         i_double = l_add + i_float;
 220         i_short = (short) l_subtract;
 221         i_long = l_multiply + i_byte + i_short;
 222     }
 223 
 224     public static void main(String[] args) {
 225         System.out.println("Howdy!");
 226         test_expressions();
 227         System.out.println("Goodbye from GetLocalVariablesTarg!");
 228     }
 229 }
 230 
 231  /********** test program **********/
 232 
 233 public class GetLocalVariables extends TestScaffold {

 234     ReferenceType targetClass;
 235     ThreadReference mainThread;
 236 
 237     GetLocalVariables (String args[]) {
 238         super(args);
 239     }
 240 
 241     public static void main(String[] args)
 242         throws Exception
 243     {
 244         new GetLocalVariables (args).startTests();
 245     }
 246 
 247     /********** test core **********/
 248 
 249     protected void runTests()
 250         throws Exception
 251     {
 252         /*
 253          * Get to the top of main() to determine targetClass and mainThread
 254          */
 255         BreakpointEvent bpe = startToMain("GetLocalVariablesTarg");
 256         targetClass = bpe.location().declaringType();
 257         mainThread = bpe.thread();
 258         EventRequestManager erm = vm().eventRequestManager();
 259 
 260         bpe = resumeTo("GetLocalVariablesTarg", 197);
 261         /*
 262          * We've arrived.  Look around at some variables.
 263          */
 264         StackFrame frame = bpe.thread().frame(0);
 265         List localVars = frame.visibleVariables();
 266         System.out.println("    Visible variables at this point are: ");
 267         for (Iterator it = localVars.iterator(); it.hasNext();) {
 268             LocalVariable lv = (LocalVariable) it.next();
 269             System.out.print(lv.name());
 270             System.out.print(" typeName: ");
 271             System.out.print(lv.typeName());
 272             System.out.print(" signature: ");
 273             System.out.print(lv.type().signature());
 274             System.out.print(" primitive type: ");
 275             System.out.println(lv.type().name());
 276         }
 277 
 278         /*
 279          * resume the target listening for events
 280          */
   1 /*
   2  * Copyright (c) 2007, 2017, 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 //    THIS TEST IS LINE NUMBER SENSITIVE
  25 
  26 /**
  27  * @test
  28  * @bug 4359312 4450091
  29  * @summary Test PTR 1421 JVM exceptions making a call to LocalVariable.type().name()

  30  * @author Tim Bell (based on the PTR 1421 report submitted by IBM).
  31  *
  32  * @run build TestScaffold VMConnection TargetListener TargetAdapter
  33  * @run compile -g GetLocalVariables.java
  34  * @run driver GetLocalVariables
  35  */
  36 
  37 import com.sun.jdi.*;
  38 import com.sun.jdi.event.*;
  39 import com.sun.jdi.request.*;
  40 
  41 import java.util.*;
  42 
  43  /********** target program **********/
  44 
  45 class GetLocalVariablesTarg {
  46     private static char s_char1 = 'a';
  47     private static char s_char2 = (char) 0;
  48     private static char s_char3 = (char) 1;
  49     private static char s_char4 = (char) 32;
  50     private static char s_char5 = '\u7ffe';
  51     private static char s_char6 = '\u7fff';
  52     private static char s_char7 = '\u8000';
  53     private static char s_char8 = '\u8001';
  54     private static char s_char9 = '\ufffe';
  55     private static char s_char10 = '\uffff';
  56 


 202         int l_int = s_int1 + s_int2 + s_int3 + s_int4 + s_int5 +
 203         s_int6 + s_int7 + s_int8 + s_int9 + s_int10;
 204         long l_long = s_long1 + s_long2 + s_long3 + s_long4 + s_long5 +
 205         s_long6 + s_long7 + s_long8 + s_long9 + s_long10;
 206         float l_float = s_float1 + s_float2;
 207         double l_double = s_double1 + s_double2;
 208         int[] l_iarray = null;
 209         int[][] l_marray = null;
 210         String l_string = s_string1 + s_string3 + s_sarray1[0];
 211 
 212         if (s_sarray2 == null)
 213             l_string += "?";
 214 
 215         if (s_sarray3 instanceof String[])
 216             l_string += "<io>";
 217 
 218         Object e6 = new GetLocalVariablesTarg(l_char, l_byte, l_short, l_int,
 219                                      l_long, l_float, l_double, l_iarray,
 220                                      l_marray, l_string);
 221 
 222         e1.test_1();            // RESUME_TO_LINE
 223         e3.test_1();
 224         e4.test_1();
 225         e5.test_1();
 226         ((GetLocalVariablesTarg) e6).test_1();
 227 
 228         e3 = null;
 229         if (e3 == e1)
 230             e3.test_1();
 231         e3 = e4;
 232         if (e3 == e2)
 233             e3 = e5;
 234         e3.test_1();
 235 
 236     }
 237 
 238     public void test_1()
 239     {
 240         double l_add = i_double + i_short;
 241         long l_subtract = i_long - i_int;
 242         long l_multiply = i_byte * i_int;
 243 
 244         i_double = l_add + i_float;
 245         i_short = (short) l_subtract;
 246         i_long = l_multiply + i_byte + i_short;
 247     }
 248 
 249     public static void main(String[] args) {
 250         System.out.println("Howdy!");
 251         test_expressions();
 252         System.out.println("Goodbye from GetLocalVariablesTarg!");
 253     }
 254 }
 255 
 256  /********** test program **********/
 257 
 258 public class GetLocalVariables extends TestScaffold {
 259     static final int RESUME_TO_LINE = 222;
 260     ReferenceType targetClass;
 261     ThreadReference mainThread;
 262 
 263     GetLocalVariables (String args[]) {
 264         super(args);
 265     }
 266 
 267     public static void main(String[] args)
 268         throws Exception
 269     {
 270         new GetLocalVariables (args).startTests();
 271     }
 272 
 273     /********** test core **********/
 274 
 275     protected void runTests()
 276         throws Exception
 277     {
 278         /*
 279          * Get to the top of main() to determine targetClass and mainThread
 280          */
 281         BreakpointEvent bpe = startToMain("GetLocalVariablesTarg");
 282         targetClass = bpe.location().declaringType();
 283         mainThread = bpe.thread();
 284         EventRequestManager erm = vm().eventRequestManager();
 285 
 286         bpe = resumeTo("GetLocalVariablesTarg", RESUME_TO_LINE);
 287         /*
 288          * We've arrived.  Look around at some variables.
 289          */
 290         StackFrame frame = bpe.thread().frame(0);
 291         List localVars = frame.visibleVariables();
 292         System.out.println("    Visible variables at this point are: ");
 293         for (Iterator it = localVars.iterator(); it.hasNext();) {
 294             LocalVariable lv = (LocalVariable) it.next();
 295             System.out.print(lv.name());
 296             System.out.print(" typeName: ");
 297             System.out.print(lv.typeName());
 298             System.out.print(" signature: ");
 299             System.out.print(lv.type().signature());
 300             System.out.print(" primitive type: ");
 301             System.out.println(lv.type().name());
 302         }
 303 
 304         /*
 305          * resume the target listening for events
 306          */
< prev index next >