test/hotspot/jtreg/vmTestbase/nsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001.java
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 50317 cf71bff5f533
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
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) 2003, 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.VirtualMachine.AllClassesWithGeneric;
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 java.io.*;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    27
import java.util.*;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    28
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    29
import nsk.share.*;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    30
import nsk.share.jpda.*;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    31
import nsk.share.jdwp.*;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    32
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
 * This test checks that the JDWP command <code>AllClassesWithGeneric</code>
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    35
 * from the <code>VirtualMachine</code> command set returns generic signature
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    36
 * information properly.<br>
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    37
 * Debuggee part of the test creates instances of several tested classes. Some
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    38
 * of the classes are generic. Debugger part obtains signature information of
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    39
 * all loaded classes by sending the tested JDWP command. Proper generic
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    40
 * signature should be returned for each tested class which is generic, or
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    41
 * an empty string for non-generic one. All tested classes should be found
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    42
 * in reply packet as well.
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 class allclswithgeneric001 {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    45
    static final String DEBUGGEE_CLASS =
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    46
        "nsk.jdwp.VirtualMachine.AllClassesWithGeneric.allclswithgeneric001t";
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    47
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    48
    static final String JDWP_COMMAND_NAME = "VirtualMachine.AllClassesWithGeneric";
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    49
    static final int JDWP_COMMAND_ID =
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    50
        JDWP.Command.VirtualMachine.AllClassesWithGeneric;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    51
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    52
    static final String COMMAND_READY = "ready";
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    53
    static final String COMMAND_QUIT = "quit";
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    54
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    55
    static final String[][] classes = {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    56
        {"Lnsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001t;",
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    57
            "NULL"},
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    58
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    59
        {"Lnsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001b;",
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    60
            "<L:Ljava/lang/String;>Ljava/lang/Object;"},
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    61
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    62
        {"Lnsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001c;",
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    63
            "<A:Ljava/lang/Object;B:Ljava/lang/Integer;>Ljava/lang/Object;"},
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    64
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    65
        {"Lnsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001d;",
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    66
            "<T:Ljava/lang/Object;>Ljava/lang/Object;Lnsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001if<TT;>;"},
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    67
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    68
        {"Lnsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001e;",
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    69
            "NULL"},
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    70
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    71
        {"Lnsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001if;",
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    72
            "<I:Ljava/lang/Object;>Ljava/lang/Object;"},
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
        {"Lnsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001f;",
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    75
            "NULL"},
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    76
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    77
        {"Lnsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001g;",
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    78
            "<E:Lnsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001e;:Lnsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001if;>Ljava/lang/Object;"},
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    79
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    80
        {"Lnsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001h;",
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    81
            "<A1:Ljava/lang/Object;B1:Ljava/lang/Object;C1:Ljava/lang/Object;>Lnsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001d<TA1;>;Lnsk/jdwp/VirtualMachine/AllClassesWithGeneric/allclswithgeneric001if2<TA1;TB1;TC1;>;"}
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    82
    };
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    83
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    84
    static final int CLS_NUM = classes.length;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    85
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    86
    private int foundClasses[] = new int[CLS_NUM];
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    87
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    88
    private Log log;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    89
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    90
    public static void main(String argv[]) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    91
        System.exit(run(argv,System.out) + Consts.JCK_STATUS_BASE);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    92
    }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    93
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    94
    public static int run(String argv[], PrintStream out) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    95
        return new allclswithgeneric001().runThis(argv, out);
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
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    98
    public int runThis(String argv[], PrintStream out) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
    99
        ArgumentHandler argumentHandler = new ArgumentHandler(argv);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   100
        log = new Log(out, argumentHandler);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   101
        boolean result = true;
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
        try {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   104
            for(int i=0; i<CLS_NUM; i++)
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   105
                foundClasses[i] = 0;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   106
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   107
            Binder binder = new Binder(argumentHandler, log);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   108
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   109
            log.display("Starting debuggee VM ...");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   110
            Debugee debuggee = binder.bindToDebugee(DEBUGGEE_CLASS);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   111
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   112
            Transport transport = debuggee.getTransport();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   113
            IOPipe pipe = debuggee.createIOPipe();
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
            log.display("Waiting for VM_INIT event ...");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   116
            debuggee.waitForVMInit();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   117
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   118
            log.display("Querying for IDSizes ...");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   119
            debuggee.queryForIDSizes();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   120
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   121
            log.display("Resuming debuggee VM ...");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   122
            debuggee.resume();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   123
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   124
            log.display("Waiting for command: " + COMMAND_READY
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   125
                + " ...");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   126
            String cmd = pipe.readln();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   127
            log.display(" ... Received command: " + cmd);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   128
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   129
            try {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   130
                /////// begin test of JDWP command
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   131
                log.display("\n>>>>>> Create command " + JDWP_COMMAND_NAME);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   132
                CommandPacket command = new CommandPacket(JDWP_COMMAND_ID);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   133
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   134
                log.display("Sending command packet:\n" + command);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   135
                transport.write(command);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   136
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   137
                log.display("\nWaiting for reply packet ...");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   138
                ReplyPacket reply = new ReplyPacket();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   139
                transport.read(reply);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   140
                log.display(" ... Reply packet received:\n" + reply);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   141
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   142
                log.display("\nChecking reply packet header");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   143
                reply.checkHeader(command.getPacketID());
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   144
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   145
             /* parsing of reply data:
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   146
                int classes - Number of reference types that follow
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   147
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   148
                ---- Repeated 'classes' times:
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   149
                byte refTypeTag - Kind of following reference type.
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   150
                referenceTypeID typeID - Loaded reference type.
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   151
                string signature - The JNI signature for the loaded reference type.
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   152
                string genericSignature - The generic signature for the loaded reference type
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   153
                                          or an empty string if there is none.
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   154
                int status - The current class status.
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   155
                ----
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   156
             */
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   157
                log.display("\nParsing reply packet:");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   158
                reply.resetPosition();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   159
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   160
                int cls_num = reply.getInt();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   161
                log.display("\tclasses: " + cls_num);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   162
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   163
                for (int i=0; i<cls_num; i++) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   164
                    byte refTypeTag = reply.getByte();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   165
                    long typeID = reply.getReferenceTypeID();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   166
                    String signature = reply.getString();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   167
                    String genSignature = reply.getString();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   168
                    int status = reply.getInt();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   169
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   170
                    int idx = findClass(signature);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   171
                    if (idx != -1) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   172
                        foundClasses[idx]++;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   173
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   174
                        log.display("\n--> found tested class "
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   175
                            + classes[idx][0] + " :"
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   176
                            + "\n\t\trefTypeTag: " + refTypeTag
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   177
                            + "\n\t\ttypeID: " + typeID
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   178
                            + "\n\t\tsignature: " + signature);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   179
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   180
                        if (genSignature.length() == 0) // a non-generic class
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   181
                            genSignature = "NULL";
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   182
                            if (!genSignature.equals(classes[idx][1])) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   183
                            log.complain("TEST FAILED: Unexpected generic signature of tested class #"
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   184
                                + (i+1) + " (" + classes[idx][0] + ")"
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   185
                                + " in the reply packet:"
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   186
                                + "\n\tGot: " + genSignature
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   187
                                + "\n\tExpected: " + classes[idx][1] + "\n");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   188
                            result = false;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   189
                        }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   190
                        else
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   191
                            log.display("\t\tgeneric signature: " + genSignature);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   192
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   193
                        log.display("\t\tstatus: " + status);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   194
                    }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   195
                }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   196
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   197
                if (!reply.isParsed()) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   198
                    log.complain("TEST FAILED: Extra trailing bytes found in reply packet at: "
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   199
                        + reply.currentPosition());
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   200
                    result = false;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   201
                } else
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   202
                    log.display("\n<<<<<< Reply packet parsed");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   203
                /////// end test of JDWP command
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   204
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   205
                for (int i=0; i<CLS_NUM; i++)
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   206
                    if (foundClasses[i] != 1) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   207
                        result = false;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   208
                        log.complain("TEST FAILED: Unexpected number of reference types for the tested class\n\t"
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   209
                            + classes[i][0] + "\n\tin reply packet on "
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   210
                            + JDWP_COMMAND_NAME
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   211
                            + ":\n\tGot: " + foundClasses[i]
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   212
                            + "\n\tExpected: 1");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   213
                    }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   214
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   215
            } catch (Exception e) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   216
                e.printStackTrace(out);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   217
                log.complain("Caught exception while testing JDWP command: "
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   218
                    + e);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   219
                result = false;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   220
            } finally {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   221
                log.display("Sending command: " + COMMAND_QUIT + " ...");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   222
                pipe.println(COMMAND_QUIT);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   223
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   224
                log.display("Waiting for debuggee exits ...");
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   225
                int code = debuggee.waitFor();
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   226
                if (code == Consts.JCK_STATUS_BASE + Consts.TEST_PASSED) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   227
                    log.display(" ... Debuggee PASSED with the exit code: "
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   228
                        + code);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   229
                } else {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   230
                    log.complain(" ... Debuggee FAILED with the exit code: "
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   231
                        + code);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   232
                    result = false;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   233
                }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   234
            }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   235
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   236
        } catch (Exception e) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   237
            e.printStackTrace(out);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   238
            log.complain("Caught unexpected exception while communicating with debugee: "
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   239
                + e);
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   240
            result = false;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   241
        }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   242
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   243
        if (!result)
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   244
            return Consts.TEST_FAILED;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   245
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   246
        return Consts.TEST_PASSED;
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   247
    }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   248
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   249
    private int findClass(String cls) {
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   250
        for (int i=0; i<CLS_NUM; i++)
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   251
            if (cls.equals(classes[i][0]))
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   252
                return i; // the tested class found
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   253
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   254
        return -1; // the tested class not found
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   255
    }
cf71bff5f533 8199371: [TESTBUG] Open source vm testbase JDWP tests
iignatyev
parents:
diff changeset
   256
}