test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java
author jgeorge
Fri, 01 Dec 2017 18:19:39 +0530
changeset 48181 61a14b5cb1c6
parent 47216 71c04702a3d5
child 50791 b1e90a8a876c
permissions -rw-r--r--
8191538: SA: tests for clhsdb commands: vmstructsdump, field, symboltable and symbol Summary: Create tests for the clhsdb commands: vmstructsdump, field, symboltable and symbol Reviewed-by: sspitsyn, sballal
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
     1
/*
43979
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
     2
 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
     4
 *
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
     8
 *
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    13
 * accompanied this code).
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    14
 *
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    18
 *
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    21
 * questions.
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    22
 */
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    23
43979
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
    24
import java.util.ArrayList;
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
    25
import java.util.List;
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
    26
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    27
import sun.jvm.hotspot.HotSpotAgent;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    28
import sun.jvm.hotspot.utilities.SystemDictionaryHelper;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    29
import sun.jvm.hotspot.oops.InstanceKlass;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    30
import sun.jvm.hotspot.debugger.*;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    31
43979
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
    32
import jdk.test.lib.apps.LingeredApp;
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    33
import jdk.test.lib.JDKToolLauncher;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    34
import jdk.test.lib.JDKToolFinder;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    35
import jdk.test.lib.Platform;
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40244
diff changeset
    36
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40244
diff changeset
    37
import jdk.test.lib.process.OutputAnalyzer;
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    38
import jdk.test.lib.Utils;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    39
import jdk.test.lib.Asserts;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    40
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    41
/*
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    42
 * @test
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40244
diff changeset
    43
 * @library /test/lib
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    44
 * @modules java.base/jdk.internal.misc
42573
a20695c30be5 8169638: serviceability/sa/TestInstanceKlassSize.java and serviceability/sa/TestInstanceKlassSizeForInterface.java fail compilation
dsamersoff
parents: 42075
diff changeset
    45
 *          jdk.hotspot.agent/sun.jvm.hotspot
a20695c30be5 8169638: serviceability/sa/TestInstanceKlassSize.java and serviceability/sa/TestInstanceKlassSizeForInterface.java fail compilation
dsamersoff
parents: 42075
diff changeset
    46
 *          jdk.hotspot.agent/sun.jvm.hotspot.utilities
a20695c30be5 8169638: serviceability/sa/TestInstanceKlassSize.java and serviceability/sa/TestInstanceKlassSizeForInterface.java fail compilation
dsamersoff
parents: 42075
diff changeset
    47
 *          jdk.hotspot.agent/sun.jvm.hotspot.oops
a20695c30be5 8169638: serviceability/sa/TestInstanceKlassSize.java and serviceability/sa/TestInstanceKlassSizeForInterface.java fail compilation
dsamersoff
parents: 42075
diff changeset
    48
 *          jdk.hotspot.agent/sun.jvm.hotspot.debugger
a20695c30be5 8169638: serviceability/sa/TestInstanceKlassSize.java and serviceability/sa/TestInstanceKlassSizeForInterface.java fail compilation
dsamersoff
parents: 42075
diff changeset
    49
 * @run main/othervm TestInstanceKlassSizeForInterface
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    50
 */
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    51
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    52
public class TestInstanceKlassSizeForInterface {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    53
43979
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
    54
    private static LingeredAppWithInterface theApp = null;
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
    55
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
    56
    private static void SAInstanceKlassSize(int lingeredAppPid,
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    57
                                            String[] instanceKlassNames) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    58
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    59
        HotSpotAgent agent = new HotSpotAgent();
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    60
        try {
43979
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
    61
            agent.attach(lingeredAppPid);
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    62
        }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    63
        catch (DebuggerException e) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    64
            System.out.println(e.getMessage());
43979
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
    65
            System.err.println("Unable to connect to process ID: " + lingeredAppPid);
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    66
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    67
            agent.detach();
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    68
            e.printStackTrace();
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    69
        }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    70
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    71
        for (String instanceKlassName : instanceKlassNames) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    72
            InstanceKlass iKlass = SystemDictionaryHelper.findInstanceKlass(
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    73
                                       instanceKlassName);
