Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/jcl/src/java.base/share/classes/java/lang/Compiler.java
12513 views
1
/*[INCLUDE-IF Sidecar16]*/
2
package java.lang;
3
4
/*******************************************************************************
5
* Copyright (c) 1998, 2019 IBM Corp. and others
6
*
7
* This program and the accompanying materials are made available under
8
* the terms of the Eclipse Public License 2.0 which accompanies this
9
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
10
* or the Apache License, Version 2.0 which accompanies this distribution and
11
* is available at https://www.apache.org/licenses/LICENSE-2.0.
12
*
13
* This Source Code may also be made available under the following
14
* Secondary Licenses when the conditions for such availability set
15
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
16
* General Public License, version 2 with the GNU Classpath
17
* Exception [1] and GNU General Public License, version 2 with the
18
* OpenJDK Assembly Exception [2].
19
*
20
* [1] https://www.gnu.org/software/classpath/license.html
21
* [2] http://openjdk.java.net/legal/assembly-exception.html
22
*
23
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
24
*******************************************************************************/
25
26
/**
27
* This class is a placeholder for environments which
28
* explicitly manage the action of a "Just In Time"
29
* compiler.
30
*
31
* @author OTI
32
* @version initial
33
*
34
* @see Cloneable
35
*/
36
/*[IF Sidecar19-SE]*/
37
@Deprecated(forRemoval=true, since="9")
38
/*[ENDIF]*/
39
public final class Compiler {
40
41
private Compiler() {}
42
43
/**
44
* Low level interface to the JIT compiler. Can return
45
* any object, or null if no JIT compiler is available.
46
*
47
* @author OTI
48
* @version initial
49
*
50
* @return Object
51
* result of executing command
52
* @param cmd Object
53
* a command for the JIT compiler
54
*/
55
public static Object command(Object cmd) {
56
if (cmd == null) {
57
throw new NullPointerException();
58
}
59
return commandImpl(cmd);
60
}
61
62
private static native Object commandImpl(Object cmd);
63
64
/**
65
* Compiles the class using the JIT compiler. Answers
66
* true if the compilation was successful, or false if
67
* it failed or there was no JIT compiler available.
68
*
69
* @return boolean
70
* indicating compilation success
71
* @param classToCompile java.lang.Class
72
* the class to JIT compile
73
*/
74
public static boolean compileClass(Class<?> classToCompile) {
75
if (classToCompile == null) {
76
throw new NullPointerException();
77
}
78
return compileClassImpl(classToCompile);
79
}
80
81
private static native boolean compileClassImpl(Class classToCompile);
82
83
/**
84
* Compiles all classes whose name matches the argument
85
* using the JIT compiler. Answers true if the compilation
86
* was successful, or false if it failed or there was no
87
* JIT compiler available.
88
*
89
* @return boolean
90
* indicating compilation success
91
* @param nameRoot String
92
* the string to match against class names
93
*/
94
public static boolean compileClasses(String nameRoot) {
95
if (nameRoot == null) {
96
throw new NullPointerException();
97
}
98
return compileClassesImpl(nameRoot);
99
}
100
101
private static native boolean compileClassesImpl(String nameRoot);
102
103
/**
104
* Disable the JIT compiler
105
*/
106
public static native void disable();
107
108
/**
109
* Enable the JIT compiler
110
*/
111
public static native void enable();
112
}
113
114