List of usage examples for org.objectweb.asm MethodVisitor visitAnnotationDefault
public AnnotationVisitor visitAnnotationDefault()
From source file:com.facebook.buck.jvm.java.abi.AnnotationDefaultValueMirror.java
License:Apache License
public void appendTo(MethodVisitor method) { final AnnotationVisitor annotationVisitor = method.visitAnnotationDefault(); Preconditions.checkNotNull(defaultValue).accept(null, annotationVisitor); annotationVisitor.visitEnd();/*from w ww.jav a 2s. co m*/ }
From source file:com.googlecode.ddom.weaver.asm.MethodVisitorTee.java
License:Apache License
public AnnotationVisitor visitAnnotationDefault() { AnnotationVisitor result = null;//from www . j a v a 2 s .com for (MethodVisitor visitor : visitors) { result = AnnotationVisitorTee.mergeVisitors(result, visitor.visitAnnotationDefault()); } return result; }
From source file:kilim.analysis.MethodFlow.java
License:Open Source License
@Override /**/* w w w . j a v a 2 s .com*/ * Copied verbatim from MethodNode except for the instruction processing. * Unlike MethodNode, we don't keep LabelNodes inline, so we need to * do visitLabel ourselves. * * @param mv a method visitor. */ public void accept(final MethodVisitor mv) { // visits the method attributes int i, j, n; if (annotationDefault != null) { AnnotationVisitor av = mv.visitAnnotationDefault(); acceptAnnotation(av, null, annotationDefault); av.visitEnd(); } n = visibleAnnotations == null ? 0 : visibleAnnotations.size(); for (i = 0; i < n; ++i) { AnnotationNode an = (AnnotationNode) visibleAnnotations.get(i); an.accept(mv.visitAnnotation(an.desc, true)); } n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size(); for (i = 0; i < n; ++i) { AnnotationNode an = (AnnotationNode) invisibleAnnotations.get(i); an.accept(mv.visitAnnotation(an.desc, false)); } n = visibleParameterAnnotations == null ? 0 : visibleParameterAnnotations.length; for (i = 0; i < n; ++i) { List<?> l = visibleParameterAnnotations[i]; if (l == null) { continue; } for (j = 0; j < l.size(); ++j) { AnnotationNode an = (AnnotationNode) l.get(j); an.accept(mv.visitParameterAnnotation(i, an.desc, true)); } } n = invisibleParameterAnnotations == null ? 0 : invisibleParameterAnnotations.length; for (i = 0; i < n; ++i) { List<?> l = invisibleParameterAnnotations[i]; if (l == null) { continue; } for (j = 0; j < l.size(); ++j) { AnnotationNode an = (AnnotationNode) l.get(j); an.accept(mv.visitParameterAnnotation(i, an.desc, false)); } } n = attrs == null ? 0 : attrs.size(); for (i = 0; i < n; ++i) { mv.visitAttribute((Attribute) attrs.get(i)); } // visits the method's code if (instructions.size() > 0) { mv.visitCode(); // visits try catch blocks for (i = 0; i < tryCatchBlocks.size(); ++i) { ((TryCatchBlockNode) tryCatchBlocks.get(i)).accept(mv); } // visits instructions for (i = 0; i < instructions.size(); ++i) { Label l = getLabelAt(i); if (l != null) { mv.visitLabel(l); } ((AbstractInsnNode) instructions.get(i)).accept(mv); } Label l = getLabelAt(instructions.size()); if (l != null) { mv.visitLabel(l); } // visits local variables n = localVariables == null ? 0 : localVariables.size(); for (i = 0; i < n; ++i) { ((LocalVariableNode) localVariables.get(i)).accept(mv); } // visits line numbers /* TODO this was in ASM 2.3.3 but not 3.x or 4.0, find a substitute or remove n = lineNumbers == null ? 0 : lineNumbers.size(); for (i = 0; i < n; ++i) { ((LineNumberNode) lineNumbers.get(i)).accept(mv); } */ // visits maxs mv.visitMaxs(maxStack, maxLocals); } mv.visitEnd(); }
From source file:kilim.analysis.MethodWeaver.java
License:Open Source License
private void visitAttrs(MethodVisitor mv) { MethodFlow mf = methodFlow;//from w w w . jav a 2 s . c o m // visits the method attributes int i, j, n; if (mf.annotationDefault != null) { AnnotationVisitor av = mv.visitAnnotationDefault(); MethodFlow.acceptAnnotation(av, null, mf.annotationDefault); av.visitEnd(); } n = mf.visibleAnnotations == null ? 0 : mf.visibleAnnotations.size(); for (i = 0; i < n; ++i) { AnnotationNode an = (AnnotationNode) mf.visibleAnnotations.get(i); an.accept(mv.visitAnnotation(an.desc, true)); } n = mf.invisibleAnnotations == null ? 0 : mf.invisibleAnnotations.size(); for (i = 0; i < n; ++i) { AnnotationNode an = (AnnotationNode) mf.invisibleAnnotations.get(i); an.accept(mv.visitAnnotation(an.desc, false)); } n = mf.visibleParameterAnnotations == null ? 0 : mf.visibleParameterAnnotations.length; for (i = 0; i < n; ++i) { List<?> l = mf.visibleParameterAnnotations[i]; if (l == null) { continue; } for (j = 0; j < l.size(); ++j) { AnnotationNode an = (AnnotationNode) l.get(j); an.accept(mv.visitParameterAnnotation(i, an.desc, true)); } } n = mf.invisibleParameterAnnotations == null ? 0 : mf.invisibleParameterAnnotations.length; for (i = 0; i < n; ++i) { List<?> l = mf.invisibleParameterAnnotations[i]; if (l == null) { continue; } for (j = 0; j < l.size(); ++j) { AnnotationNode an = (AnnotationNode) l.get(j); an.accept(mv.visitParameterAnnotation(i, an.desc, false)); } } n = mf.attrs == null ? 0 : mf.attrs.size(); for (i = 0; i < n; ++i) { mv.visitAttribute((Attribute) mf.attrs.get(i)); } }
From source file:org.codehaus.groovy.classgen.AsmClassGenerator.java
License:Apache License
private void visitAnnotationDefault(final MethodNode node, final MethodVisitor mv) { if (!node.hasAnnotationDefault()) return;/*from ww w .j a v a2 s . co m*/ Expression exp = ((ReturnStatement) node.getCode()).getExpression(); AnnotationVisitor av = mv.visitAnnotationDefault(); visitAnnotationDefaultExpression(av, node.getReturnType(), exp); }
From source file:org.jephyr.activeobject.instrument.ActiveObjectClassAdapter.java
License:Open Source License
private static void acceptAllBeforeCode(MethodNode methodNode, MethodVisitor mv) { if (methodNode.parameters != null) { for (ParameterNode node : methodNode.parameters) { node.accept(mv);/*from w ww.j av a 2s. c om*/ } } if (methodNode.annotationDefault != null) { AnnotationVisitor av = mv.visitAnnotationDefault(); if (av != null) { acceptAnnotation(av, null, methodNode.annotationDefault); av.visitEnd(); } } if (methodNode.visibleAnnotations != null) { for (AnnotationNode node : methodNode.visibleAnnotations) { node.accept(mv.visitAnnotation(node.desc, true)); } } if (methodNode.invisibleAnnotations != null) { for (AnnotationNode node : methodNode.invisibleAnnotations) { node.accept(mv.visitAnnotation(node.desc, false)); } } if (methodNode.visibleTypeAnnotations != null) { for (TypeAnnotationNode node : methodNode.visibleTypeAnnotations) { node.accept(mv.visitTypeAnnotation(node.typeRef, node.typePath, node.desc, true)); } } if (methodNode.invisibleTypeAnnotations != null) { for (TypeAnnotationNode node : methodNode.invisibleTypeAnnotations) { node.accept(mv.visitTypeAnnotation(node.typeRef, node.typePath, node.desc, false)); } } if (methodNode.visibleParameterAnnotations != null) { int parameter = 0; for (List<AnnotationNode> nodes : methodNode.visibleParameterAnnotations) { if (nodes != null) { for (AnnotationNode node : nodes) { node.accept(mv.visitParameterAnnotation(parameter, node.desc, true)); } } parameter++; } } if (methodNode.invisibleParameterAnnotations != null) { int parameter = 0; for (List<AnnotationNode> nodes : methodNode.invisibleParameterAnnotations) { if (nodes != null) { for (AnnotationNode node : nodes) { node.accept(mv.visitParameterAnnotation(parameter, node.desc, false)); } } parameter++; } } if (methodNode.attrs != null) { for (Attribute attribute : methodNode.attrs) { mv.visitAttribute(attribute); } } }
From source file:org.springframework.migrationanalyzer.contributions.bytecode.DelegatingMethodVisitor.java
License:Apache License
@Override public AnnotationVisitor visitAnnotationDefault() { Set<AnnotationVisitor> delegateVisitors = new HashSet<AnnotationVisitor>(); for (MethodVisitor delegate : this.delegates) { AnnotationVisitor delegateAnnotationVisitor = delegate.visitAnnotationDefault(); if (delegateAnnotationVisitor != null) { delegateVisitors.add(delegateAnnotationVisitor); }//from w w w .j av a 2s .c o m } delegateVisitors.add(this.annotationVisitor); return new DelegatingAnnotationVisitor(delegateVisitors); }