[英]NetBeans runs a Java program with compile time errors
由于else子句中的错误,以下Java程序无法编译。
public class Temp1 {
public static void main(String[] args) {
if (args.length == 0)
{
System.out.println("PASS");
}
else{
COMPILEERROR
}
}
}
但是,在NetBeans中运行时,在收到错误通知并单击“仍然运行”后,程序将运行并输出“ PASS”。 当条件失败时(当args> 0时),程序将抛出RuntimeException:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - not a statement
NetNeans如何运行不可编译的代码? 它运行的是解释器/ JIT编译器还是类似的东西?
这是我以前不记得的一项新功能吗?
正如@ElliottFrisch所评论的那样,NetBeans删除了无法访问/无法编译的代码,并将其替换为throw
这是反编译的代码:
/*
* Decompiled with CFR 0_114.
*/
package temp1;
import java.io.PrintStream;
public class Temp1 {
public static void main(String[] args) {
if (args.length != 0) {
throw new RuntimeException("Uncompilable source code - not a statement");
}
System.out.println("PASS");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.