catch 블록 매개변수로의 대입을 보고합니다.

catch 블록 매개변수를 변경하면 매우 혼동될 수 있어 권장하지 않습니다.

빠른 수정에서는 새로운 변수 선언을 추가합니다.

예:


  void processFile(String fileName) throws Exception {
    try {
      doProcessFile(fileName);
    } catch(Exception ex) {
      if (ex instanceof UncheckedIOException) {
        // Warning: catch block parameter reassigned
        ex = ((UncheckedIOException) ex).getCause();
      }
      throw ex;
    }
  }

빠른 수정을 적용한 후:


  void processFile(String fileName) throws Exception {
    try {
      doProcessFile(fileName);
    } catch(Exception ex) {
      Exception unwrapped = ex;
      if (unwrapped instanceof UncheckedIOException) {
        unwrapped = ((UncheckedIOException)
          unwrapped).getCause();
      }
      throw unwrapped;
    }
  }