test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeClass.java
author ihse
Tue, 20 Feb 2018 21:47:54 +0100
changeset 48923 b75c9e2e3b1f
parent 48791 6e079ff6c83c
permissions -rw-r--r--
8198450: Make jdk.internal.vm.compiler/module-info.java.extra reproducable Reviewed-by: erikj, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39207
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
     1
/*
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
     4
 *
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
     8
 *
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    13
 * accompanied this code).
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    14
 *
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    18
 *
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    21
 * questions.
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    22
 */
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    23
import java.io.PrintWriter;
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39207
diff changeset
    24
import jdk.test.lib.JDKToolFinder;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39207
diff changeset
    25
import jdk.test.lib.process.OutputAnalyzer;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39207
diff changeset
    26
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39207
diff changeset
    27
39207
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    28
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    29
/*
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    30
 * @test
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    31
 * @bug 8075030
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    32
 * @summary JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39207
diff changeset
    33
 * @library /test/lib
39207
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    34
 * @modules java.base/jdk.internal.misc
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    35
 *          java.compiler
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    36
 *          java.instrument
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    37
 *          java.management
43467
f91da24c6bca 8152206: Simplify jvmstat modules
gtriantafill
parents: 40631
diff changeset
    38
 *          jdk.internal.jvmstat/sun.jvmstat.monitor
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 39207
diff changeset
    39
 * @build GetObjectSizeClassAgent
48791
6e079ff6c83c 8186635: ClassFileInstaller should be run as a driver
iignatyev
parents: 47216
diff changeset
    40
 * @run driver ClassFileInstaller GetObjectSizeClassAgent
39207
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    41
 * @run main GetObjectSizeClass
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    42
 */
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    43
public class GetObjectSizeClass {
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    44
    public static void main(String[] args) throws Exception  {
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    45
        PrintWriter pw = new PrintWriter("MANIFEST.MF");
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    46
        pw.println("Premain-Class: GetObjectSizeClassAgent");
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    47
        pw.close();
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    48
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    49
        ProcessBuilder pb = new ProcessBuilder();
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    50
        pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", "agent.jar", "GetObjectSizeClassAgent.class"});
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    51
        pb.start().waitFor();
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    52
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    53
        ProcessBuilder pt = ProcessTools.createJavaProcessBuilder(true, "-javaagent:agent.jar",  "GetObjectSizeClassAgent");
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    54
        OutputAnalyzer output = new OutputAnalyzer(pt.start());
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    55
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    56
        output.stdoutShouldContain("GetObjectSizeClass passed");
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    57
    }
5c6e88667985 8075030: JvmtiEnv::GetObjectSize reports incorrect java.lang.Class instance size
shade
parents:
diff changeset
    58
}