Search in sources :

Example 6 with AnnotationVisitor

use of org.objectweb.asm.AnnotationVisitor in project presto by prestodb.

the class AnnotationDefinition method visitMethodAnnotation.

public void visitMethodAnnotation(MethodVisitor visitor) {
    AnnotationVisitor annotationVisitor = visitor.visitAnnotation(type.getType(), true);
    visit(annotationVisitor);
    annotationVisitor.visitEnd();
}
Also used : AnnotationVisitor(org.objectweb.asm.AnnotationVisitor)

Example 7 with AnnotationVisitor

use of org.objectweb.asm.AnnotationVisitor in project presto by prestodb.

the class AnnotationDefinition method visitParameterAnnotation.

public void visitParameterAnnotation(int parameterIndex, MethodVisitor visitor) {
    AnnotationVisitor annotationVisitor = visitor.visitParameterAnnotation(parameterIndex, type.getType(), true);
    visit(annotationVisitor);
    annotationVisitor.visitEnd();
}
Also used : AnnotationVisitor(org.objectweb.asm.AnnotationVisitor)

Example 8 with AnnotationVisitor

use of org.objectweb.asm.AnnotationVisitor in project quasar by puniverse.

the class InstrumentClass method emitInstrumentedAnn.

private void emitInstrumentedAnn() {
    final AnnotationVisitor instrumentedAV = visitAnnotation(INSTRUMENTED_DESC, true);
    instrumentedAV.visitEnd();
}
Also used : AnnotationVisitor(org.objectweb.asm.AnnotationVisitor)

Example 9 with AnnotationVisitor

use of org.objectweb.asm.AnnotationVisitor in project quasar by puniverse.

the class AnnotationUtil method hasClassAnnotation.

private static boolean hasClassAnnotation(Class<? extends Annotation> annClass, ClassReader r) {
    // annotationName = annotationName.replace('.', '/');
    final String annDesc = Type.getDescriptor(annClass);
    final AtomicBoolean res = new AtomicBoolean(false);
    r.accept(new ClassVisitor(ASMAPI) {

        @Override
        public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
        }

        @Override
        public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
            if (desc.equals(annDesc))
                res.set(true);
            return null;
        }
    }, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG);
    return res.get();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) AnnotationVisitor(org.objectweb.asm.AnnotationVisitor) ClassVisitor(org.objectweb.asm.ClassVisitor)

Example 10 with AnnotationVisitor

use of org.objectweb.asm.AnnotationVisitor in project robovm by robovm.

the class InterfaceBuilderClassesPlugin method getCustomClass.

private String getCustomClass(URL url, Map<URL, String> customClassValuesCache) throws IOException {
    if (customClassValuesCache.containsKey(url)) {
        return customClassValuesCache.get(url);
    }
    class Visitor extends ClassVisitor {

        String customClass;

        Visitor() {
            super(Opcodes.ASM4);
        }

        @Override
        public AnnotationVisitor visitAnnotation(final String desc, boolean visible) {
            if (CUSTOM_CLASS.equals(desc)) {
                return new AnnotationVisitor(Opcodes.ASM4) {

                    public void visit(String name, Object value) {
                        customClass = (String) value;
                    }
                };
            }
            return super.visitAnnotation(desc, visible);
        }
    }
    Visitor visitor = new Visitor();
    new ClassReader(IOUtils.toByteArray(url)).accept(visitor, 0);
    customClassValuesCache.put(url, visitor.customClass);
    return visitor.customClass;
}
Also used : AnnotationVisitor(org.objectweb.asm.AnnotationVisitor) ClassVisitor(org.objectweb.asm.ClassVisitor) AnnotationVisitor(org.objectweb.asm.AnnotationVisitor) ClassReader(org.objectweb.asm.ClassReader) ClassVisitor(org.objectweb.asm.ClassVisitor)

Aggregations

AnnotationVisitor (org.objectweb.asm.AnnotationVisitor)64 AnnotationNode (org.codehaus.groovy.ast.AnnotationNode)12 ArrayList (java.util.ArrayList)9 Type (org.objectweb.asm.Type)9 MethodVisitor (org.objectweb.asm.MethodVisitor)7 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)6 ClassNode (org.codehaus.groovy.ast.ClassNode)6 InnerClassNode (org.codehaus.groovy.ast.InnerClassNode)6 InterfaceHelperClassNode (org.codehaus.groovy.ast.InterfaceHelperClassNode)6 ClassVisitor (org.objectweb.asm.ClassVisitor)6 ClassReader (org.objectweb.asm.ClassReader)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 FieldVisitor (org.objectweb.asm.FieldVisitor)3 Label (org.objectweb.asm.Label)3 GroovyRuntimeException (groovy.lang.GroovyRuntimeException)2 InputStream (java.io.InputStream)2 List (java.util.List)2 GroovyBugError (org.codehaus.groovy.GroovyBugError)2 GenericsType (org.codehaus.groovy.ast.GenericsType)2