annotate test/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java @ 24231:18ae50e05080 jvmci-0.35

HotSpotResolvedJavaMethod.setNotInlineable() should be renamed to represent actual behavior (JDK-8180487)
author Doug Simon <doug.simon@oracle.com>
date Thu, 14 Sep 2017 13:00:31 +0200
parents 8641949eb21f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23487
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
1 /*
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
4 *
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
7 * published by the Free Software Foundation.
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
8 *
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
13 * accompanied this code).
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
14 *
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
18 *
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
21 * questions.
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
22 */
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
23
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
24 /*
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
25 * @test TestExitOnOutOfMemoryError
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
26 * @summary Test using -XX:ExitOnOutOfMemoryError
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
27 * @library /testlibrary
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
28 * @build jdk.test.lib.*
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
29 * @run driver TestExitOnOutOfMemoryError
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
30 * @bug 8138745
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
31 */
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
32
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
33 import com.oracle.java.testlibrary.ProcessTools;
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
34 import com.oracle.java.testlibrary.OutputAnalyzer;
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
35
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
36 public class TestExitOnOutOfMemoryError {
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
37
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
38 public static void main(String[] args) throws Exception {
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
39 if (args.length == 1) {
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
40 // This should guarantee to throw:
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
41 // java.lang.OutOfMemoryError: Requested array size exceeds VM limit
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
42 try {
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
43 Object[] oa = new Object[Integer.MAX_VALUE];
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
44 throw new Error("OOME not triggered");
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
45 } catch (OutOfMemoryError err) {
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
46 throw new Error("OOME didn't terminate JVM!");
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
47 }
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
48 }
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
49
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
50 // else this is the main test
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
51 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+ExitOnOutOfMemoryError",
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
52 "-Xmx64m", TestExitOnOutOfMemoryError.class.getName(), "throwOOME");
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
53 OutputAnalyzer output = new OutputAnalyzer(pb.start());
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
54
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
55 /*
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
56 * Actual output should look like this:
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
57 * Terminating due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
58 */
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
59 output.shouldHaveExitValue(3);
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
60 output.shouldContain("Terminating due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit");
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
61 System.out.println("PASSED");
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
62 }
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
63 }