Examples of AnnotationVisitor


Examples of org.objectweb.asm.AnnotationVisitor

        // method is done, declare all variables
        variableCompiler.declareLocals(scope, scopeStart, scopeEnd);
       
        // Define the annotation for the method
        AnnotationVisitor annotation = method.visitAnnotation(ci(JRubyMethod.class), true);
        annotation.visit("name", rubyName);
        annotation.visit("frame", true);
        annotation.visit("required", scope.getRequiredArgs());
        annotation.visit("optional", scope.getOptionalArgs());
        annotation.visit("rest", scope.getRestArg());
        // TODO: reads/writes from frame
        // TODO: information on scoping
        // TODO: visibility?

        method.end();

Examples of org.objectweb.asm.AnnotationVisitor

        return new MethodVisitor(Opcodes.ASM4) {};
    }
   
    @Override
    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
        return new AnnotationVisitor(Opcodes.ASM4) {};
    }

Examples of org.objectweb.asm.AnnotationVisitor

    @Override
    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
      if (Type.getType(desc).getInternalName().equals(
              "com/google/java/contract/core/agent/ContractMethodSignature")) {
        return new AnnotationVisitor(Opcodes.ASM5) {
          @Override
          public void visit(String name, Object value) {
            if (name.equals("lines")) {
              lineNumbers = ContractMethodSignatures.getLineNumbers(value);
            }

Examples of org.objectweb.asm.AnnotationVisitor

        }
        String classFileName = periodToSlashes(className);
        cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, classFileName, null,
                 "java/lang/Object", null);

        AnnotationVisitor av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlRootElement;", true);
        av0.visit("name", wrapperElement.getLocalPart());
        av0.visit("namespace", wrapperElement.getNamespaceURI());
        av0.visitEnd();

        av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlAccessorType;", true);
        av0.visitEnum("value", "Ljavax/xml/bind/annotation/XmlAccessType;", "FIELD");
        av0.visitEnd();

        av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlType;", true);
        if (!anonymous) {
            av0.visit("name", wrapperElement.getLocalPart());
            av0.visit("namespace", wrapperElement.getNamespaceURI());
        } else {
            av0.visit("name", "");           
        }
        av0.visitEnd();

        // add constructor
        MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        Label lbegin = new Label();

Examples of org.objectweb.asm.AnnotationVisitor

        boolean q = qualified;
        SchemaInfo si = interfaceInfo.getService().getSchema(ns);
        if (si != null) {
            q = si.isElementFormQualified();
        }
        AnnotationVisitor av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlSchema;", true);
        av0.visit("namespace", ns);
        av0.visitEnum("elementFormDefault",
                      getClassCode(XmlNsForm.class),
                      q ? "QUALIFIED" : "UNQUALIFIED");
        av0.visitEnd();
        cw.visitEnd();

        loadClass(className, clz, cw.toByteArray());
    }

Examples of org.objectweb.asm.AnnotationVisitor

                                        classCode,
                                        fieldDescriptor,
                                        null);
       
       
        AnnotationVisitor av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElement;", true);
        av0.visit("name", name);
        if (factory.isWrapperPartQualified(mpi)) {
            av0.visit("namespace", mpi.getConcreteName().getNamespaceURI());           
        }
        if (factory.isWrapperPartNillable(mpi)) {
            av0.visit("nillable", Boolean.TRUE);
        }
        if (factory.getWrapperPartMinOccurs(mpi) == 1) {
            av0.visit("required", Boolean.TRUE);
        }
        av0.visitEnd();

        List<Annotation> jaxbAnnos = getJaxbAnnos(mpi);
        addJAXBAnnotations(fv, jaxbAnnos);
        fv.visitEnd();

Examples of org.objectweb.asm.AnnotationVisitor

        mv.visitEnd();

    }
    
    private void addJAXBAnnotations(FieldVisitor fv, List<Annotation> jaxbAnnos) {
        AnnotationVisitor av0;
        for (Annotation ann : jaxbAnnos) {
            if (ann instanceof XmlMimeType) {
                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlMimeType;", true);
                av0.visit("value", ((XmlMimeType)ann).value());
                av0.visitEnd();
            } else if (ann instanceof XmlJavaTypeAdapter) {
                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapter;", true);
                XmlJavaTypeAdapter adapter = (XmlJavaTypeAdapter)ann;
                if (adapter.value() != null) {
                    av0.visit("value", org.objectweb.asm.Type.getType(getClassCode(adapter.value())));
                }
                if (adapter.type() != javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT.class) {
                    av0.visit("type", org.objectweb.asm.Type.getType(getClassCode(adapter.type())));
                }
                av0.visitEnd();
            } else if (ann instanceof XmlAttachmentRef) {
                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlAttachmentRef;", true);
                av0.visitEnd();
            } else if (ann instanceof XmlList) {
                av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlList;", true);
                av0.visitEnd();
            }
        }
    }

