From 312465ce31605328f3cadc5271107ac40f256742 Mon Sep 17 00:00:00 2001 From: liyiwei <979621500@qq.com> Date: Tue, 10 Oct 2023 22:47:38 +0800 Subject: [PATCH] unify conditions --- .../typehierarchy/MethodDispatchResolver.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/sootup.core/src/main/java/sootup/core/typehierarchy/MethodDispatchResolver.java b/sootup.core/src/main/java/sootup/core/typehierarchy/MethodDispatchResolver.java index 11f83a7e73e..ff6f94fb36d 100644 --- a/sootup.core/src/main/java/sootup/core/typehierarchy/MethodDispatchResolver.java +++ b/sootup.core/src/main/java/sootup/core/typehierarchy/MethodDispatchResolver.java @@ -201,20 +201,21 @@ public static Optional resolveConcreteDispatch( List> classesInHierarchyOrder = findSuperClassesInclusive(view, current); for (SootClass currentClass : classesInHierarchyOrder) { - SootMethod concreteMethod = currentClass.getMethod(m.getSubSignature()).orElse(null); - if (concreteMethod != null && !concreteMethod.isAbstract()) { - // found method is not abstract - return Optional.of(concreteMethod.getSignature()); - } - if (concreteMethod != null && concreteMethod.isAbstract()) { - if (startClass.isAbstract() - && !startClass.getType().equals(concreteMethod.getDeclaringClassType())) { - // A not implemented method of an abstract class results into an abstract method - return Optional.empty(); + SootMethod method = currentClass.getMethod(m.getSubSignature()).orElse(null); + if (method != null) { + if (!method.isAbstract()) { + // found method is not abstract + return Optional.of(method.getSignature()); + } else { + if (startClass.isAbstract() + && !startClass.getType().equals(method.getDeclaringClassType())) { + // A not implemented method of an abstract class results into an abstract method + return Optional.empty(); + } + // found method is abstract and the startClass is not abstract + throw new ResolveException( + "Could not find concrete method for " + m + " because the method is abstract"); } - // found method is abstract and the startClass is not abstract - throw new ResolveException( - "Could not find concrete method for " + m + " because the method is abstract"); } }