Java.lang.Compiler类

java.lang.Compiler.disable() 用于导致编译器停止运行。

语法

public static void disable()

参数

不需要参数。

返回值

void 类型。

异常

无。

示例:

在下面的示例中,java.lang. Compiler.disable()方法用于使编译器停止运行。

public class MyClass {
  public static void main(String[] args) {
    
    //检查编译器是否开启
    Compiler.enable();
    System.out.println("Compiler is enabled using enable() method.");

    Compiler.command("{java.lang.Byte.*} (compile)");
    
    //创建字节对象
    Byte b = new Byte("25");

    //打印b的hashCode
    System.out.println("hashCode of b is: " + b.hashCode());   

    //禁用编译器
    Compiler.disable();
  }
}

上述代码的输出将是:

Compiler is enabled using enable() method.
hashCode of b is: 25