001 /* Compiler.java -- placeholder for Java-to-native runtime compilers 002 Copyright (C) 1998, 1999, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. 003 004 This file is part of GNU Classpath. 005 006 GNU Classpath is free software; you can redistribute it and/or modify 007 it under the terms of the GNU General Public License as published by 008 the Free Software Foundation; either version 2, or (at your option) 009 any later version. 010 011 GNU Classpath is distributed in the hope that it will be useful, but 012 WITHOUT ANY WARRANTY; without even the implied warranty of 013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 General Public License for more details. 015 016 You should have received a copy of the GNU General Public License 017 along with GNU Classpath; see the file COPYING. If not, write to the 018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 019 02110-1301 USA. 020 021 Linking this library statically or dynamically with other modules is 022 making a combined work based on this library. Thus, the terms and 023 conditions of the GNU General Public License cover the whole 024 combination. 025 026 As a special exception, the copyright holders of this library give you 027 permission to link this library with independent modules to produce an 028 executable, regardless of the license terms of these independent 029 modules, and to copy and distribute the resulting executable under 030 terms of your choice, provided that you also meet, for each linked 031 independent module, the terms and conditions of the license of that 032 module. An independent module is a module which is not derived from 033 or based on this library. If you modify this library, you may extend 034 this exception to your version of the library, but you are not 035 obligated to do so. If you do not wish to do so, delete this 036 exception statement from your version. */ 037 038 039 package java.lang; 040 041 /** 042 * The <code>Compiler</code> class is a placeholder for a JIT compiler 043 * implementation, and does nothing unless there is such a compiler. 044 * 045 * <p>The system property <code>java.compiler</code> may contain the name 046 * of a library to load with <code>System.loadLibrary</code> when the 047 * virtual machine first starts. If so, and loading the library succeeds, 048 * then a function by the name of <code>java_lang_Compiler_start()</code> 049 * in that library is called. 050 * 051 * <p>Note that a VM might not have implemented any of this. 052 * 053 * @author Tom Tromey (tromey@cygnus.com) 054 * @see System#getProperty(String) 055 * @see System#getProperty(String, String) 056 * @see System#loadLibrary(String) 057 * @since JDK 1.0 058 * @status updated to 1.4 059 */ 060 public final class Compiler 061 { 062 /** 063 * Don't allow new `Compiler's to be made. 064 */ 065 private Compiler() 066 { 067 } 068 069 /** 070 * Compile the class named by <code>oneClass</code>. 071 * 072 * @param oneClass the class to compile 073 * @return <code>false</code> if no compiler is available or 074 * compilation failed, <code>true</code> if compilation succeeded 075 * @throws NullPointerException if oneClass is null 076 */ 077 public static boolean compileClass(Class<?> oneClass) 078 { 079 return VMCompiler.compileClass(oneClass); 080 } 081 082 /** 083 * Compile the classes whose name matches <code>classNames</code>. 084 * 085 * @param classNames the name of classes to compile 086 * @return <code>false</code> if no compiler is available or 087 * compilation failed, <code>true</code> if compilation succeeded 088 * @throws NullPointerException if classNames is null 089 */ 090 public static boolean compileClasses(String classNames) 091 { 092 return VMCompiler.compileClasses(classNames); 093 } 094 095 /** 096 * This method examines the argument and performs an operation 097 * according to the compilers documentation. No specific operation 098 * is required. 099 * 100 * @param arg a compiler-specific argument 101 * @return a compiler-specific value, including null 102 * @throws NullPointerException if the compiler doesn't like a null arg 103 */ 104 public static Object command(Object arg) 105 { 106 return VMCompiler.command(arg); 107 } 108 109 /** 110 * Calling <code>Compiler.enable()</code> will cause the compiler 111 * to resume operation if it was previously disabled; provided that a 112 * compiler even exists. 113 */ 114 public static void enable() 115 { 116 VMCompiler.enable(); 117 } 118 119 /** 120 * Calling <code>Compiler.disable()</code> will cause the compiler 121 * to be suspended; provided that a compiler even exists. 122 */ 123 public static void disable() 124 { 125 VMCompiler.disable(); 126 } 127 }