Skip to content

Commit a858a8c

Browse files
committed
Java: Fix for private interface methods.
1 parent f952293 commit a858a8c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

java/ql/src/semmle/code/java/Member.qll

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,18 +361,23 @@ class Method extends Callable, @method {
361361
override MethodAccess getAReference() { result = Callable.super.getAReference() }
362362

363363
override predicate isPublic() {
364-
Callable.super.isPublic() or
365-
// JLS 9.4: Every method declaration in the body of an interface is implicitly public.
366-
getDeclaringType() instanceof Interface or
364+
Callable.super.isPublic()
365+
or
366+
// JLS 9.4: Every method declaration in the body of an interface without an
367+
// access modifier is implicitly public.
368+
getDeclaringType() instanceof Interface and
369+
not this.isPrivate()
370+
or
367371
exists(FunctionalExpr func | func.asMethod() = this)
368372
}
369373

370374
override predicate isAbstract() {
371375
Callable.super.isAbstract()
372376
or
373-
// JLS 9.4: An interface method lacking a `default` modifier or a `static` modifier
377+
// JLS 9.4: An interface method lacking a `private`, `default`, or `static` modifier
374378
// is implicitly abstract.
375379
this.getDeclaringType() instanceof Interface and
380+
not this.isPrivate() and
376381
not this.isDefault() and
377382
not this.isStatic()
378383
}

0 commit comments

Comments
 (0)