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 {
347
347
)
348
348
}
349
349
350
+ private predicate methodMayThrow ( Method m , ThrowableType t ) {
351
+ exists ( AstNode n |
352
+ t = n .( ThrowStmt ) .getThrownExceptionType ( ) and
353
+ not n .( ThrowStmt ) .getParent ( ) .( BlockStmt ) = 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
+
350
364
/**
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 .
352
366
*/
353
367
private predicate uncheckedExceptionFromMethod ( MethodCall ma , ThrowableType t ) {
354
368
conditionCheckArgument ( ma , _, _) and
355
369
( t instanceof TypeError or t instanceof TypeRuntimeException )
370
+ or
371
+ methodMayThrow ( ma .getMethod ( ) , t )
356
372
}
357
373
358
374
/**
You can’t perform that action at this time.
0 commit comments