Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/runtime/InvocationTests/shared/Utils.java
40948 views
1
/*
2
* Copyright (c) 2009, 2019, 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
package shared;
26
27
import java.util.List;
28
29
/**
30
* Just a set of constants
31
*/
32
public class Utils {
33
public static final String TARGET_METHOD_NAME = "m";
34
public static int version = 50;
35
36
public static boolean isACC_SUPER = false;
37
38
public static void init(List<String> args) {
39
for (String param : args) {
40
String name = "classfile_version";
41
String pattern = "--"+name+"=";
42
if (param.startsWith(pattern)) {
43
String value = param.substring(pattern.length());
44
int majorVersion = 50;
45
int minorVersion = 0;
46
47
try {
48
String[] versions = value.split(":");
49
if (versions.length > 2) {
50
throw new RuntimeException(String.format("Unknown %s value: %s", name, value));
51
}
52
53
try {
54
majorVersion = Integer.parseInt(versions[0]);
55
if (versions.length > 1) {
56
minorVersion = Integer.parseInt(versions[1]);
57
}
58
} catch(Exception e) {
59
throw new RuntimeException(String.format("Can't parse %s value: '%s'", name, value));
60
}
61
} catch (Exception e) {
62
System.out.println("ERROR: "+e.getMessage());
63
}
64
65
version = majorVersion + (minorVersion << 16);
66
67
System.out.printf("INFO: Class file version: major: %d; minor: %d\n", majorVersion, minorVersion);
68
69
if (majorVersion < 49 && !args.contains("--no_acc_super")) {
70
isACC_SUPER = true;
71
System.out.printf("INFO: Enabling ACC_SUPER flag for major: %d\nTo disable it, specify --no_acc_super option.\n", majorVersion, minorVersion);
72
}
73
} else if (param.equals("--no_acc_super")){
74
System.out.println("INFO: ACC_SUPER flag is disabled");
75
isACC_SUPER = false;
76
} else if (param.equals("--acc_super")){
77
isACC_SUPER = true;
78
} else {
79
System.out.println("ERROR: Unknown option: "+param);
80
printHelp();
81
System.exit(1);
82
}
83
}
84
}
85
86
public static void printHelp() {
87
System.out.println(
88
"Supported parameters:\n"
89
+ "\t--classfile_version=major_version[:minor_version]\n"
90
+ "\t\t- specify class file version for generated classes\n"
91
+ "\t--no_acc_super\n"
92
+ "\t\t- don't add ACC_SUPER flag into generated classes\n"
93
+ "\t--acc_super\n"
94
+ "\t\t- force ACC_SUPER flag in generated classes\n"
95
+ "\t--dump\n"
96
+ "\t\t- dump generated classes\n"
97
+ "\t--noexecute\n"
98
+ "\t\t- print only expected results, don't execute tests\n"
99
);
100
}
101
102
/*******************************************************************/
103
public static String getInternalName(String s) {
104
return s.replaceAll("\\.", "/");
105
}
106
107
}
108
109