From cb2895e742e136387b5858d015ddc07a1e587240 Mon Sep 17 00:00:00 2001 From: liyiwei <979621500@qq.com> Date: Fri, 27 Oct 2023 19:07:36 +0800 Subject: [PATCH 1/6] remove duplicated getDefaultValues --- .../src/main/java/sootup/java/core/JavaSootMethod.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/sootup.java.core/src/main/java/sootup/java/core/JavaSootMethod.java b/sootup.java.core/src/main/java/sootup/java/core/JavaSootMethod.java index 91adf47e72b..b9e84dc6b71 100644 --- a/sootup.java.core/src/main/java/sootup/java/core/JavaSootMethod.java +++ b/sootup.java.core/src/main/java/sootup/java/core/JavaSootMethod.java @@ -68,10 +68,7 @@ public boolean isStaticInitializer() { @Nonnull public Iterable getAnnotations(@Nonnull Optional view) { - annotations.forEach(e -> e.getAnnotation().getDefaultValues(view)); - resolveDefaultsForAnnotationTypes(view, annotations); - return annotations; } From 1938808334d7166ab0a02505e75409c9913b1e3f Mon Sep 17 00:00:00 2001 From: liyiwei <979621500@qq.com> Date: Fri, 27 Oct 2023 21:01:24 +0800 Subject: [PATCH 2/6] remove throw --- .../main/java/sootup/java/core/types/AnnotationType.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java b/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java index 632bfb2390f..cf3f8ae38a9 100644 --- a/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java +++ b/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java @@ -32,6 +32,8 @@ import java.util.stream.StreamSupport; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import sootup.core.IdentifierFactory; import sootup.core.model.SootMethod; import sootup.core.signatures.PackageName; @@ -48,6 +50,8 @@ */ public class AnnotationType extends JavaClassType { + private static final Logger log = LoggerFactory.getLogger(AnnotationType.class); + public void setInherited(boolean inherited) { isInherited = inherited; } @@ -75,7 +79,7 @@ public Map getDefaultValues(@Nonnull Optional viewOpti } if (!jv.getClass(this).isPresent()) { - throw new RuntimeException("Class of annotation not in view"); + log.error("Class of annotation not in view" + this); } JavaSootClass jsc = jv.getClass(this).get(); From 92de8453b544593ae9b2a76364aa4055e4465538 Mon Sep 17 00:00:00 2001 From: liyiwei <979621500@qq.com> Date: Fri, 27 Oct 2023 21:11:29 +0800 Subject: [PATCH 3/6] add return --- .../main/java/sootup/java/core/types/AnnotationType.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java b/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java index cf3f8ae38a9..9e1223e828c 100644 --- a/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java +++ b/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java @@ -22,13 +22,7 @@ * #L% */ -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.stream.StreamSupport; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -80,6 +74,7 @@ public Map getDefaultValues(@Nonnull Optional viewOpti if (!jv.getClass(this).isPresent()) { log.error("Class of annotation not in view" + this); + return defaultValues; } JavaSootClass jsc = jv.getClass(this).get(); From 740dd14ad3c9bf67330009c71508b7e520d99e8c Mon Sep 17 00:00:00 2001 From: liyiwei <979621500@qq.com> Date: Wed, 15 Nov 2023 22:01:28 +0800 Subject: [PATCH 4/6] remove log --- .../src/main/java/sootup/java/core/types/AnnotationType.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java b/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java index 9e1223e828c..b4fdea423d2 100644 --- a/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java +++ b/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java @@ -26,8 +26,6 @@ import java.util.stream.StreamSupport; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import sootup.core.IdentifierFactory; import sootup.core.model.SootMethod; import sootup.core.signatures.PackageName; @@ -44,8 +42,6 @@ */ public class AnnotationType extends JavaClassType { - private static final Logger log = LoggerFactory.getLogger(AnnotationType.class); - public void setInherited(boolean inherited) { isInherited = inherited; } @@ -73,7 +69,6 @@ public Map getDefaultValues(@Nonnull Optional viewOpti } if (!jv.getClass(this).isPresent()) { - log.error("Class of annotation not in view" + this); return defaultValues; } From 08195a27c2741a81c915abd5f1474f39d97f209b Mon Sep 17 00:00:00 2001 From: liyiwei <979621500@qq.com> Date: Thu, 16 Nov 2023 00:47:05 +0800 Subject: [PATCH 5/6] unify conditions --- .../src/main/java/sootup/java/core/types/AnnotationType.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java b/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java index b4fdea423d2..c47773a0ce7 100644 --- a/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java +++ b/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java @@ -64,10 +64,6 @@ public Map getDefaultValues(@Nonnull Optional viewOpti JavaView jv = viewOptional.get(); // meta annotations are not in the view - if (this.isMetaAnnotation()) { - return defaultValues; - } - if (!jv.getClass(this).isPresent()) { return defaultValues; } From 21a092894e927d07c95fa676227400eba0d2fc21 Mon Sep 17 00:00:00 2001 From: liyiwei <979621500@qq.com> Date: Mon, 20 Nov 2023 23:09:23 +0800 Subject: [PATCH 6/6] add log --- .../src/main/java/sootup/java/core/types/AnnotationType.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java b/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java index c47773a0ce7..5ead654fe9c 100644 --- a/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java +++ b/sootup.java.core/src/main/java/sootup/java/core/types/AnnotationType.java @@ -26,6 +26,8 @@ import java.util.stream.StreamSupport; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import sootup.core.IdentifierFactory; import sootup.core.model.SootMethod; import sootup.core.signatures.PackageName; @@ -42,6 +44,8 @@ */ public class AnnotationType extends JavaClassType { + private static final Logger log = LoggerFactory.getLogger(AnnotationType.class); + public void setInherited(boolean inherited) { isInherited = inherited; } @@ -65,6 +69,7 @@ public Map getDefaultValues(@Nonnull Optional viewOpti // meta annotations are not in the view if (!jv.getClass(this).isPresent()) { + log.error("Class of annotation " + this + "is not in current view."); return defaultValues; }