Skip to content

Commit

Permalink
Merge pull request #726 from Liyw979/allow-partial-annotation
Browse files Browse the repository at this point in the history
not throw exceptions when class of annotation not found
  • Loading branch information
JonasKlauke authored Nov 20, 2023
2 parents 208413c + 21a0928 commit 0d2d469
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ public boolean isStaticInitializer() {

@Nonnull
public Iterable<AnnotationUsage> getAnnotations(@Nonnull Optional<JavaView> view) {
annotations.forEach(e -> e.getAnnotation().getDefaultValues(view));

resolveDefaultsForAnnotationTypes(view, annotations);

return annotations;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@
* #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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sootup.core.IdentifierFactory;
import sootup.core.model.SootMethod;
import sootup.core.signatures.PackageName;
Expand All @@ -48,6 +44,8 @@
*/
public class AnnotationType extends JavaClassType {

private static final Logger log = LoggerFactory.getLogger(AnnotationType.class);

public void setInherited(boolean inherited) {
isInherited = inherited;
}
Expand All @@ -70,12 +68,9 @@ public Map<String, Object> getDefaultValues(@Nonnull Optional<JavaView> viewOpti
JavaView jv = viewOptional.get();

// meta annotations are not in the view
if (this.isMetaAnnotation()) {
return defaultValues;
}

if (!jv.getClass(this).isPresent()) {
throw new RuntimeException("Class of annotation not in view");
log.error("Class of annotation " + this + "is not in current view.");
return defaultValues;
}

JavaSootClass jsc = jv.getClass(this).get();
Expand Down

0 comments on commit 0d2d469

Please sign in to comment.