home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / lang / Compiler.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  3.4 KB  |  104 lines

  1. /*
  2.  * @(#)Compiler.java    1.8 98/03/18
  3.  *
  4.  * Copyright 1995-1997 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.lang;
  16.  
  17. /**
  18.  * The <code>Compiler</code> class is provided to support 
  19.  * Java-to-native-code compilers and related services. By design, the 
  20.  * <code>Compiler</code> class does nothing; it serves as a 
  21.  * placeholder for a JIT compiler implementation. 
  22.  * <p>
  23.  * When the Java Virtual Machine first starts, it determines if the 
  24.  * system property <code>java.compiler</code> exists. (System 
  25.  * properties are accessible through <code>getProperty</code>  and , 
  26.  * a method defined by the <code>System</code> class.) If so, it is 
  27.  * assumed to be the name of a library (with a platform-dependent 
  28.  * exact location and type); the <code>loadLibrary</code> method in 
  29.  * class <code>System</code> is called to load that library. If this 
  30.  * loading succeeds, the function named 
  31.  * <code>java_lang_Compiler_start()</code> in that library is called. 
  32.  * <p>
  33.  * If no compiler is available, these methods do nothing. 
  34.  *
  35.  * @author  Frank Yellin
  36.  * @version 1.8, 03/18/98
  37.  * @see     java.lang.System#getProperty(java.lang.String)
  38.  * @see     java.lang.System#getProperty(java.lang.String, java.lang.String)
  39.  * @see     java.lang.System#loadLibrary(java.lang.String)
  40.  * @since   JDK1.0
  41.  */
  42. public final class Compiler  {
  43.     private Compiler() {}        // don't make instances
  44.     
  45.     private static native void initialize();
  46.  
  47.     private static native void registerNatives();
  48.  
  49.     static { 
  50.         registerNatives();
  51.     String library = null;
  52.     try { 
  53.         library = System.getProperty("java.compiler");
  54.         if (library != null) {
  55.         System.loadLibrary(library);
  56.         initialize();
  57.         }
  58.     } catch (UnsatisfiedLinkError e) { 
  59.         System.err.println("Warning: JIT compiler \"" + library +
  60.            "\" not found. Will use interpreter.");
  61.     }
  62.     }
  63.  
  64.     /**
  65.      * Compiles the specified class. 
  66.      *
  67.      * @param   clazz   a class.
  68.      * @return  <code>true</code> if the compilation succeeded;
  69.      *          <code>false</code> if the compilation failed or no compiler
  70.      *          is available.
  71.      */
  72.     public static native boolean compileClass(Class clazz);
  73.  
  74.     /**
  75.      * Compiles all classes whose name matches the specified string. 
  76.      *
  77.      * @param   string   the name of the classes to compile.
  78.      * @return  <code>true</code> if the compilation succeeded;
  79.      *          <code>false</code> if the compilation failed or no compiler
  80.      *          is available.
  81.      */
  82.     public static native boolean compileClasses(String string);
  83.  
  84.     /**
  85.      * Examines the argument type and its fields and perform some documented
  86.      * operation. No specific operations are required. 
  87.      *
  88.      * @param   any   an argument.
  89.      * @return  a compiler-specific value, or <code>null</code> if no compiler
  90.      *          is available.
  91.      */
  92.     public static native Object command(Object any);
  93.  
  94.     /**
  95.      * Cause the Compiler to resume operation. 
  96.      */
  97.     public static native void enable();
  98.  
  99.     /**
  100.      * Cause the Compiler to cease operation. 
  101.      */
  102.     public static native void disable();
  103. }
  104.