Path: blob/master/jcl/src/java.base/share/classes/java/lang/Compiler.java
12513 views
/*[INCLUDE-IF Sidecar16]*/1package java.lang;23/*******************************************************************************4* Copyright (c) 1998, 2019 IBM Corp. and others5*6* This program and the accompanying materials are made available under7* the terms of the Eclipse Public License 2.0 which accompanies this8* distribution and is available at https://www.eclipse.org/legal/epl-2.0/9* or the Apache License, Version 2.0 which accompanies this distribution and10* is available at https://www.apache.org/licenses/LICENSE-2.0.11*12* This Source Code may also be made available under the following13* Secondary Licenses when the conditions for such availability set14* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU15* General Public License, version 2 with the GNU Classpath16* Exception [1] and GNU General Public License, version 2 with the17* OpenJDK Assembly Exception [2].18*19* [1] https://www.gnu.org/software/classpath/license.html20* [2] http://openjdk.java.net/legal/assembly-exception.html21*22* 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-exception23*******************************************************************************/2425/**26* This class is a placeholder for environments which27* explicitly manage the action of a "Just In Time"28* compiler.29*30* @author OTI31* @version initial32*33* @see Cloneable34*/35/*[IF Sidecar19-SE]*/36@Deprecated(forRemoval=true, since="9")37/*[ENDIF]*/38public final class Compiler {3940private Compiler() {}4142/**43* Low level interface to the JIT compiler. Can return44* any object, or null if no JIT compiler is available.45*46* @author OTI47* @version initial48*49* @return Object50* result of executing command51* @param cmd Object52* a command for the JIT compiler53*/54public static Object command(Object cmd) {55if (cmd == null) {56throw new NullPointerException();57}58return commandImpl(cmd);59}6061private static native Object commandImpl(Object cmd);6263/**64* Compiles the class using the JIT compiler. Answers65* true if the compilation was successful, or false if66* it failed or there was no JIT compiler available.67*68* @return boolean69* indicating compilation success70* @param classToCompile java.lang.Class71* the class to JIT compile72*/73public static boolean compileClass(Class<?> classToCompile) {74if (classToCompile == null) {75throw new NullPointerException();76}77return compileClassImpl(classToCompile);78}7980private static native boolean compileClassImpl(Class classToCompile);8182/**83* Compiles all classes whose name matches the argument84* using the JIT compiler. Answers true if the compilation85* was successful, or false if it failed or there was no86* JIT compiler available.87*88* @return boolean89* indicating compilation success90* @param nameRoot String91* the string to match against class names92*/93public static boolean compileClasses(String nameRoot) {94if (nameRoot == null) {95throw new NullPointerException();96}97return compileClassesImpl(nameRoot);98}99100private static native boolean compileClassesImpl(String nameRoot);101102/**103* Disable the JIT compiler104*/105public static native void disable();106107/**108* Enable the JIT compiler109*/110public static native void enable();111}112113114