File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
java/ql/lib/semmle/code/java Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -347,12 +347,28 @@ private module ControlFlowGraphImpl {
347347 )
348348 }
349349
350+ private predicate methodMayThrow ( Method m , ThrowableType t ) {
351+ exists ( AstNode n |
352+ t = n .( ThrowStmt ) .getThrownExceptionType ( ) and
353+ not n .( ThrowStmt ) .getParent ( ) = any ( Method m0 ) .getBody ( )
354+ or
355+ uncheckedExceptionFromMethod ( n , t )
356+ |
357+ n .getEnclosingStmt ( ) .getEnclosingCallable ( ) = m and
358+ not exists ( TryStmt try |
359+ exists ( try .getACatchClause ( ) ) and try .getBlock ( ) = n .getEnclosingStmt ( ) .getEnclosingStmt * ( )
360+ )
361+ )
362+ }
363+
350364 /**
351- * Bind `t` to an unchecked exception that may occur in a precondition check.
365+ * Bind `t` to an unchecked exception that may occur in a precondition check or guard wrapper .
352366 */
353367 private predicate uncheckedExceptionFromMethod ( MethodCall ma , ThrowableType t ) {
354368 conditionCheckArgument ( ma , _, _) and
355369 ( t instanceof TypeError or t instanceof TypeRuntimeException )
370+ or
371+ methodMayThrow ( ma .getMethod ( ) , t )
356372 }
357373
358374 /**
You can’t perform that action at this time.
0 commit comments