Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/jdwp/ArrayReference/GetValues/getvalues002a.java
41162 views
/*1* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package nsk.jdwp.ArrayReference.GetValues;2425import nsk.share.*;26import nsk.share.jpda.*;27import nsk.share.jdwp.*;2829import java.io.*;3031public class getvalues002a {3233public static final String ARRAY_FIELD_NAME = "array";34public static final int FIELDS_COUNT = 10;35public static final int ARRAY_FIRST_INDEX = 4;36public static final int ARRAY_LENGTH = ARRAY_FIRST_INDEX + FIELDS_COUNT + 5;3738public static void main(String args[]) {39getvalues002a _getvalues002a = new getvalues002a();40System.exit(getvalues002.JCK_STATUS_BASE + _getvalues002a.runIt(args, System.err));41}4243public int runIt(String args[], PrintStream out) {44//make log for debugee messages45ArgumentHandler argumentHandler = new ArgumentHandler(args);46Log log = new Log(out, argumentHandler);4748// meke communication pipe to debugger49log.display("Creating pipe");50IOPipe pipe = argumentHandler.createDebugeeIOPipe(log);5152// ensure tested class loaded53log.display("Creating and fille tested array");54TestedClass.setArrayValues();5556// send debugger signal READY57log.display("Sending signal to debugger: " + getvalues002.READY);58pipe.println(getvalues002.READY);5960// wait for signal QUIT from debugeer61log.display("Waiting for signal from debugger: " + getvalues002.QUIT);62String signal = pipe.readln();63log.display("Received signal from debugger: " + signal);6465// check received signal66if (! signal.equals(getvalues002.QUIT)) {67log.complain("Unexpected communication signal from debugee: " + signal68+ " (expected: " + getvalues002.QUIT + ")");69log.display("Debugee FAILED");70return getvalues002.FAILED;71}7273// exit debugee74log.display("Debugee PASSED");75return getvalues002.PASSED;76}7778// tested class with own static fields values79public static class TestedClass {8081// static field with tested array82public static Object array[] = null;8384// static fields with object values85public static Object nullObject = null;86public static Object baseObject = new Object();87public static TestedClass derivedObject = new TestedClass();88public static String stringObject = new String("string");89public static int[] primitiveArrayObject = new int[10];90public static Object[] objectArrayObject = new Object[10];91public static Thread threadObject = Thread.currentThread();92public static ThreadGroup threadGroupObject = threadObject.getThreadGroup();93public static Class classObject = derivedObject.getClass();94public static ClassLoader classLoaderObject = classObject.getClassLoader();9596public static void setArrayValues() {97array = new Object[ARRAY_LENGTH];98for (int i = 0; i < ARRAY_LENGTH; i++) {99array[i] = null;100}101102int i = ARRAY_FIRST_INDEX;103array[i + 0] = nullObject;104array[i + 1] = baseObject;105array[i + 2] = derivedObject;106array[i + 3] = stringObject;107array[i + 4] = primitiveArrayObject;108array[i + 5] = objectArrayObject;109array[i + 6] = threadObject;110array[i + 7] = threadGroupObject;111array[i + 8] = classObject;112array[i + 9] = classLoaderObject;113}114}115}116117118