Mercurial > hg > truffle
annotate test/serviceability/jvmti/GetObjectSizeOverflow.java @ 21300:07c22c0ab91e
Truffle/Instrumentation: clean up minor issues in the new "ToolEval" instrument kind.
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Mon, 11 May 2015 18:43:12 -0700 |
parents | 09f19d3de485 |
children |
rev | line source |
---|---|
17946
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
1 /* |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
2 * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
4 * |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
8 * |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
13 * accompanied this code). |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
14 * |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
18 * |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
21 * questions. |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
22 */ |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
23 import java.io.PrintWriter; |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
24 import com.oracle.java.testlibrary.*; |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
25 |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
26 /* |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
27 * Test to verify GetObjectSize does not overflow on a 600M element int[] |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
28 * |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
29 * @test |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
30 * @bug 8027230 |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
31 * @library /testlibrary |
17974
09f19d3de485
8043915: Tests get ClassNotFoundException: com.oracle.java.testlibrary.StreamPumper
ykantser
parents:
17946
diff
changeset
|
32 * @build ClassFileInstaller com.oracle.java.testlibrary.* GetObjectSizeOverflowAgent |
17946
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
33 * @run main ClassFileInstaller GetObjectSizeOverflowAgent |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
34 * @run main GetObjectSizeOverflow |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
35 */ |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
36 public class GetObjectSizeOverflow { |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
37 public static void main(String[] args) throws Exception { |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
38 |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
39 if (!Platform.is64bit()) { |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
40 System.out.println("Test needs a 4GB heap and can only be run as a 64bit process, skipping."); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
41 return; |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
42 } |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
43 |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
44 PrintWriter pw = new PrintWriter("MANIFEST.MF"); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
45 pw.println("Premain-Class: GetObjectSizeOverflowAgent"); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
46 pw.close(); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
47 |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
48 ProcessBuilder pb = new ProcessBuilder(); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
49 pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", "agent.jar", "GetObjectSizeOverflowAgent.class"}); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
50 pb.start().waitFor(); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
51 |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
52 ProcessBuilder pt = ProcessTools.createJavaProcessBuilder(true, "-Xmx4000m", "-javaagent:agent.jar", "GetObjectSizeOverflowAgent"); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
53 OutputAnalyzer output = new OutputAnalyzer(pt.start()); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
54 |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
55 if (output.getStdout().contains("Could not reserve enough space") || output.getStderr().contains("java.lang.OutOfMemoryError")) { |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
56 System.out.println("stdout: " + output.getStdout()); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
57 System.out.println("stderr: " + output.getStderr()); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
58 System.out.println("Test could not reserve or allocate enough space, skipping"); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
59 return; |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
60 } |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
61 |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
62 output.stdoutShouldContain("GetObjectSizeOverflow passed"); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
63 } |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
64 } |