40889
adf083cbc37f 8164562: serviceability/sa/TestInstanceKlassSizeForInterface.java: fails with NPE
dsamersoff
parents: 40631
diff changeset
    74
            Asserts.assertNotNull(iKlass,
adf083cbc37f 8164562: serviceability/sa/TestInstanceKlassSizeForInterface.java: fails with NPE
dsamersoff
parents: 40631
diff changeset
    75
                String.format("Unable to find instance klass for %s", instanceKlassName));
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    76
            System.out.println("SA: The size of " + instanceKlassName +
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    77
                               " is " + iKlass.getSize());
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    78
        }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    79
        agent.detach();
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    80
    }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    81
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    82
    private static String getJcmdInstanceKlassSize(OutputAnalyzer output,
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    83
                                                   String instanceKlassName) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    84
        for (String s : output.asLines()) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    85
            if (s.contains(instanceKlassName)) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    86
                String tokens[];
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    87
                System.out.println(s);
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    88
                tokens = s.split("\\s+");
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    89
                return tokens[3];
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    90
            }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    91
        }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    92
        return null;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    93
    }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    94
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    95
    private static void createAnotherToAttach(
43979
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
    96
                            String[] instanceKlassNames,
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
    97
                            int lingeredAppPid) throws Exception {
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    98
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    99
        String[] toolArgs = {
40244
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 39999
diff changeset
   100
            "--add-modules=jdk.hotspot.agent",
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 39999
diff changeset
   101
            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED",
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 39999
diff changeset
   102
            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.utilities=ALL-UNNAMED",
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 39999
diff changeset
   103
            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
40889
adf083cbc37f 8164562: serviceability/sa/TestInstanceKlassSizeForInterface.java: fails with NPE
dsamersoff
parents: 40631
diff changeset
   104
            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.debugger=ALL-UNNAMED",
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   105
            "TestInstanceKlassSizeForInterface",
43979
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   106
            Integer.toString(lingeredAppPid)
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   107
        };
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   108
43979
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   109
        // Start a new process to attach to the LingeredApp process
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   110
        ProcessBuilder processBuilder = ProcessTools
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   111
                  .createJavaProcessBuilder(toolArgs);
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   112
        OutputAnalyzer SAOutput = ProcessTools.executeProcess(processBuilder);
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   113
        SAOutput.shouldHaveExitValue(0);
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   114
        System.out.println(SAOutput.getOutput());
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   115
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   116
        // Run jcmd on the LingeredApp process
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   117
        ProcessBuilder pb = new ProcessBuilder();
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   118
        pb.command(new String[] {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   119
                          JDKToolFinder.getJDKTool("jcmd"),
43979
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   120
                          Long.toString(lingeredAppPid),
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   121
                          "GC.class_stats",
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   122
                          "VTab,ITab,OopMap,KlassBytes"
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   123
                      }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   124
                  );
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   125
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   126
        OutputAnalyzer jcmdOutput = new OutputAnalyzer(pb.start());
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   127
        System.out.println(jcmdOutput.getOutput());
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   128
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   129
        // Match the sizes from both the output streams
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   130
        for (String instanceKlassName : instanceKlassNames) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   131
            System.out.println ("Trying to match for " + instanceKlassName);
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   132
            String jcmdInstanceKlassSize = getJcmdInstanceKlassSize(
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   133
                                                      jcmdOutput,
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   134
                                                      instanceKlassName);
40889
adf083cbc37f 8164562: serviceability/sa/TestInstanceKlassSizeForInterface.java: fails with NPE
dsamersoff
parents: 40631
diff changeset
   135
            Asserts.assertNotNull(jcmdInstanceKlassSize,
adf083cbc37f 8164562: serviceability/sa/TestInstanceKlassSizeForInterface.java: fails with NPE
dsamersoff
parents: 40631
diff changeset
   136
                "Could not get the instance klass size from the jcmd output");
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   137
            for (String s : SAOutput.asLines()) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   138
                if (s.contains(instanceKlassName)) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   139
                   Asserts.assertTrue(
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   140
                      s.contains(jcmdInstanceKlassSize),
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   141
                      "The size computed by SA for " +
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   142
                      instanceKlassName + " does not match.");
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   143
                }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   144
            }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   145
        }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   146
    }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   147
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   148
    public static void main (String... args) throws Exception {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   149
        String[] instanceKlassNames = new String[] {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   150
                                          "Language",
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   151
                                          "ParselTongue",
43979
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   152
                                          "LingeredAppWithInterface$1"
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   153
                                      };
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   154
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   155
        if (!Platform.shouldSAAttach()) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   156
            System.out.println(
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   157
               "SA attach not expected to work - test skipped.");
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   158
            return;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   159
        }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   160
40889
adf083cbc37f 8164562: serviceability/sa/TestInstanceKlassSizeForInterface.java: fails with NPE
dsamersoff
parents: 40631
diff changeset
   161
        if (args == null || args.length == 0) {
43979
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   162
            try {
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   163
                List<String> vmArgs = new ArrayList<String>();
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   164
                vmArgs.addAll(Utils.getVmOptions());
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   165
43979
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   166
                theApp = new LingeredAppWithInterface();
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   167
                LingeredApp.startApp(vmArgs, theApp);
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   168
                createAnotherToAttach(instanceKlassNames,
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   169
                                      (int)theApp.getPid());
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   170
            } finally {
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   171
                LingeredApp.stopApp(theApp);
4597fa06b227 8162504: TestInstanceKlassSize.java and TestInstanceKlassSizeForInterface.java fail on Mac OS
jgeorge
parents: 42646
diff changeset
   172
            }
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   173
        } else {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   174
            SAInstanceKlassSize(Integer.parseInt(args[0]), instanceKlassNames);
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   175
        }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   176
    }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   177
}