本文整理汇总了Java中org.objectweb.asm.tree.AnnotationNode类的典型用法代码示例。如果您正苦于以下问题:Java AnnotationNode类的具体用法?Java AnnotationNode怎么用?Java AnnotationNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnnotationNode类属于org.objectweb.asm.tree包,在下文中一共展示了AnnotationNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: callDetour
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
private Detour callDetour(ClassNode cn, MethodNode mn, AnnotationNode a) {
String owner = getFirstParameter(mn);
if (owner == null) {
_log.debug("Could not get parameter type for detour " + mn.name + mn.desc);
return null;
}
MethodInsnNode mi = getMethodInstruction(mn, owner, mn.name);
if (mi == null) {
_log.debug("Could not get method instruction for detour " + mn.name + mn.desc);
return null;
}
CallDetour detour = new CallDetour(_log);
detour.matchMethod = mn.name;
detour.matchDesc = mi.desc;
detour.owner = owner.replace('/', '.');
detour.detourOwner = cn.name;
detour.detourDesc = mn.desc;
return detour;
}
示例2: checkAnnotation
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
private boolean checkAnnotation(AnnotationNode a) {
if (a.desc.equals("Lcom/rakuten/tech/mobile/perf/core/annotations/Exists;")) {
if (!exists(((Type) a.values.get(1)).getClassName())) {
return false;
}
} else if (a.desc
.equals("Lcom/rakuten/tech/mobile/perf/core/annotations/MinCompileSdkVersion;")) {
if (_compileSdkVersion < (int) a.values.get(1)) {
return false;
}
} else if (a.desc
.equals("Lcom/rakuten/tech/mobile/perf/core/annotations/MaxCompileSdkVersion;")) {
if (_compileSdkVersion > (int) a.values.get(1)) {
return false;
}
}
return true;
}
示例3: isParameterAnnotationFound
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
private boolean isParameterAnnotationFound(List<Annotation> annotationRules, MethodNode methodNode) {
boolean annotationFound = true;
List<AnnotationNode> allParameterAnnotations = new ArrayList<>();
List<AnnotationNode>[] visibleParameterAnnotations = methodNode.visibleParameterAnnotations;
if (visibleParameterAnnotations != null && visibleParameterAnnotations.length != 0) {
addIfNotNull(allParameterAnnotations, visibleParameterAnnotations);
}
List<AnnotationNode>[] inVisibleParameterAnnotations = methodNode.invisibleParameterAnnotations;
if (inVisibleParameterAnnotations != null && inVisibleParameterAnnotations.length != 0) {
addIfNotNull(allParameterAnnotations, inVisibleParameterAnnotations);
}
if (annotationRules != null && !annotationRules.isEmpty()) {
for (Annotation annotationRule : annotationRules) {
annotationFound &= RuleHelper.containsAnnotation(annotationRule, allParameterAnnotations);
}
}
return annotationFound;
}
示例4: isLocalVariableAnnotationFound
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
private boolean isLocalVariableAnnotationFound(List<Annotation> annotationRules, MethodNode methodNode) {
boolean annotationFound = true;
List<AnnotationNode> allLocalVariableAnnotations = new ArrayList<>();
List<LocalVariableAnnotationNode> invisibleVariableAnnotations = methodNode.invisibleLocalVariableAnnotations;
if (invisibleVariableAnnotations != null) {
allLocalVariableAnnotations.addAll(invisibleVariableAnnotations);
}
List<LocalVariableAnnotationNode> visibleVariableAnnotations = methodNode.visibleLocalVariableAnnotations;
if (visibleVariableAnnotations != null) {
allLocalVariableAnnotations.addAll(visibleVariableAnnotations);
}
for (Annotation annotationRule : annotationRules) {
annotationFound &= RuleHelper.containsAnnotation(annotationRule, allLocalVariableAnnotations);
}
return annotationFound;
}
示例5: isMethodAnnotationFound
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
private boolean isMethodAnnotationFound(List<Annotation> annotationRules, MethodNode methodNode) {
boolean annotationFound = true;
List<AnnotationNode> allMethodAnnotations = new ArrayList<>();
List<AnnotationNode> invisibleAnnotations = methodNode.invisibleAnnotations;
if (invisibleAnnotations != null) {
allMethodAnnotations.addAll(invisibleAnnotations);
}
List<AnnotationNode> visibleAnnotations = methodNode.visibleAnnotations;
if (visibleAnnotations != null) {
allMethodAnnotations.addAll(visibleAnnotations);
}
for (Annotation annotationRule : annotationRules) {
annotationFound &= RuleHelper.containsAnnotation(annotationRule, allMethodAnnotations);
}
return annotationFound;
}
示例6: process
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
@Override
public void process() {
boolean issueFound;
List<AnnotationNode> allAnnotations = new ArrayList<>();
List<AnnotationNode> visibleAnnotations = getClassNode().visibleAnnotations;
if (visibleAnnotations != null) {
allAnnotations.addAll(visibleAnnotations);
}
List<AnnotationNode> invisibleAnnotations = getClassNode().invisibleAnnotations;
if (invisibleAnnotations != null) {
allAnnotations.addAll(invisibleAnnotations);
}
for (AnnotationNode annotationNode : allAnnotations) {
String desc = annotationNode.desc;
boolean visible = visibleAnnotations == null ? false : visibleAnnotations.contains(annotationNode);
logger.trace("visitAnnotation: desc={}, visible={}", desc, visible);
issueFound = StringsHelper.simpleDescriptorToHuman(desc).equals(StringsHelper.dotsToSlashes(annotation.getType()));
if (issueFound) {
ReportItem reportItem = new ReportItem(getRuleName(), showInReport());
this.itemsFound().add(reportItem);
this.setIssueFound(true);
}
}
}
示例7: getSide
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
public Side getSide(final List<AnnotationNode> anns) {
if (anns == null) {
return null;
}
for (final AnnotationNode ann : anns) {
if (ann.desc.equals(Type.getDescriptor((Class)SideOnly.class)) && ann.values != null) {
for (int x = 0; x < ann.values.size() - 1; x += 2) {
final Object key = ann.values.get(x);
final Object value = ann.values.get(x + 1);
if (key instanceof String && key.equals("value") && value instanceof String[]) {
final String s = ((String[])value)[1];
if (s.equals(SafeCore.SIDE_SERVER)) {
return Side.SERVER;
}
if (s.equals(SafeCore.SIDE_CLIENT)) {
return Side.CLIENT;
}
}
}
}
}
return null;
}
示例8: isPackageInstantRunDisabled
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
private static boolean isPackageInstantRunDisabled(
File inputFile, ClassNode classNode) throws IOException {
ClassNode packageInfoClass = parsePackageInfo(inputFile, classNode);
if (packageInfoClass != null) {
//noinspection unchecked
List<AnnotationNode> annotations = packageInfoClass.invisibleAnnotations;
if (annotations == null) {
return false;
}
for (AnnotationNode annotation : annotations) {
if (annotation.desc.equals(DISABLE_ANNOTATION_TYPE.getDescriptor())) {
return true;
}
}
}
return false;
}
示例9: removeInterfaces
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
private boolean removeInterfaces(ClassNode classNode) {
boolean b = false;
if (classNode.visibleAnnotations != null) {
for (AnnotationNode an : classNode.visibleAnnotations) {
Type anType = Type.getType(an.desc);
if (anType.equals(Type.getType(Strippable.Interface.class))) {
b = b | handleStrippableInterface(classNode, an);
} else if (anType.equals(Type.getType(InterfaceContainer.class))) {
for (Object o : (Iterable<?>) an.values.get(1)) {
b = b | handleStrippableInterface(classNode, (AnnotationNode) o);
}
}
}
}
return b;
}
示例10: isJUnit4TestSuite
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private boolean isJUnit4TestSuite(ClassNode cn) {
if (cn.visibleAnnotations == null) {
return false;
}
boolean annotatedRunWith = false;
boolean annotatedSuiteClasses = false;
for (AnnotationNode annotation : (List<AnnotationNode>) cn.visibleAnnotations) {
if (annotation.desc.equals(JUNIT_4_RUN_WITH_ANNOTATION)) {
annotatedRunWith = true;
} else if (annotation.desc.equals(JUNIT_4_SUITE_CLASSES_ANNOTATION)) {
annotatedSuiteClasses = true;
}
}
return annotatedRunWith && annotatedSuiteClasses;
}
示例11: isJUnit4Testcase
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
/** Check if the method is a JUnit 4 test case. */
@SuppressWarnings("unchecked")
public boolean isJUnit4Testcase(MethodNode method) {
if (method.visibleAnnotations == null) {
return false;
}
boolean hasTestcaseAnnotation = false;
boolean hasIgnoreAnnotation = false;
for (AnnotationNode annotation : (List<AnnotationNode>) method.visibleAnnotations) {
if (annotation.desc.equals(JUNIT_4_TEST_ANNOTATION)) {
hasTestcaseAnnotation = true;
} else if (annotation.desc.equals(JUNIT_4_IGNORE_ANNOTATION)) {
hasIgnoreAnnotation = true;
}
}
if (IGNORE_IGNORED_TEST_CASES && hasIgnoreAnnotation) {
return false;
}
return hasTestcaseAnnotation;
}
示例12: checkClassIsDLC
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
@Nullable
private static IDLCInfo checkClassIsDLC(InputStream input) throws Exception {
try {
ClassReader reader = new ClassReader(input);
ClassNode node = new ClassNode(Opcodes.ASM5);
reader.accept(node, 0);
if (node.visibleAnnotations != null)
for (AnnotationNode annotation : node.visibleAnnotations)
if (DESCRIPTOR.equals(annotation.desc))
return Tool.makeAnnotation(IDLCInfo.class, makeHandlerMapping(node.name.replace('/', '.')), annotation.values,
"forgeVersion", "*", "description", "");
} finally {
if (!(input instanceof ZipInputStream))
IOUtils.closeQuietly(input);
}
return null;
}
示例13: loadHook
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
@Unsafe(Unsafe.ASM_API)
private static void loadHook(ClassNode node) throws Exception {
if (node.visibleAnnotations != null)
for (AnnotationNode nann : node.visibleAnnotations)
if (nann.desc.equals(HOOK_PROVIDER_ANNOTATION_DESC)) {
for (MethodNode methodNode : node.methods)
if (checkSideOnly(methodNode) && methodNode.visibleAnnotations != null)
for (AnnotationNode ann : methodNode.visibleAnnotations)
if (ann.desc.equals(HOOK_ANNOTATION_DESC)) {
Hook hook = Tool.makeAnnotation(Hook.class, ann.values,
"isStatic", false, "type", Hook.Type.HEAD, "disable", "");
if (hook.disable().isEmpty() || !Boolean.getBoolean(hook.disable())) {
String args[] = hook.value().split("#");
if (args.length == 2)
transformers_mapping.get(args[0]).add(new TransformerHook(methodNode, node.name,
args[0], args[1], hook.isStatic(), hook.type()));
else
AlchemyRuntimeException.onException(new RuntimeException("@Hook method -> split(\"#\") != 2"));
}
}
break;
}
}
示例14: loadProxy
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
@Unsafe(Unsafe.ASM_API)
private static void loadProxy(ClassNode node) throws Exception {
if (node.visibleAnnotations != null)
for (AnnotationNode nann : node.visibleAnnotations)
if (nann.desc.equals(PROXY_PROVIDER_ANNOTATION_DESC)) {
for (MethodNode methodNode : node.methods)
if (checkSideOnly(methodNode) && methodNode.visibleAnnotations != null)
for (AnnotationNode ann : methodNode.visibleAnnotations)
if (ann.desc.equals(PROXY_ANNOTATION_DESC)) {
Proxy proxy = Tool.makeAnnotation(Proxy.class, ann.values);
String args[] = proxy.target().split("#");
if (args.length == 2)
transformers_mapping.get(ASMHelper.getClassSrcName(node.name)).add(new TransformerProxy(
methodNode, proxy.opcode(), args[0], args[1]));
else
AlchemyRuntimeException.onException(new RuntimeException("@Hook method -> split(\"#\") != 2"));
}
break;
}
}
示例15: copyClass
import org.objectweb.asm.tree.AnnotationNode; //导入依赖的package包/类
private void copyClass(ZipFile inJar, ZipEntry entry, ZipOutputStream outJar, boolean isClientOnly) throws IOException {
ClassReader reader = new ClassReader(readEntry(inJar, entry));
ClassNode classNode = new ClassNode();
reader.accept(classNode, 0);
if (classNode.visibleAnnotations == null) {
classNode.visibleAnnotations = new ArrayList<AnnotationNode>();
}
classNode.visibleAnnotations.add(getSideAnn(isClientOnly));
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
classNode.accept(writer);
byte[] data = writer.toByteArray();
ZipEntry newEntry = new ZipEntry(entry.getName());
if (outJar != null) {
outJar.putNextEntry(newEntry);
outJar.write(data);
}
}