org.jf.dexlib2.iface.Annotation.getType()方法的使用及代码示例

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

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

Annotation.getType介绍

[英]Gets the type of this annotation. This will be the type descriptor of the class that defines this annotation.
[中]获取此批注的类型。这将是定义此注释的类的类型描述符。

代码示例

代码示例来源: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: 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: 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: 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: Sable/soot

Type atype = DexType.toSoot(a.getType());
String atypes = atype.toString();
int eSize = a.getElements().size();
  AnnotationTag adt = new AnnotationTag(a.getType());
  adt.addElem(anne);
  if (vatg[v] == null) {

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

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

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

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

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

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

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

@Nonnull public BuilderAnnotation internAnnotation(@Nonnull Annotation annotation) {
  BuilderAnnotation ret = internedItems.get(annotation);
  if (ret != null) {
    return ret;
  }
  BuilderAnnotation dexBuilderAnnotation = new BuilderAnnotation(
      annotation.getVisibility(),
      dexBuilder.typeSection.internType(annotation.getType()),
      dexBuilder.internAnnotationElements(annotation.getElements()));
  ret = internedItems.putIfAbsent(dexBuilderAnnotation, dexBuilderAnnotation);
  return ret==null?dexBuilderAnnotation:ret;
}

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

@Nonnull public BuilderAnnotation internAnnotation(@Nonnull Annotation annotation) {
  BuilderAnnotation ret = internedItems.get(annotation);
  if (ret != null) {
    return ret;
  }
  BuilderAnnotation dexBuilderAnnotation = new BuilderAnnotation(
      annotation.getVisibility(),
      dexBuilder.typeSection.internType(annotation.getType()),
      dexBuilder.internAnnotationElements(annotation.getElements()));
  ret = internedItems.putIfAbsent(dexBuilderAnnotation, dexBuilderAnnotation);
  return ret==null?dexBuilderAnnotation:ret;
}

代码示例来源: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: testwhat/SmaliEx

@Override
public boolean equals(Object o) {
  if (o instanceof Annotation) {
    Annotation other = (Annotation)o;
    return (getVisibility() == other.getVisibility()) &&
        getType().equals(other.getType()) &&
        getElements().equals(other.getElements());
  }
  return false;
}

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

@Override
public boolean equals(Object o) {
  if (o instanceof Annotation) {
    Annotation other = (Annotation)o;
    return (getVisibility() == other.getVisibility()) &&
        getType().equals(other.getType()) &&
        getElements().equals(other.getElements());
  }
  return false;
}

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

public static void writeTo(@Nonnull IndentingWriter writer, @Nonnull Annotation annotation,
                @Nullable String containingClass) throws IOException {
    writer.write(".annotation ");
    writer.write(AnnotationVisibility.getVisibility(annotation.getVisibility()));
    writer.write(' ');
    writer.write(annotation.getType());
    writer.write('\n');

    AnnotationEncodedValueAdaptor.writeElementsTo(writer, annotation.getElements(), containingClass);

    writer.write(".end annotation\n");
  }
}

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

public static void writeTo(@Nonnull IndentingWriter writer, @Nonnull Annotation annotation,
                @Nullable String containingClass) throws IOException {
    writer.write(".annotation ");
    writer.write(AnnotationVisibility.getVisibility(annotation.getVisibility()));
    writer.write(' ');
    writer.write(annotation.getType());
    writer.write('\n');

    AnnotationEncodedValueAdaptor.writeElementsTo(writer, annotation.getElements(), containingClass);

    writer.write(".end annotation\n");
  }
}

代码示例来源:origin: com.taobao.android/dex_patch

public static void writeTo(@Nonnull IndentingWriter writer, @Nonnull Annotation annotation,
                @Nullable String containingClass) throws IOException {
    writer.write(".annotation ");
    writer.write(AnnotationVisibility.getVisibility(annotation.getVisibility()));
    writer.write(' ');
    writer.write(annotation.getType());
    writer.write('\n');

    AnnotationEncodedValueAdaptor.writeElementsTo(writer, annotation.getElements(), containingClass);

    writer.write(".end annotation\n");
  }
}

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

@Override
public int compareTo(Annotation o) {
  int res = Ints.compare(getVisibility(), o.getVisibility());
  if (res != 0) return res;
  res = getType().compareTo(o.getType());
  if (res != 0) return res;
  return CollectionUtils.compareAsSet(getElements(), o.getElements());
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.dalvik

static Annotation getAnnotation(org.jf.dexlib2.iface.Annotation ea, ClassLoaderReference clr) {
  Map<String,ElementValue> values = HashMapFactory.make();
  TypeReference at = getTypeRef(ea.getType(), clr);
  
  for(AnnotationElement elt : ea.getElements()) {
    String name = elt.getName();
    EncodedValue v = elt.getValue();
    ElementValue value = getValue(clr, v);
    values.put(name, value);
  }
  
  return Annotation.makeWithNamed(at, values);
}

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

public static void writeTo(IndentingWriter writer, Annotation annotation) throws IOException {
    writer.write(".annotation ");
    writer.write(AnnotationVisibility.getVisibility(annotation.getVisibility()));
    writer.write(' ');
    writer.write(annotation.getType());
    writer.write('\n');

    AnnotationEncodedValueAdaptor.writeElementsTo(writer, annotation.getElements());

    writer.write(".end annotation\n");
  }
}

相关文章