Examples of org.objectweb.asm.AnnotationVisitor

                                boolean isElement,
                                boolean isNillable,
                                String xmlAdapterClassSignature,
                                List<Annotation> jaxbAnnotations) {
        FieldVisitor fv;
        AnnotationVisitor av0;
        fv = cw.visitField(ACC_PROTECTED, getFieldName(propName), propClassSignature, propTypeSignature, null);

        // For Map property, we cannot have the XmlElement annotation
        if (isElement && xmlAdapterClassSignature == null) {
            av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlElement;", true);
            av0.visit("name", propName);
            av0.visit("namespace", "");
            if (isNillable) {
                av0.visit("nillable", Boolean.TRUE);
            }
            // FIXME:
            // av0.visit("required", Boolean.FALSE);
            av0.visitEnd();
        }

        if (xmlAdapterClassSignature != null) {
            av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlAnyElement;", true);
            av0.visit("lax", Boolean.TRUE);
            av0.visitEnd();
            av0 = fv.visitAnnotation("Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapter;", true);
            av0.visit("value", org.objectweb.asm.Type.getType(xmlAdapterClassSignature));
            av0.visitEnd();
        }

        for (Annotation ann : jaxbAnnotations) {
            if (ann instanceof XmlMimeType) {
                AnnotationVisitor mime = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlMimeType;", true);
                mime.visit("value", ((XmlMimeType)ann).value());
                mime.visitEnd();
            } else if (ann instanceof XmlJavaTypeAdapter) {
                AnnotationVisitor ada = fv.visitAnnotation("Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapter;", true);
                ada.visit("value", org.objectweb.asm.Type.getType(((XmlJavaTypeAdapter)ann).value()));
                ada.visit("type", org.objectweb.asm.Type.getType(((XmlJavaTypeAdapter)ann).type()));
                ada.visitEnd();
            } else if (ann instanceof XmlAttachmentRef) {
                AnnotationVisitor att = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlAttachmentRef;", true);
                att.visitEnd();
            } else if (ann instanceof XmlList) {
                AnnotationVisitor list = fv.visitAnnotation("Ljavax/xml/bind/annotation/XmlList;", true);
                list.visitEnd();
            }
        }

        fv.visitEnd();
    }

Examples of org.objectweb.asm.AnnotationVisitor

    protected void declareClass(ClassWriter cw, String classDescriptor) {
        cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, classDescriptor, null, "java/lang/Object", null);
    }

    protected void annotateClass(ClassWriter cw, String name, String namespace, String[] propOrder) {
        AnnotationVisitor av0;
        // @XmlRootElement
        av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlRootElement;", true);
        av0.visit("name", name);
        av0.visit("namespace", namespace);
        av0.visitEnd();
        // @XmlAccessorType
        av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlAccessorType;", true);
        av0.visitEnum("value", "Ljavax/xml/bind/annotation/XmlAccessType;", "FIELD");
        av0.visitEnd();
        // @XmlType
        av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlType;", true);
        av0.visit("name", name);
        av0.visit("namespace", namespace);
        if (propOrder != null) {
            AnnotationVisitor pv = av0.visitArray("propOrder");
            for (String p : propOrder) {
                pv.visit(null, p);
            }
            pv.visitEnd();
        }
        av0.visitEnd();
    }

Examples of org.objectweb.asm.AnnotationVisitor

        }
        String classFileName = periodToSlashes(className);
        cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, classFileName, null,
                 "java/lang/Object", null);

        AnnotationVisitor av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlRootElement;", true);
        av0.visit("name", wrapperElement.getLocalPart());
        av0.visit("namespace", wrapperElement.getNamespaceURI());
        av0.visitEnd();

        av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlAccessorType;", true);
        av0.visitEnum("value", "Ljavax/xml/bind/annotation/XmlAccessType;", "FIELD");
        av0.visitEnd();

        av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/XmlType;", true);
        if (!anonymous) {
            av0.visit("name", wrapperElement.getLocalPart());
            av0.visit("namespace", wrapperElement.getNamespaceURI());
        } else {
            av0.visit("name", "");           
        }
        av0.visitEnd();

        // add constructor
        MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
        mv.visitCode();
        Label lbegin = new Label();
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.