hotspot/test/serviceability/sa/TestInstanceKlassSizeForInterface.java
author hseigel
Wed, 10 Aug 2016 15:48:04 -0700
changeset 40244 b3055c216762
parent 39999 82ece130a37b
child 40631 ed82623d7831
permissions -rw-r--r--
8136930: Simplify use of module-system options by custom launchers Reviewed-by: coleenp, lfoltan, mchung
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
/*
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
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
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    24
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
    25
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
    26
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
    27
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
    28
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    29
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
    30
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
    31
import jdk.test.lib.Platform;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    32
import jdk.test.lib.ProcessTools;
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.OutputAnalyzer;
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.Utils;
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.Asserts;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    36
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    37
/*
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    38
 * @test
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    39
 * @library /test/lib/share/classes
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    40
 * @library /testlibrary
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    41
 * @build jdk.test.lib.*
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    42
 * @build jdk.test.lib.apps.*
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    43
 * @modules java.base/jdk.internal.misc
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    44
 * @modules jdk.hotspot.agent
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    45
 * @modules jdk.hotspot.agent/sun.jvm.hotspot
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    46
 * @modules jdk.hotspot.agent/sun.jvm.hotspot.utilities
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    47
 * @modules jdk.hotspot.agent/sun.jvm.hotspot.oops
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    48
 * @compile -XDignore.symbol.file=true -Xmodule:jdk.hotspot.agent TestInstanceKlassSizeForInterface.java
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    49
 * @run main/othervm TestInstanceKlassSizeForInterface
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
interface Language {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    53
    static final long nbrOfWords = 99999;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    54
    public abstract long getNbrOfWords();
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    55
}
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    56
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    57
class ParselTongue implements Language {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    58
    public long getNbrOfWords() {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    59
      return nbrOfWords * 4;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    60
    }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    61
}
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
public class TestInstanceKlassSizeForInterface {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    64
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    65
    private static void SAInstanceKlassSize(int pid,
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    66
                                            String[] instanceKlassNames) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    67
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    68
        HotSpotAgent agent = new HotSpotAgent();
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    69
        try {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    70
            agent.attach((int)pid);
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    71
        }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    72
        catch (DebuggerException e) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    73
            System.out.println(e.getMessage());
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    74
            System.err.println("Unable to connect to process ID: " + pid);
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    75
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    76
            agent.detach();
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    77
            e.printStackTrace();
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
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    80
        for (String instanceKlassName : instanceKlassNames) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    81
            InstanceKlass iKlass = SystemDictionaryHelper.findInstanceKlass(
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    82
                                       instanceKlassName);
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    83
            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
    84
                               " is " + iKlass.getSize());
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    85
        }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    86
        agent.detach();
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    87
    }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    88
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    89
    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
    90
                                                   String instanceKlassName) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    91
        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
    92
            if (s.contains(instanceKlassName)) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    93
                String tokens[];
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    94
                System.out.println(s);
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    95
                tokens = s.split("\\s+");
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    96
                return tokens[3];
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
    97
            }
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
        return null;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   100
    }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   101
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   102
    private static void createAnotherToAttach(
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   103
                            String[] instanceKlassNames) throws Exception {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   104
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   105
        ProcessBuilder pb = new ProcessBuilder();
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   106
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   107
        // Grab the pid from the current java process and pass it
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   108
        String[] toolArgs = {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   109
            "-XX:+UnlockDiagnosticVMOptions",
40244
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 39999
diff changeset
   110
            "--add-modules=jdk.hotspot.agent",
b3055c216762 8136930: Simplify use of module-system options by custom launchers
hseigel
parents: 39999
diff changeset
   111
            "--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
   112
            "--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
   113
            "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
39999
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   114
            "TestInstanceKlassSizeForInterface",
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   115
            Long.toString(ProcessTools.getProcessId())
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   116
        };
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   117
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"),
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   120
                          Long.toString(ProcessTools.getProcessId()),
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
        // Start a new process to attach to the current process
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   127
        ProcessBuilder processBuilder = ProcessTools
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   128
                  .createJavaProcessBuilder(toolArgs);
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   129
        OutputAnalyzer SAOutput = ProcessTools.executeProcess(processBuilder);
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   130
        System.out.println(SAOutput.getOutput());
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   131
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   132
        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
   133
        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
   134
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   135
        // 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
   136
        for (String instanceKlassName : instanceKlassNames) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   137
            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
   138
            String jcmdInstanceKlassSize = getJcmdInstanceKlassSize(
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   139
                                                      jcmdOutput,
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   140
                                                      instanceKlassName);
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   141
            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
   142
                if (s.contains(instanceKlassName)) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   143
                   Asserts.assertTrue(
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   144
                      s.contains(jcmdInstanceKlassSize),
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   145
                      "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
   146
                      instanceKlassName + " does not match.");
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
            }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   149
        }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   150
    }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   151
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   152
    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
   153
        String[] instanceKlassNames = new String[] {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   154
                                          "Language",
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   155
                                          "ParselTongue",
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   156
                                          "TestInstanceKlassSizeForInterface$1"
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   157
                                      };
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   158
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   159
        if (!Platform.shouldSAAttach()) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   160
            System.out.println(
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   161
               "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
   162
            return;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   163
        }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   164
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   165
        if ( args == null || args.length == 0 ) {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   166
            ParselTongue lang = new ParselTongue();
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   167
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   168
            Language ventro = new Language() {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   169
                public long getNbrOfWords() {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   170
                    return nbrOfWords * 8;
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   171
                }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   172
            };
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   173
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   174
            // Not tested at this point. The test needs to be enhanced
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   175
            // later to test for the sizes of the Lambda MetaFactory
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   176
            // generated anonymous classes too. (After JDK-8160228 gets
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   177
            // fixed.)
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   178
            Runnable r2 = () -> System.out.println("Hello world!");
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   179
            r2.run();
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   180
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   181
            createAnotherToAttach(instanceKlassNames);
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   182
        } else {
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   183
            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
   184
        }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   185
    }
82ece130a37b 8145627: sun.jvm.hotspot.oops.InstanceKlass::getSize() returns the incorrect size and has no test
sspitsyn
parents:
diff changeset
   186
}