本文整理汇总了Java中org.jf.dexlib2.AnnotationVisibility类的典型用法代码示例。如果您正苦于以下问题:Java AnnotationVisibility类的具体用法?Java AnnotationVisibility怎么用?Java AnnotationVisibility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AnnotationVisibility类属于org.jf.dexlib2包,在下文中一共展示了AnnotationVisibility类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: writeTo
import org.jf.dexlib2.AnnotationVisibility; //导入依赖的package包/类
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");
}
开发者ID:alibaba,项目名称:atlas,代码行数:13,代码来源:AnnotationFormatter.java
示例2: writeTo
import org.jf.dexlib2.AnnotationVisibility; //导入依赖的package包/类
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");
}
开发者ID:Miracle963,项目名称:zjdroid,代码行数:12,代码来源:AnnotationFormatter.java
示例3: buildEnclosingMethodTag
import org.jf.dexlib2.AnnotationVisibility; //导入依赖的package包/类
private Annotation buildEnclosingMethodTag(EnclosingMethodTag t, Set<String> skipList) {
if (!skipList.add("Ldalvik/annotation/EnclosingMethod;"))
return null;
if (t.getEnclosingMethod() == null)
return null;
String[] split1 = t.getEnclosingMethodSig().split("\\)");
String parametersS = split1[0].replaceAll("\\(", "");
String returnTypeS = split1[1];
List<String> typeList = new ArrayList<String>();
if (!parametersS.equals("")) {
for (String p : Util.splitParameters(parametersS)) {
if (!p.isEmpty())
typeList.add(p);
}
}
ImmutableMethodReference mRef = new ImmutableMethodReference
(SootToDexUtils.getDexClassName(t.getEnclosingClass()),
t.getEnclosingMethod(), typeList, returnTypeS);
ImmutableMethodEncodedValue methodRef = new ImmutableMethodEncodedValue
(dexFile.internMethodReference(mRef));
AnnotationElement methodElement = new ImmutableAnnotationElement("value", methodRef);
return new ImmutableAnnotation(AnnotationVisibility.SYSTEM,
"Ldalvik/annotation/EnclosingMethod;",
Collections.singleton(methodElement));
}
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:31,代码来源:DexPrinter.java
示例4: getVisibility
import org.jf.dexlib2.AnnotationVisibility; //导入依赖的package包/类
/**
* Converts Jimple visibility to Dexlib visibility
*
* @param visibility
* Jimple visibility
* @return Dexlib visibility
*/
private static int getVisibility(int visibility) {
if (visibility == AnnotationConstants.RUNTIME_VISIBLE)
return AnnotationVisibility.RUNTIME;
if (visibility == AnnotationConstants.RUNTIME_INVISIBLE)
return AnnotationVisibility.SYSTEM;
if (visibility == AnnotationConstants.SOURCE_VISIBLE)
return AnnotationVisibility.BUILD;
throw new RuntimeException("Unknown annotation visibility: '" + visibility + "'");
}
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:17,代码来源:DexPrinter.java
示例5: getVisibility
import org.jf.dexlib2.AnnotationVisibility; //导入依赖的package包/类
@Override
public int getVisibility() {
return AnnotationVisibility.getVisibility("runtime");
}
开发者ID:alibaba,项目名称:atlas,代码行数:5,代码来源:MethodReplaceAnnotation.java
示例6: buildInnerClassAttribute
import org.jf.dexlib2.AnnotationVisibility; //导入依赖的package包/类
private List<Annotation> buildInnerClassAttribute(SootClass parentClass,
InnerClassAttribute t, Set<String> skipList) {
if (t.getSpecs() == null)
return null;
List<Annotation> anns = null;
for (Tag t2 : t.getSpecs()) {
InnerClassTag icTag = (InnerClassTag) t2;
// In Dalvik, both the EnclosingMethod/EnclosingClass tag and the
// InnerClass tag are written to the inner class which is different
// to Java. We thus check whether this tag actually points to our
// outer class.
String outerClass = getOuterClassNameFromTag(icTag);
String innerClass = icTag.getInnerClass().replaceAll("/", ".");
// Only write the InnerClass tag to the inner class itself, not
// the other one. If the outer class points to our parent, but
// this is simply the wrong inner class, we also continue with the
// next tag.
if (!parentClass.hasOuterClass()
|| !innerClass.equals(parentClass.getName()))
continue;
// If the outer class points to the very same class, we null it
if (parentClass.getName().equals(outerClass)
&& icTag.getOuterClass() == null)
outerClass = null;
// Do not write garbage. Never.
if (parentClass.getName().equals(outerClass))
continue;
// This is an actual inner class. Write the annotation
if (skipList.add("Ldalvik/annotation/InnerClass;")) {
// InnerClass annotation
List<AnnotationElement> elements = new ArrayList<AnnotationElement>();
ImmutableAnnotationElement flagsElement = new ImmutableAnnotationElement
("accessFlags", new ImmutableIntEncodedValue(icTag.getAccessFlags()));
elements.add(flagsElement);
ImmutableEncodedValue nameValue;
if (icTag.getShortName() != null && !icTag.getShortName().isEmpty())
nameValue = new ImmutableStringEncodedValue(icTag.getShortName());
else
nameValue = ImmutableNullEncodedValue.INSTANCE;
ImmutableAnnotationElement nameElement = new ImmutableAnnotationElement
("name", nameValue);
elements.add(nameElement);
if (anns == null) anns = new ArrayList<Annotation>();
anns.add(new ImmutableAnnotation(AnnotationVisibility.SYSTEM,
"Ldalvik/annotation/InnerClass;",
elements));
}
}
return anns;
}
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:62,代码来源:DexPrinter.java
示例7: buildMemberClassesAttribute
import org.jf.dexlib2.AnnotationVisibility; //导入依赖的package包/类
private List<Annotation> buildMemberClassesAttribute(SootClass parentClass,
InnerClassAttribute t, Set<String> skipList) {
List<Annotation> anns = null;
Set<String> memberClasses = null;
// Collect the inner classes
for (Tag t2 : t.getSpecs()) {
InnerClassTag icTag = (InnerClassTag) t2;
String outerClass = getOuterClassNameFromTag(icTag);
// Only classes with names are member classes
if (icTag.getOuterClass() != null
&& parentClass.getName().equals(outerClass)) {
if (memberClasses == null)
memberClasses = new HashSet<String>();
memberClasses.add(SootToDexUtils.getDexClassName(icTag.getInnerClass()));
}
}
// Write the member classes
if (memberClasses != null
&& !memberClasses.isEmpty()
&& skipList.add("Ldalvik/annotation/MemberClasses;")) {
List<EncodedValue> classes = new ArrayList<EncodedValue>();
for (String memberClass : memberClasses) {
ImmutableTypeEncodedValue classValue = new ImmutableTypeEncodedValue(memberClass);
classes.add(classValue);
}
ImmutableArrayEncodedValue classesValue =
new ImmutableArrayEncodedValue(classes);
ImmutableAnnotationElement element =
new ImmutableAnnotationElement("value", classesValue);
ImmutableAnnotation memberAnnotation =
new ImmutableAnnotation(AnnotationVisibility.SYSTEM,
"Ldalvik/annotation/MemberClasses;",
Collections.singletonList(element));
if (anns == null) anns = new ArrayList<Annotation>();
anns.add(memberAnnotation);
}
return anns;
}
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:43,代码来源:DexPrinter.java
示例8: getVisibility
import org.jf.dexlib2.AnnotationVisibility; //导入依赖的package包/类
/**
* Converts Dexlib visibility to Jimple visibility.
*
* In Dalvik:
* VISIBILITY_BUILD 0x00 intended only to be visible at build time
* (e.g., during compilation of other code)
* VISIBILITY_RUNTIME 0x01 intended to visible at runtime
* VISIBILITY_SYSTEM 0x02 intended to visible at runtime, but only to
* the underlying system (and not to regular
* user code)
*
* @param visibility
* Dexlib visibility
* @return Jimple visibility
*/
private int getVisibility(int visibility) {
if ("runtime".equals(AnnotationVisibility.getVisibility(visibility)))
return AnnotationConstants.RUNTIME_VISIBLE;
if ("system".equals(AnnotationVisibility.getVisibility(visibility)))
return AnnotationConstants.RUNTIME_INVISIBLE;
if ("build".equals(AnnotationVisibility.getVisibility(visibility)))//
return AnnotationConstants.SOURCE_VISIBLE;
throw new RuntimeException("error: unknown annotation visibility: '" + visibility + "'");
}
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:25,代码来源:DexAnnotation.java
注:本文中的org.jf.dexlib2.AnnotationVisibility类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论