아이템 74 메서드가 던지는 모든 예외를 문서화하라
Effective Java 3e 아이템 74를 요약한 내용 입니다.
Last updated
/**
*
* @return secondField
* @throws NullPointerException if parameter is null or empty 비검사예외
* @throws IllegalAccessError if someone access 검사예외
*/
public int getSecondField() throws IllegalAccessError {
return secondField;
}public class Util {
/**
* @throws NullPointerException
* @throws IndexOutofBoundsException
*/
public static void capture() {
...
}
}
public class Client {
/**
* @throws NullPointerException
*/
public void execute() {
...
Util.capture();
}
/**
* @throws NullPointerException
* @throws IndexOutofBoundsException
*/
public void test() {
...
Util.capture();
}
}
/**
*
* @throws IllegalAccessError
*/
public class Test {
public void add() throws IllegalAccessError {
...
}
public void minus() throws IllegalAccessError {
...
}