Skip to content

Commit 6dd14a6

Browse files
committed
Java: Fix reflection predicate for getMethod having non-public method result
1 parent 3119885 commit 6dd14a6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

java/ql/lib/semmle/code/java/Reflection.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,11 @@ class ReflectiveMethodAccess extends ClassMethodAccess {
355355
then
356356
// The method must be declared on the type itself.
357357
result.getDeclaringType() = this.getInferredClassType()
358-
else
359-
// The method may be declared on an inferred type or a super-type.
358+
else (
359+
// The method must be public, and declared or inherited by the inferred class type.
360+
result.isPublic() and
360361
this.getInferredClassType().inherits(result)
362+
)
361363
) and
362364
// Only consider instances where the method name is provided as a `StringLiteral`.
363365
result.hasName(this.getArgument(0).(StringLiteral).getValue())

0 commit comments

Comments
 (0)