Skip to content

Commit 2deb3e5

Browse files
committed
Reapply "Java: Fix cartesian product"
This reverts commit c1654ce.
1 parent 281e49d commit 2deb3e5

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

java/ql/src/Advisory/Documentation/ImpossibleJavadocThrows.ql

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,14 @@ RefType getTaggedType(ThrowsTag tag) {
1616
exists(ImportType i | i.getFile() = tag.getFile() | i.getImportedType() = result)
1717
}
1818

19-
predicate canThrow(Callable callable, RefType exception) {
20-
exists(string uncheckedException |
21-
uncheckedException = "RuntimeException" or uncheckedException = "Error"
22-
|
23-
exception.getAnAncestor().hasQualifiedName("java.lang", uncheckedException)
24-
)
25-
or
26-
callable.getAnException().getType().getADescendant() = exception
27-
}
28-
29-
from ThrowsTag throwsTag, RefType thrownType, Callable docMethod
19+
// Uses ClassOrInterface as type for thrownType to also cover case where erroneously an interface
20+
// type is declared as thrown exception
21+
from ThrowsTag throwsTag, ClassOrInterface thrownType, Callable docMethod
3022
where
3123
getTaggedType(throwsTag) = thrownType and
3224
docMethod.getDoc().getJavadoc().getAChild*() = throwsTag and
33-
not canThrow(docMethod, thrownType)
25+
not thrownType instanceof UncheckedThrowableType and
26+
not docMethod.getAnException().getType().getADescendant() = thrownType
3427
select throwsTag,
3528
"Javadoc for " + docMethod + " claims to throw " + thrownType.getName() +
3629
" but this is impossible."

0 commit comments

Comments
 (0)