简体   繁体   English

Java:Enerjy-未检查的异常?

[英]Java: Enerjy - Unchecked Exception?

Enerjy has a problem with this line of code: Enerjy在以下代码行中有问题:

private static List<ParseTree> getTestTrees(Xml test) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {

This is the warning: 这是警告:

(Baseline) JAVA0126 Method 'getTestTrees' declares unchecked exception 'IllegalArgumentException' in throws

How can I fix this? 我怎样才能解决这个问题? What is the problem? 问题是什么? What does it mean for an exception to be "unchecked"? “取消检查”异常是什么意思?

"Unchecked" exceptions (also known as runtime exceptions ) are those that the compiler does not force you to catch. “未检查的”异常(也称为运行时异常 )是编译器不会强迫您捕获的那些异常 For example, imagine if you had to declare and catch NullPointerException everywhere it might occur. 例如,假设您必须在可能发生的所有地方声明并捕获NullPointerException These are the types of exceptions that, if they occur, the assumption is your program likely can't recover anyway. 这些类型的异常,如果发生,则假定您的程序可能仍然无法恢复。

The compiler is telling you to remove IllegalArgumentException from the throws clause of your method. 编译器告诉您从方法的throws子句中删除IllegalArgumentException

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM