author | lana |
Thu, 23 Feb 2017 17:30:12 +0000 | |
changeset 44011 | 5eea3031ae7b |
parent 43467 | f91da24c6bca |
permissions | -rw-r--r-- |
24659
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
1 |
/* |
43467 | 2 |
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. |
24659
a1482c33e323
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. |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
4 |
* |
a1482c33e323
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 |
a1482c33e323
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 |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
8 |
* |
a1482c33e323
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 |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a1482c33e323
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 |
a1482c33e323
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 |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
13 |
* accompanied this code). |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
14 |
* |
a1482c33e323
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 |
a1482c33e323
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, |
a1482c33e323
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. |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
18 |
* |
a1482c33e323
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 |
a1482c33e323
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 |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
21 |
* questions. |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
22 |
*/ |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
23 |
import java.io.PrintWriter; |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
24 |
import jdk.test.lib.JDKToolFinder; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
25 |
import jdk.test.lib.Platform; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
26 |
import jdk.test.lib.process.OutputAnalyzer; |
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
27 |
import jdk.test.lib.process.ProcessTools; |
24659
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
28 |
|
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
29 |
/* |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
30 |
* Test to verify GetObjectSize does not overflow on a 600M element int[] |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
31 |
* |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
32 |
* @test |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
33 |
* @bug 8027230 |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
34 |
* @library /test/lib |
36851 | 35 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
24835
diff
changeset
|
36 |
* java.compiler |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
24835
diff
changeset
|
37 |
* java.instrument |
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
24835
diff
changeset
|
38 |
* java.management |
43467 | 39 |
* jdk.internal.jvmstat/sun.jvmstat.monitor |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
36851
diff
changeset
|
40 |
* @build GetObjectSizeOverflowAgent |
24659
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
41 |
* @run main ClassFileInstaller GetObjectSizeOverflowAgent |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
42 |
* @run main GetObjectSizeOverflow |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
43 |
*/ |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
44 |
public class GetObjectSizeOverflow { |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
45 |
public static void main(String[] args) throws Exception { |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
46 |
|
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
47 |
if (!Platform.is64bit()) { |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
48 |
System.out.println("Test needs a 4GB heap and can only be run as a 64bit process, skipping."); |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
49 |
return; |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
50 |
} |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
51 |
|
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
52 |
PrintWriter pw = new PrintWriter("MANIFEST.MF"); |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
53 |
pw.println("Premain-Class: GetObjectSizeOverflowAgent"); |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
54 |
pw.close(); |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
55 |
|
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
56 |
ProcessBuilder pb = new ProcessBuilder(); |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
57 |
pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", "agent.jar", "GetObjectSizeOverflowAgent.class"}); |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
58 |
pb.start().waitFor(); |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
59 |
|
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
60 |
ProcessBuilder pt = ProcessTools.createJavaProcessBuilder(true, "-Xmx4000m", "-javaagent:agent.jar", "GetObjectSizeOverflowAgent"); |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
61 |
OutputAnalyzer output = new OutputAnalyzer(pt.start()); |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
62 |
|
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
63 |
if (output.getStdout().contains("Could not reserve enough space") || output.getStderr().contains("java.lang.OutOfMemoryError")) { |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
64 |
System.out.println("stdout: " + output.getStdout()); |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
65 |
System.out.println("stderr: " + output.getStderr()); |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
66 |
System.out.println("Test could not reserve or allocate enough space, skipping"); |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
67 |
return; |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
68 |
} |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
69 |
|
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
70 |
output.stdoutShouldContain("GetObjectSizeOverflow passed"); |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
71 |
} |
a1482c33e323
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
72 |
} |