jdk/test/com/sun/jdi/GetLocalVariables.java
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 2 90ce3da70b43
child 24973 8c4bc3fa4c4e
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/** hard coded linenumbers in this test - DO NOT CHANGE
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 *  @test/nodynamiccopyright/
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *  @bug 4359312 4450091
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *  @summary Test PTR 1421 JVM exceptions making a call to LocalVariable.type().name()
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 *  @author Tim Bell (based on the PTR 1421 report submitted by IBM).
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *  @run build TestScaffold VMConnection TargetListener TargetAdapter
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *  @run compile -g GetLocalVariables.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *  @run main GetLocalVariables
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
import com.sun.jdi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
import com.sun.jdi.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
import com.sun.jdi.request.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 /********** target program **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
class GetLocalVariablesTarg {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
    private static char s_char1 = 'a';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
    private static char s_char2 = (char) 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
    private static char s_char3 = (char) 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
    private static char s_char4 = (char) 32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
    private static char s_char5 = '\u7ffe';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
    private static char s_char6 = '\u7fff';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
    private static char s_char7 = '\u8000';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
    private static char s_char8 = '\u8001';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
    private static char s_char9 = '\ufffe';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
    private static char s_char10 = '\uffff';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
    private static byte s_byte1 = (byte) 146;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
    private static byte s_byte2 = (byte) 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
    private static byte s_byte3 = (byte) 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    private static byte s_byte4 = (byte) 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    private static byte s_byte5 = (byte) 127;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    private static byte s_byte6 = (byte) 128;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    private static byte s_byte7 = (byte) - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    private static byte s_byte8 = (byte) - 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    private static byte s_byte9 = (byte) - 127;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    private static byte s_byte10 = (byte) - 128;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    private static short s_short1 = (short) 28123;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    private static short s_short2 = (short) 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private static short s_short3 = (short) 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private static short s_short4 = (short) 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private static short s_short5 = (short) 0x7ffe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private static short s_short6 = (short) 0x7fff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private static short s_short7 = (short) -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private static short s_short8 = (short) -15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private static short s_short9 = (short) -0x7ffe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private static short s_short10 = (short) -0x7fff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private static int s_int1 = 3101246;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private static int s_int2 = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private static int s_int3 = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private static int s_int4 = 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    private static int s_int5 = 0x7ffffffe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private static int s_int6 = 0x7fffffff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private static int s_int7 = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private static int s_int8 = -15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private static int s_int9 = -0x7ffffffe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private static int s_int10 = -0x7fffffff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    private static long s_long1 = 0x0123456789ABCDEFL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private static long s_long2 = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private static long s_long3 = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private static long s_long4 = 15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private static long s_long5 = 0x000000007fffffffL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private static long s_long6 = 0x0000000080000000L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private static long s_long7 = 0x0000000100000000L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private static long s_long8 = 0x7fffffffffffffffL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private static long s_long9 = 0x8000000000000000L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private static long s_long10 = -15;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private static float s_float1 = 2.3145f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private static float s_float2 = 0f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    private static double s_double1 = 1.469d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private static double s_double2 = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    private static int s_iarray1[] = {1, 2, 3};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    private static int s_iarray2[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    private static int s_marray1[][] = {{1, 2, 3}, {3, 4, 5}, null, {6, 7}};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    private static int s_marray2[][] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    private static String s_sarray1[] = {"abc", null, "def", "ghi"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private static String s_sarray2[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    private static Object s_sarray3[] = s_sarray1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    private static String s_string1 = "abcdef";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    private static String s_string2 = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private static String s_string3 = "a\u1234b\u7777";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    private char i_char;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    private byte i_byte;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    private short i_short;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    private int i_int;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    private long i_long;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    private float i_float;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    private double i_double;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    private int i_iarray[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    private int i_marray[][];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    private String i_string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    public GetLocalVariablesTarg()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        int index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        i_char = 'B';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        i_byte = 120;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        i_short = 12048;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        i_int = 0x192842;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        i_long = 123591230941L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        i_float = 235.15e5f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        i_double = 176e-1d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        i_iarray = new int[5];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        i_marray = new int[7][];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        i_string = "empty";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        for (index = 0; index < i_iarray.length; ++index)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            i_iarray[index] = index + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        i_marray[0] = new int[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        i_marray[1] = new int[4];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        i_marray[2] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        i_marray[3] = new int[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        i_marray[4] = new int[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        i_marray[5] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        i_marray[6] = new int[7];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        for (index = 0; index < i_marray.length; ++index)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            if (i_marray[index] != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                for (int index2 = 0; index2 < i_marray[index].length; ++index2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                    i_marray[index][index2] = index + index2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    public GetLocalVariablesTarg(char p_char, byte p_byte, short p_short,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                        int p_int, long p_long, float p_float,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                        double p_double, int p_iarray[], int p_marray[][],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                        String p_string)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        i_char = p_char;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        i_byte = p_byte;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        i_short = p_short;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        i_int = p_int;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        i_long = p_long;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        i_float = p_float;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        i_double = p_double;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        i_iarray = p_iarray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        i_marray = p_marray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        i_string = p_string;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    public static void test_expressions()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        GetLocalVariablesTarg e1 = new GetLocalVariablesTarg();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        GetLocalVariablesTarg e2 = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        GetLocalVariablesTarg e3 = e1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        GetLocalVariablesTarg e4 = new GetLocalVariablesTarg(s_char1, s_byte1, s_short1, s_int1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                                           s_long1, s_float1, s_double1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                                           s_iarray1, s_marray1, "e4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        GetLocalVariablesTarg e5 = new GetLocalVariablesTarg(s_char2, s_byte2, s_short2, s_int2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                                           s_long2, s_float2, s_double2,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                                           s_iarray2, s_marray2, "e5");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        char l_char = (char) (
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                           s_char1 + s_char2 + s_char3 + s_char4 + s_char5 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                          s_char6 + s_char7 + s_char8 + s_char9 + s_char10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        byte l_byte = (byte) (
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                           s_byte1 + s_byte2 + s_byte3 + s_byte4 + s_byte5 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                          s_byte6 + s_byte7 + s_byte8 + s_byte9 + s_byte10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        short l_short = (short) (
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                      s_short1 + s_short2 + s_short3 + s_short4 + s_short5 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                     s_short6 + s_short7 + s_short8 + s_short9 + s_short10);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        int l_int = s_int1 + s_int2 + s_int3 + s_int4 + s_int5 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        s_int6 + s_int7 + s_int8 + s_int9 + s_int10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        long l_long = s_long1 + s_long2 + s_long3 + s_long4 + s_long5 +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        s_long6 + s_long7 + s_long8 + s_long9 + s_long10;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        float l_float = s_float1 + s_float2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        double l_double = s_double1 + s_double2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        int[] l_iarray = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        int[][] l_marray = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        String l_string = s_string1 + s_string3 + s_sarray1[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        if (s_sarray2 == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            l_string += "?";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        if (s_sarray3 instanceof String[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            l_string += "<io>";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        Object e6 = new GetLocalVariablesTarg(l_char, l_byte, l_short, l_int,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                                     l_long, l_float, l_double, l_iarray,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                                     l_marray, l_string);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        e1.test_1();            // <-- this is line 197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        e3.test_1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        e4.test_1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        e5.test_1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        ((GetLocalVariablesTarg) e6).test_1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        e3 = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        if (e3 == e1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            e3.test_1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        e3 = e4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        if (e3 == e2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            e3 = e5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        e3.test_1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public void test_1()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        double l_add = i_double + i_short;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        long l_subtract = i_long - i_int;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        long l_multiply = i_byte * i_int;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        i_double = l_add + i_float;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        i_short = (short) l_subtract;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        i_long = l_multiply + i_byte + i_short;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    public static void main(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        System.out.println("Howdy!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        test_expressions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        System.out.println("Goodbye from GetLocalVariablesTarg!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
 /********** test program **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
public class GetLocalVariables extends TestScaffold {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    ReferenceType targetClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    ThreadReference mainThread;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    GetLocalVariables (String args[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        super(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    public static void main(String[] args)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        new GetLocalVariables (args).startTests();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    /********** test core **********/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    protected void runTests()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
         * Get to the top of main() to determine targetClass and mainThread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        BreakpointEvent bpe = startToMain("GetLocalVariablesTarg");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        targetClass = bpe.location().declaringType();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        mainThread = bpe.thread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        EventRequestManager erm = vm().eventRequestManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        bpe = resumeTo("GetLocalVariablesTarg", 197);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
         * We've arrived.  Look around at some variables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        StackFrame frame = bpe.thread().frame(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        List localVars = frame.visibleVariables();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        System.out.println("    Visible variables at this point are: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        for (Iterator it = localVars.iterator(); it.hasNext();) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            LocalVariable lv = (LocalVariable) it.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            System.out.print(lv.name());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            System.out.print(" typeName: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            System.out.print(lv.typeName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            System.out.print(" signature: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            System.out.print(lv.type().signature());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            System.out.print(" primitive type: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            System.out.println(lv.type().name());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
         * resume the target listening for events
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        listenUntilVMDisconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
         * deal with results of test if anything has called failure("foo")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
         * testFailed will be true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        if (!testFailed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            println("GetLocalVariables: passed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            throw new Exception("GetLocalVariables: failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
}