Skip to content

Commit e89b42f

Browse files
committed
Java: Allow dispatch to methods on abstract classes without subtypes.
1 parent 6e7dcfc commit e89b42f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

java/ql/lib/semmle/code/java/dispatch/VirtualDispatch.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,14 @@ private module Dispatch {
211211
exists(Method m | t.hasMethod(m, _, _) and impl = m.getSourceDeclaration())
212212
}
213213

214+
private predicate isAbstractWithSubclass(SrcRefType t) {
215+
t.isAbstract() and exists(Class c | c.getASourceSupertype() = t)
216+
}
217+
214218
private predicate hasViableSubtype(RefType t, SrcRefType sub) {
215219
sub.extendsOrImplements*(t) and
216220
not sub instanceof Interface and
217-
not sub.isAbstract()
221+
not isAbstractWithSubclass(sub)
218222
}
219223
}
220224

0 commit comments

Comments
 (0)