From c1654ce7cc1d57e80054827800a184b33c2ef68e Mon Sep 17 00:00:00 2001 From: Tony Torralba Date: Tue, 4 Oct 2022 10:56:32 +0200 Subject: [PATCH] Revert "Java: Fix cartesian product" --- .../Advisory/Documentation/ImpossibleJavadocThrows.ql | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/java/ql/src/Advisory/Documentation/ImpossibleJavadocThrows.ql b/java/ql/src/Advisory/Documentation/ImpossibleJavadocThrows.ql index 42fd2049289..3111c704b4d 100644 --- a/java/ql/src/Advisory/Documentation/ImpossibleJavadocThrows.ql +++ b/java/ql/src/Advisory/Documentation/ImpossibleJavadocThrows.ql @@ -16,14 +16,19 @@ ClassOrInterface getTaggedType(ThrowsTag tag) { result = tag.getFile().(CompilationUnit).getATypeInScope() } +predicate canThrow(Callable callable, Class exception) { + exception instanceof UncheckedThrowableType + or + callable.getAnException().getType().getADescendant() = exception +} + // Uses ClassOrInterface as type for thrownType to also cover case where erroneously an interface // type is declared as thrown exception from ThrowsTag throwsTag, ClassOrInterface thrownType, Callable docMethod where getTaggedType(throwsTag) = thrownType and docMethod.getDoc().getJavadoc().getAChild*() = throwsTag and - not thrownType instanceof UncheckedThrowableType and - not docMethod.getAnException().getType().getADescendant() = thrownType + not canThrow(docMethod, thrownType) select throwsTag, "Javadoc for " + docMethod + " claims to throw " + thrownType.getName() + " but this is impossible."