Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/runtime/ClassFile/JsrRewriting.java
40942 views
1
/*
2
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
25
26
/*
27
* @test JsrRewriting
28
* @summary JSR (jump local subroutine)
29
* rewriting can overflow memory address size variables
30
* @bug 7020373
31
* @bug 7055247
32
* @bug 7053586
33
* @bug 7185550
34
* @bug 7149464
35
* @library /test/lib
36
* @modules java.base/jdk.internal.misc
37
* java.desktop
38
* java.management
39
* @run driver JsrRewriting
40
*/
41
42
import jdk.test.lib.JDKToolFinder;
43
import jdk.test.lib.Platform;
44
import jdk.test.lib.process.ProcessTools;
45
import jdk.test.lib.process.OutputAnalyzer;
46
import java.io.File;
47
48
public class JsrRewriting {
49
50
public static void main(String[] args) throws Exception {
51
52
// ======= Configure the test
53
String jarFile = System.getProperty("test.src") +
54
File.separator + "JsrRewritingTestCase.jar";
55
String className = "OOMCrashClass4000_1";
56
57
// limit is 768MB in native words
58
int mallocMaxTestWords = (1024 * 1024 * 768 / 4);
59
if (Platform.is64bit())
60
mallocMaxTestWords = (mallocMaxTestWords / 2);
61
62
// ======= extract the test class
63
ProcessBuilder pb = new ProcessBuilder(new String[] {
64
JDKToolFinder.getJDKTool("jar"),
65
"xvf", jarFile } );
66
OutputAnalyzer output = new OutputAnalyzer(pb.start());
67
output.shouldHaveExitValue(0);
68
69
// ======= execute the test
70
pb = ProcessTools.createJavaProcessBuilder(
71
"-cp", ".",
72
"-XX:+UnlockDiagnosticVMOptions",
73
"-XX:MallocMaxTestWords=" + mallocMaxTestWords,
74
className);
75
76
output = new OutputAnalyzer(pb.start());
77
String[] expectedMsgs = {
78
"java.lang.LinkageError",
79
"java.lang.NoSuchMethodError",
80
"Main method not found in class " + className,
81
"insufficient memory"
82
};
83
84
MultipleOrMatch(output, expectedMsgs);
85
}
86
87
private static void
88
MultipleOrMatch(OutputAnalyzer analyzer, String[] whatToMatch) {
89
String output = analyzer.getOutput();
90
91
for (String expected : whatToMatch)
92
if (output.contains(expected))
93
return;
94
95
String err =
96
" stdout: [" + analyzer.getOutput() + "];\n" +
97
" exitValue = " + analyzer.getExitValue() + "\n";
98
System.err.println(err);
99
100
StringBuilder msg = new StringBuilder("Output did not contain " +
101
"any of the following expected messages: \n");
102
for (String expected : whatToMatch)
103
msg.append(expected).append(System.lineSeparator());
104
throw new RuntimeException(msg.toString());
105
}
106
}
107
108
109