test/hotspot/jtreg/vmTestbase/nsk/jdwp/ArrayReference/GetValues/getvalues002a.java
author iignatyev
Wed, 30 May 2018 20:54:45 -0700
changeset 50317 cf71bff5f533
permissions -rw-r--r--
8199371: [TESTBUG] Open source vm testbase JDWP tests Reviewed-by: sspitsyn, mseledtsov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50317
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
     1
/*
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
     2
 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
     4
 *
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
     8
 *
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    14
 *
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    18
 *
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    21
 * questions.
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    22
 */
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    23
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    24
package nsk.jdwp.ArrayReference.GetValues;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    25
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    26
import nsk.share.*;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    27
import nsk.share.jpda.*;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    28
import nsk.share.jdwp.*;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    29
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    30
import java.io.*;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    31
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    32
public class getvalues002a {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    33
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    34
    public static final String ARRAY_FIELD_NAME = "array";
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    35
    public static final int FIELDS_COUNT = 10;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    36
    public static final int ARRAY_FIRST_INDEX = 4;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    37
    public static final int ARRAY_LENGTH = ARRAY_FIRST_INDEX + FIELDS_COUNT + 5;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    38
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    39
    public static void main(String args[]) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    40
        getvalues002a _getvalues002a = new getvalues002a();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    41
        System.exit(getvalues002.JCK_STATUS_BASE + _getvalues002a.runIt(args, System.err));
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    42
    }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    43
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    44
    public int runIt(String args[], PrintStream out) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    45
        //make log for debugee messages
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    46
        ArgumentHandler argumentHandler = new ArgumentHandler(args);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    47
        Log log = new Log(out, argumentHandler);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    48
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    49
        // meke communication pipe to debugger
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    50
        log.display("Creating pipe");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    51
        IOPipe pipe = argumentHandler.createDebugeeIOPipe(log);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    52
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    53
        // ensure tested class loaded
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    54
        log.display("Creating and fille tested array");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    55
        TestedClass.setArrayValues();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    56
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    57
        // send debugger signal READY
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    58
        log.display("Sending signal to debugger: " + getvalues002.READY);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    59
        pipe.println(getvalues002.READY);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    60
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    61
        // wait for signal QUIT from debugeer
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    62
        log.display("Waiting for signal from debugger: " + getvalues002.QUIT);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    63
        String signal = pipe.readln();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    64
        log.display("Received signal from debugger: " + signal);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    65
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    66
        // check received signal
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    67
        if (! signal.equals(getvalues002.QUIT)) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    68
            log.complain("Unexpected communication signal from debugee: " + signal
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    69
                        + " (expected: " + getvalues002.QUIT + ")");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    70
            log.display("Debugee FAILED");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    71
            return getvalues002.FAILED;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    72
        }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    73
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    74
        // exit debugee
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    75
        log.display("Debugee PASSED");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    76
        return getvalues002.PASSED;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    77
    }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    78
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    79
    // tested class with own static fields values
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    80
    public static class TestedClass {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    81
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    82
        // static field with tested array
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    83
        public static Object array[] = null;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    84
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    85
        // static fields with object values
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    86
        public static Object      nullObject           = null;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    87
        public static Object      baseObject           = new Object();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    88
        public static TestedClass derivedObject        = new TestedClass();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    89
        public static String      stringObject         = new String("string");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    90
        public static int[]       primitiveArrayObject = new int[10];
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    91
        public static Object[]    objectArrayObject    = new Object[10];
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    92
        public static Thread      threadObject         = Thread.currentThread();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    93
        public static ThreadGroup threadGroupObject    = threadObject.getThreadGroup();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    94
        public static Class       classObject          = derivedObject.getClass();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    95
        public static ClassLoader classLoaderObject    = classObject.getClassLoader();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    96
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    97
        public static void setArrayValues() {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    98
            array = new Object[ARRAY_LENGTH];
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    99
            for (int i = 0; i < ARRAY_LENGTH; i++) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   100
                array[i] = null;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   101
            }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   102
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   103
            int i = ARRAY_FIRST_INDEX;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   104
            array[i + 0] = nullObject;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   105
            array[i + 1] = baseObject;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   106
            array[i + 2] = derivedObject;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   107
            array[i + 3] = stringObject;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   108
            array[i + 4] = primitiveArrayObject;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   109
            array[i + 5] = objectArrayObject;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   110
            array[i + 6] = threadObject;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   111
            array[i + 7] = threadGroupObject;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   112
            array[i + 8] = classObject;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   113
            array[i + 9] = classLoaderObject;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   114
        }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   115
    }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   116
}