jdk/test/com/sun/jdi/FetchLocals.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 test - DO NOT CHANGE
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 *  @test/nodynamiccopyright/
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *  @bug 4386002 4429245
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *  @summary Test fix for: Incorrect values reported for some locals of type long
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 *  @author Tim Bell
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 FetchLocals.java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *  @run main FetchLocals
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 java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
class FetchLocalsDebugee {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
    public long testMethod() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
        short s = 12345;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
        int i = 8675309;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
        boolean pt = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
        long w = 973230999L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
        byte b = 0x3b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
        long x = w * 1000L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
        char c = '\u005A';      // 005A = "Z"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
        long y = 22;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
        float f = 6.66f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
        double d = 7.77;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
        System.out.print("pt is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
        System.out.println(pt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
        System.out.print("b is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
        System.out.println(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
        System.out.print("c is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
        System.out.println(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
        System.out.print("s is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
        System.out.println(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
        System.out.print("i is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
        System.out.println(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
        System.out.print("w is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        System.out.print(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        System.out.print("     (0x");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        System.out.print(Long.toHexString(w));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        System.out.println(")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        System.out.print("x is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        System.out.print(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        System.out.print("  (0x");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        System.out.print(Long.toHexString(x));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        System.out.println(")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        System.out.print("y is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        System.out.print(y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        System.out.print("            (0x");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        System.out.print(Long.toHexString(y));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        System.out.println(")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        System.out.print("f is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        System.out.println(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        System.out.print("d is: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        System.out.println(d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        System.out.println();   // Thie is Line 63...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        if (w == 0xde00ad00be00ef00L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
          System.out.print  ("The debugger was here.  w modified to: 0x");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
          System.out.println(Long.toHexString(w));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
          System.out.print  ("w contains : 0x");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
          System.out.println(Long.toHexString(w));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        System.out.println();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        return x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public static void main(String[] args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        System.out.print  ("FetchLocalsDebugee");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        System.out.println(" Starting up...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        FetchLocalsDebugee my = new FetchLocalsDebugee ();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        long result = my.testMethod();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        System.out.print  ("testMethod() returned: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        System.out.print  (result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        System.out.print  (" (0x");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        System.out.print  (Long.toHexString(result));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        System.out.println(")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        System.out.print  ("FetchLocalsDebugee");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        System.out.println(" Shutting down...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
public class FetchLocals extends TestScaffold {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    FetchLocals (String args[]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        super(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public static void main(String[] args)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        new FetchLocals (args).startTests();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /** Express a 64 bit double as a hex string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    private static String hexify(double d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        long bits = Double.doubleToLongBits(d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        return (" (0x" + java.lang.Long.toHexString(bits) + ")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /** Express a 32 bit float as a hex string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    private static String hexify(float f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        int bits = Float.floatToIntBits(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        return (" (0x" + java.lang.Integer.toHexString(bits) + ")");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    protected void test(String name, BooleanValue testV, boolean expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            System.out.println("Error for " + name + " = " + testV.value() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                                 " should be: " + expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    protected void test(String name, ByteValue testV, byte expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            System.out.println("Error for " + name + " = " + testV.value() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                 " should be: " + expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    protected void test(String name, CharValue testV, char expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            System.out.println("Error for " + name + " = " + testV.value() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                                 " should be: " + expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    protected void test(String name, ShortValue testV, short expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            System.out.println("Error for " + name + " = " + testV.value() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                                 " should be: " + expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    protected void test(String name, IntegerValue testV, int expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            System.out.println("Error for " + name + " = " + testV.value() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                                 " should be: " + expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    protected void test(String name, LongValue testV, long expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            System.out.println("Error for " + name + " = 0x" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                                 Long.toHexString(testV.value()) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                                 " should be: 0x" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                                 Long.toHexString(expectV));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    protected void test(String name, FloatValue testV, float expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            System.out.println("Error for " + name + " = " + testV.value() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                               hexify(testV.value()) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                               " should be: " + expectV +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                               hexify(expectV));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    protected void test(String name, DoubleValue testV, double expectV)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        if (testV.value() != expectV) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            System.out.println("Error for " + name + " = " + testV.value() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                               hexify(testV.value()) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                               " should be: " + expectV +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                               hexify(expectV));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            System.out.print  ("Tested OK: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            System.out.print  (name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            System.out.print  (" = ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            System.out.println(expectV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    protected void testLocalVariables (StackFrame sf)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
         * Test values in the local method testMethod ():
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
         *   1) Read current data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
         *   2) Test against the expected value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
         *   3) Set to a new value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
         *   4) Read again
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
         *   5) Test against the expected value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        LocalVariable lv = sf.visibleVariableByName("pt");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        BooleanValue booleanV = (BooleanValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        test("pt", booleanV, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        booleanV = vm().mirrorOf(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        sf.setValue(lv, booleanV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        booleanV = (BooleanValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        test("pt", booleanV, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        lv = sf.visibleVariableByName("b");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        ByteValue byteV = (ByteValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        byte bTmp = 0x3b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        test("b", byteV, bTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        bTmp = 0x7e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        byteV = vm().mirrorOf(bTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        sf.setValue(lv, byteV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        byteV = (ByteValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        test("b", byteV, bTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        lv = sf.visibleVariableByName("c");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        CharValue charV = (CharValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        char cTmp = '\u005A';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        test("c", charV, cTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        cTmp = 'A';
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        charV = vm().mirrorOf(cTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        sf.setValue(lv, charV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        charV = (CharValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        test("c", charV, cTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        lv = sf.visibleVariableByName("s");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        ShortValue shortV = (ShortValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        short sTmp = 12345;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        test("s", shortV, sTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        sTmp = -32766;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        shortV = vm().mirrorOf(sTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        sf.setValue(lv, shortV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        shortV = (ShortValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        test("s", shortV, sTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        lv = sf.visibleVariableByName("i");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        IntegerValue integerV = (IntegerValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        int iTmp = 8675309;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        test("i", integerV, iTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        iTmp = -42;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        integerV = vm().mirrorOf(iTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        sf.setValue(lv, integerV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        integerV = (IntegerValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        test("i", integerV, iTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        lv = sf.visibleVariableByName("w");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        LongValue longV = (LongValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        long wTmp = 973230999L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        test("w", longV, wTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        wTmp = 0xde00ad00be00ef00L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        longV = vm().mirrorOf(wTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        sf.setValue(lv, longV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        longV = (LongValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        test("w", longV, wTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        lv = sf.visibleVariableByName("x");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        longV = (LongValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        long xTmp = 973230999L * 1000L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        test("x", longV, xTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        xTmp = 0xca00fe00ba00be00L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        longV = vm().mirrorOf(xTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        sf.setValue(lv, longV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        longV = (LongValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        test("x", longV, xTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        lv = sf.visibleVariableByName("y");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        longV = (LongValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        long yTmp = 22;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        test("y", longV, yTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        yTmp = 0xdeadbeefcafebabeL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        longV = vm().mirrorOf(yTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        sf.setValue(lv, longV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        longV = (LongValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        test("x", longV, yTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        lv = sf.visibleVariableByName("f");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        FloatValue floatV = (FloatValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        float fTmp = 6.66f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        test("f", floatV, fTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        fTmp = (float)java.lang.Math.PI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        floatV = vm().mirrorOf(fTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        sf.setValue(lv, floatV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        floatV = (FloatValue)sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        test("f", floatV, fTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        lv = sf.visibleVariableByName("d");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        DoubleValue doubleV = (DoubleValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        double dTmp = 7.77;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        test("d", doubleV, dTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        dTmp = java.lang.Math.E;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        doubleV = vm().mirrorOf(dTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        sf.setValue(lv, doubleV);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        doubleV = (DoubleValue) sf.getValue(lv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        test("d", doubleV, dTmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    protected void runTests()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        throws Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        startToMain("FetchLocalsDebugee");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
         * Get to the bottom of testMethod():
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            BreakpointEvent bpe = resumeTo("FetchLocalsDebugee", 63);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
             * Fetch values from fields; what did we get?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            StackFrame sf = bpe.thread().frame(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            testLocalVariables (sf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        } catch(Exception ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            ex.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            testFailed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            // Allow application to complete and shut down
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            resumeToVMDisconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        if (!testFailed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            System.out.println("FetchLocals: passed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            throw new Exception("FetchLocals: failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
}