ExceptionUtils { public static boolean isUncheckedException(@Nullable Type exceptionType) { if (exceptionType == null) { return false; } return exceptionType.isSubtypeOf("java.lang.RuntimeException") || exceptionType.isSubtypeOf("java.lang.Error") || exceptionType.is("java.lang.Exception") || exceptionType.is("java.lang.Throwable"); } private  ExceptionUtils(); static boolean isUncheckedException(@Nullable Type exceptionType);  }
@Test void test_is_unchecked_exception() { assertThat(ExceptionUtils.isUncheckedException(null)).isFalse(); assertThat(ExceptionUtils.isUncheckedException(Symbols.unknownType)).isFalse(); Sema semanticModel = SETestUtils.getSemanticModel("src/test/java/org/sonar/java/se/ExceptionUtilsTest.java"); Type ex = semanticModel.getClassType("java.lang.IllegalArgumentException"); assertThat(ExceptionUtils.isUncheckedException(ex)).isTrue(); ex = semanticModel.getClassType("java.lang.Exception"); assertThat(ExceptionUtils.isUncheckedException(ex)).isTrue(); ex = semanticModel.getClassType("java.lang.Throwable"); assertThat(ExceptionUtils.isUncheckedException(ex)).isTrue(); }