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

x33g5p2x  于2022-01-25 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(98)

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

Method.getAnnotations介绍

[英]Gets a set of the annotations that are applied to this method. The annotations in the returned set are guaranteed to have unique types.
[中]获取应用于此方法的一组批注。返回集中的注释保证具有唯一的类型。

代码示例

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

@Nonnull @Override public Set<? extends Annotation> getAnnotations() {
  return method.getAnnotations();
}

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

method.getReturnType(),
    method.getAccessFlags(),
    method.getAnnotations(),
    methodImpl
);

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

Set<? extends Annotation> aSet = method.getAnnotations();
if (!(aSet == null || aSet.isEmpty())) {
 List<Tag> tags = handleAnnotation(aSet, null);

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

public static void writeEmptyMethodTo(IndentingWriter writer, Method method,
                   BaksmaliOptions options) throws IOException {
  writer.write(".method ");
  writeAccessFlags(writer, method.getAccessFlags());
  writer.write(method.getName());
  writer.write("(");
  ImmutableList<MethodParameter> methodParameters = ImmutableList.copyOf(method.getParameters());
  for (MethodParameter parameter: methodParameters) {
    writer.write(parameter.getType());
  }
  writer.write(")");
  writer.write(method.getReturnType());
  writer.write('\n');
  writer.indent(4);
  writeParameters(writer, method, methodParameters, options);
  String containingClass = null;
  if (options.implicitReferences) {
    containingClass = method.getDefiningClass();
  }
  AnnotationFormatter.writeTo(writer, method.getAnnotations(), containingClass);
  writer.deindent(4);
  writer.write(".end method\n");
}

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

containingClass = method.getDefiningClass();
AnnotationFormatter.writeTo(writer, method.getAnnotations(), containingClass);

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

@Nonnull @Override public Set<? extends Annotation> getAnnotations() {
  return method.getAnnotations();
}

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

@Override @Nonnull public Set<? extends Annotation> getAnnotations() {
  return method.getAnnotations();
}

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

@Override @Nonnull public Set<? extends Annotation> getAnnotations() {
  return method.getAnnotations();
}

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

@Override @Nonnull public Set<? extends Annotation> getAnnotations() {
  return method.getAnnotations();
}

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

@Override @Nonnull public Set<? extends Annotation> getAnnotations() {
  return RewriterUtils.rewriteSet(rewriters.getAnnotationRewriter(), method.getAnnotations());
}

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

@Override @Nonnull public Set<? extends Annotation> getAnnotations() {
  return RewriterUtils.rewriteSet(rewriters.getAnnotationRewriter(), method.getAnnotations());
}

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

@Override @Nonnull public Set<? extends Annotation> getAnnotations() {
  return RewriterUtils.rewriteSet(rewriters.getAnnotationRewriter(), method.getAnnotations());
}

代码示例来源:origin: wala/WALA

List<Annotation> getAnnotations(Method m, Set<String> set) {
  List<Annotation> result = new ArrayList<>();
  for(org.jf.dexlib2.iface.Annotation a : m.getAnnotations()) {
    if (set == null || set.contains(AnnotationVisibility.getVisibility(a.getVisibility()))) {
      result.add(DexUtil.getAnnotation(a, getClassLoader().getReference()));
    }
  }
  return result;
}

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

List<Annotation> getAnnotations(Method m, Set<String> set) {
  List<Annotation> result = new ArrayList<>();
  for(org.jf.dexlib2.iface.Annotation a : m.getAnnotations()) {
    if (set == null || set.contains(AnnotationVisibility.getVisibility(a.getVisibility()))) {
      result.add(DexUtil.getAnnotation(a, getClassLoader().getReference()));
    }
  }
  return result;
}

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

private static List<Method> reDexMethods(@Nonnull ClassDef classDef) {
  List<Method> taintedMethods = Lists.newArrayList();
  for (Method method : classDef.getMethods()) {
    MethodImplementation implementation = method.getImplementation();
    MutableMethodImplementation mutableImplementation = new MutableMethodImplementation(implementation);
    taintedMethods.add(new ImmutableMethod(
        method.getDefiningClass(),
        method.getName(),
        method.getParameters(),
        method.getReturnType(),
        method.getAccessFlags(),
        method.getAnnotations(),
        mutableImplementation));
  }
  return taintedMethods;
}

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

public static ImmutableMethod of(Method method) {
  if (method instanceof ImmutableMethod) {
    return (ImmutableMethod)method;
  }
  return new ImmutableMethod(
      method.getDefiningClass(),
      method.getName(),
      method.getParameters(),
      method.getReturnType(),
      method.getAccessFlags(),
      method.getAnnotations(),
      method.getImplementation());
}

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

public static ImmutableMethod of(Method method) {
  if (method instanceof ImmutableMethod) {
    return (ImmutableMethod)method;
  }
  return new ImmutableMethod(
      method.getDefiningClass(),
      method.getName(),
      method.getParameters(),
      method.getReturnType(),
      method.getAccessFlags(),
      method.getAnnotations(),
      method.getImplementation());
}

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

public static ImmutableMethod of(Method method) {
  if (method instanceof ImmutableMethod) {
    return (ImmutableMethod)method;
  }
  return new ImmutableMethod(
      method.getDefiningClass(),
      method.getName(),
      method.getParameters(),
      method.getReturnType(),
      method.getAccessFlags(),
      method.getAnnotations(),
      method.getImplementation());
}

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

public static void writeEmptyMethodTo(IndentingWriter writer, Method method,
                   baksmaliOptions options) throws IOException {
  writer.write(".method ");
  writeAccessFlags(writer, method.getAccessFlags());
  writer.write(method.getName());
  writer.write("(");
  ImmutableList<MethodParameter> methodParameters = ImmutableList.copyOf(method.getParameters());
  for (MethodParameter parameter: methodParameters) {
    writer.write(parameter.getType());
  }
  writer.write(")");
  writer.write(method.getReturnType());
  writer.write('\n');
  writer.indent(4);
  writeParameters(writer, method, methodParameters, options);
  AnnotationFormatter.writeTo(writer, method.getAnnotations());
  writer.deindent(4);
  writer.write(".end method\n");
}

相关文章