예외 생성자가 Throwable cause 인수도 취하는 Throwable.initCause() 호출을 보고합니다.

이 경우 initCause() 호출이 제거되고, 예외의 생성자 호출에 그 인수가 추가될 수 있습니다.

예:


  try {
      process();
  }
  catch (RuntimeException ex) {
    RuntimeException wrapper = new RuntimeException("Error while processing");
    wrapper.initCause(ex); // 불필요한 'Throwable.initCause()' 호출
    throw wrapper;
  }

원인 인수를 생성자로 전달하는 빠른 수정을 사용할 수 있습니다. 빠른 수정을 적용한 후:


  try {
      process();
  }
  catch (RuntimeException ex) {
    RuntimeException wrapper = new RuntimeException("Error while processing", ex);
    throw wrapper;
  }