org.jf.dexlib2.iface.Annotation类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(200)

本文整理了Java中org.jf.dexlib2.iface.Annotation类的一些代码示例,展示了Annotation类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation类的具体详情如下:
包路径:org.jf.dexlib2.iface.Annotation
类名称:Annotation

Annotation介绍

[英]This class represents a specific instance of an annotation applied to a class/field/method/parameter
[中]

代码示例

代码示例来源:origin: Sable/soot

protected void addAnnotation(String classType, List<Tag> tags, VisibilityAnnotationTag[] vatg, Annotation a) {
 int v = getVisibility(a.getVisibility());
 Type atype = DexType.toSoot(a.getType());
 String atypes = atype.toString();
 int eSize = a.getElements().size();
   AnnotationElem anne = getElements(a.getElements()).get(0);
   AnnotationTag adt = new AnnotationTag(a.getType());
   adt.addElem(anne);
   if (vatg[v] == null) {
   for (AnnotationElement elem : a.getElements()) {
    String outerClass = ((TypeEncodedValue) elem.getValue()).getValue();
    outerClass = Util.dottedClassName(outerClass);
   AnnotationStringElem e = (AnnotationStringElem) getElements(a.getElements()).get(0);
   String[] split1 = e.getValue().split("\\ \\|");
   String classString = split1[0];
   for (AnnotationElem ele : getElements(a.getElements())) {
    if (ele instanceof AnnotationIntElem && ele.getName().equals("accessFlags")) {
     accessFlags = ((AnnotationIntElem) ele).getValue();
   AnnotationArrayElem arre = (AnnotationArrayElem) getElements(a.getElements()).get(0);
   for (AnnotationElem ae : arre.getValues()) {
    AnnotationClassElem c = (AnnotationClassElem) ae;
   arre = (AnnotationArrayElem) getElements(a.getElements()).get(0);
   String sig = "";

代码示例来源:origin: CalebFenton/simplify

private String buildASMSignature(ClassDef classDef) {
  String signature = null;
  outer:
  for (Annotation annotation : classDef.getAnnotations()) {
    if (!annotation.getType().equals("Ldalvik/annotation/Signature;")) {
      continue;
    }
    StringBuilder sb = new StringBuilder();
    for (AnnotationElement e : annotation.getElements()) {
      BuilderEncodedValues.BuilderArrayEncodedValue ev = (BuilderEncodedValues.BuilderArrayEncodedValue) e
          .getValue();
      for (EncodedValue v : ev.getValue()) {
        BuilderEncodedValues.BuilderStringEncodedValue value = (BuilderEncodedValues.BuilderStringEncodedValue) v;
        sb.append(value.getValue());
      }
    }
    signature = sb.toString();
    break;
  }
  return signature;
}

代码示例来源:origin: JesusFreke/smali

Annotation old = annotationMap.put(anno.getType(), anno);
if (old != null) {
  throw new SemanticException(input, "Multiple annotations of type %s", anno.getType());

代码示例来源:origin: testwhat/SmaliEx

@Nonnull @Override public Collection<? extends AnnotationElement> getElements(@Nonnull Annotation annotation) {
  return annotation.getElements();
}

代码示例来源:origin: testwhat/SmaliEx

@Override public int getVisibility() {
  return annotation.getVisibility();
}

代码示例来源:origin: CalebFenton/simplify

private void visitClassAnnotations(Set<? extends Annotation> annotations,
                  ClassWriter classWriter) {
  for (Annotation annotation : annotations) {
    switch (annotation.getType()) {
      case "Ldalvik/annotation/EnclosingMethod;":
        for (AnnotationElement e : annotation.getElements()) {
          BuilderEncodedValues.BuilderMethodEncodedValue v = (BuilderEncodedValues.BuilderMethodEncodedValue) e
              .getValue();
          visitEnclosingMethod(v, classWriter);
          // There should only ever be one enclosing method.
          break;
        }
        break;
      case "Ldalvik/annotation/MemberClasses;":
        for (AnnotationElement e : annotation.getElements()) {
          BuilderEncodedValues.BuilderArrayEncodedValue ev = (BuilderEncodedValues.BuilderArrayEncodedValue) e
              .getValue();
          for (EncodedValue v : ev.getValue()) {
            BuilderEncodedValues.BuilderTypeEncodedValue value = (BuilderEncodedValues.BuilderTypeEncodedValue) v;
            visitInnerClasses(value, classWriter);
          }
        }
        break;
    }
  }
}

代码示例来源:origin: org.smali/dexlib2

@Override
  public int compare(Annotation annotation1, Annotation annotation2) {
    return annotation1.getType().compareTo(annotation2.getType());
  }
};

代码示例来源:origin: org.smali/dexlib2

@Nonnull @Override public Collection<? extends AnnotationElement> getElements(@Nonnull Annotation annotation) {
  return annotation.getElements();
}

代码示例来源:origin: org.smali/dexlib2

@Override public int getVisibility() {
  return annotation.getVisibility();
}

代码示例来源:origin: testwhat/SmaliEx

public static ImmutableAnnotation of(Annotation annotation) {
  if (annotation instanceof  ImmutableAnnotation) {
    return (ImmutableAnnotation)annotation;
  }
  return new ImmutableAnnotation(
      annotation.getVisibility(),
      annotation.getType(),
      annotation.getElements());
}

代码示例来源:origin: Sable/soot

/**
 * Processes a normal annotation and adds it to the proper visibility annotation tag in the given array
 * 
 * @param vatg
 *          the visibility annotation tags for different visibility levels
 * @param a
 *          the annotation
 * @param v
 *          the visibility
 */
protected void addNormalAnnotation(VisibilityAnnotationTag[] vatg, Annotation a, int v) {
 if (vatg[v] == null) {
  vatg[v] = new VisibilityAnnotationTag(v);
 }
 AnnotationTag tag = new AnnotationTag(a.getType());
 for (AnnotationElem e : getElements(a.getElements())) {
  tag.addElem(e);
 }
 vatg[v].addAnnotation(tag);
}

代码示例来源:origin: testwhat/SmaliEx

@Override
  public int compare(Annotation annotation1, Annotation annotation2) {
    return annotation1.getType().compareTo(annotation2.getType());
  }
};

代码示例来源:origin: KB5201314/ZjDroid

@Nonnull @Override public Collection<? extends AnnotationElement> getElements(@Nonnull Annotation annotation) {
  return annotation.getElements();
}

代码示例来源:origin: KB5201314/ZjDroid

@Override public int getVisibility() {
  return annotation.getVisibility();
}

代码示例来源:origin: org.smali/dexlib2

public static ImmutableAnnotation of(Annotation annotation) {
  if (annotation instanceof  ImmutableAnnotation) {
    return (ImmutableAnnotation)annotation;
  }
  return new ImmutableAnnotation(
      annotation.getVisibility(),
      annotation.getType(),
      annotation.getElements());
}

代码示例来源:origin: Sable/soot

protected List<SootClass> getThrownExceptions(final Method method) {
  // the following snippet retrieves all exceptions that this method
  // throws by analyzing its annotations
  List<SootClass> thrownExceptions = new ArrayList<SootClass>();
  for (Annotation a : method.getAnnotations()) {
   Type atype = DexType.toSoot(a.getType());
   String atypes = atype.toString();
   if (!(atypes.equals("dalvik.annotation.Throws"))) {
    continue;
   }
   for (AnnotationElement ae : a.getElements()) {
    EncodedValue ev = ae.getValue();
    if (ev instanceof ArrayEncodedValue) {
     for (EncodedValue evSub : ((ArrayEncodedValue) ev).getValue()) {
      if (evSub instanceof TypeEncodedValue) {
       TypeEncodedValue valueType = (TypeEncodedValue) evSub;
       String exceptionName = valueType.getValue();
       String dottedName = Util.dottedClassName(exceptionName);
       thrownExceptions.add(SootResolver.v().makeClassRef(dottedName));
      }
     }
    }
   }
  }
  return thrownExceptions;
 }
}

代码示例来源:origin: KB5201314/ZjDroid

@Override
  public int compare(Annotation annotation1, Annotation annotation2) {
    return annotation1.getType().compareTo(annotation2.getType());
  }
};

代码示例来源:origin: testwhat/SmaliEx

@Override @Nonnull public Set<? extends AnnotationElement> getElements() {
    return RewriterUtils.rewriteSet(rewriters.getAnnotationElementRewriter(), annotation.getElements());
  }
}

代码示例来源:origin: testwhat/SmaliEx

@Override public int getVisibility(@Nonnull Annotation annotation) {
  return annotation.getVisibility();
}

代码示例来源:origin: KB5201314/ZjDroid

public static ImmutableAnnotation of(Annotation annotation) {
  if (annotation instanceof  ImmutableAnnotation) {
    return (ImmutableAnnotation)annotation;
  }
  return new ImmutableAnnotation(
      annotation.getVisibility(),
      annotation.getType(),
      annotation.getElements());
}

相关文章

微信公众号

最新文章

更多