NetBeans 运行 Java 程序时出现编译时错误
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 中时,在收到错误通知并单击 "Run Anyway" 程序 运行s 并输出 "PASS" 之后。当条件失败时(当 args > 0 时),程序抛出 RuntimeException:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - not a statement
NetNeans 如何运行 无法编译代码?它是 运行 解释器/JIT 编译器还是类似的东西?
这是我以前不记得的新功能吗?
正如@ElliottFrisch 评论的那样,NetBeans 删除了 unreachable/uncompilable 代码并将其替换为 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");
}
}
由于 else 子句中的错误,以下 Java 程序无法编译。
public class Temp1 {
public static void main(String[] args) {
if (args.length == 0)
{
System.out.println("PASS");
}
else{
COMPILEERROR
}
}
}
然而,当 运行 在 NetBeans 中时,在收到错误通知并单击 "Run Anyway" 程序 运行s 并输出 "PASS" 之后。当条件失败时(当 args > 0 时),程序抛出 RuntimeException:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - not a statement
NetNeans 如何运行 无法编译代码?它是 运行 解释器/JIT 编译器还是类似的东西?
这是我以前不记得的新功能吗?
正如@ElliottFrisch 评论的那样,NetBeans 删除了 unreachable/uncompilable 代码并将其替换为 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");
}
}