Package org.apache.xbean.asm5

Examples of org.apache.xbean.asm5.ClassWriter


        }
        return createSignature(collectionType, type);
    }

    public String getProxyDescriptor() {
        final Type collectionType = cmrStyle.getCollectionType();
        if (collectionType == null) {
            return proxyType.getDescriptor();
        }
        return collectionType.getDescriptor();
    }
View Full Code Here


    public String getAccessorDescriptor() {
        return cmrStyle.getAccessorType().getDescriptor();
    }

    public String getAccessorGenericSignature() {
        final Type collectionType = cmrStyle.getCollectionType();
        if (collectionType == null) {
            return null;
        }
        return createSignature(cmrStyle.getAccessorType(), type, proxyType);
    }
View Full Code Here

            if ("Ljavax/persistence/PersistenceContext;".equals(desc)) {
                return new PersistenceContextVisitor(className, currentName, contexts);
            } else if ("Ljavax/persistence/PersistenceContexts;".equals(desc)) {
                return super.visitAnnotation(name, desc);
            }
            return new EmptyVisitor().annotationVisitor();
        }
View Full Code Here

            return annotationVisitor();
        }

        @Override
        public AnnotationVisitor visitMethodParameterAnnotation(final int i, final String string, final boolean b) {
            return new EmptyVisitor().annotationVisitor();
        }
View Full Code Here

            return new EmptyVisitor().annotationVisitor();
        }

        @Override
        public AnnotationVisitor visitParameterAnnotation(final int i, final String string, final boolean b) {
            return new EmptyVisitor().annotationVisitor();
        }
View Full Code Here

            return new EmptyVisitor().annotationVisitor();
        }

        @Override
        public AnnotationVisitor visitAnnotationDefault() {
            return new EmptyVisitor().annotationVisitor();
        }
View Full Code Here

                persistenceContext.type = value;
            }
        }

        public AnnotationVisitor visitArray(final String string) {
            return new EmptyVisitor() {
                private String name;
                private String value;

                public void visit(final String n, final Object v) {
                    if ("name".equals(n)) {
View Full Code Here

        }
    }

    private void addSignature(final String signature) {
        if (signature != null) {
            new SignatureReader(signature).accept(new SignatureAdapter(this));
        }
    }
View Full Code Here

        }
    }

    private void addTypeSignature(final String signature) {
        if (signature != null) {
            new SignatureReader(signature).acceptType(new SignatureAdapter(this));
        }
    }
View Full Code Here

    public SubClassGenerator(ClassLoader parent) {
        super(parent);
    }

    public <T> Class<? extends T> generate(Class<T> base, String name) {
        ClassWriter cw = new ClassWriter(0);//?
        cw.visit(49, ACC_PUBLIC, name.replace('.', '/'), null,
                Type.getInternalName(base),null);

        for (Constructor c : base.getDeclaredConstructors()) {
            Class[] et = c.getExceptionTypes();
            String[] exceptions = new String[et.length];
            for (int i = 0; i < et.length; i++)
                exceptions[i] = Type.getInternalName(et[i]);

            String methodDescriptor = getMethodDescriptor(c);
            MethodVisitor m = cw.visitMethod(c.getModifiers(), "<init>", methodDescriptor, null, exceptions);
            m.visitCode();

            int index=1;
            m.visitVarInsn(ALOAD,0);
            for (Class param : c.getParameterTypes()) {
                Type t = Type.getType(param);
                m.visitVarInsn(t.getOpcode(ILOAD), index);
                index += t.getSize();
            }
            m.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(base), "<init>", methodDescriptor);
            m.visitInsn(RETURN);
            m.visitMaxs(index,index);
            m.visitEnd();
        }

        cw.visitEnd();
        byte[] image = cw.toByteArray();

        Class<? extends T> c = defineClass(name, image, 0, image.length).asSubclass(base);

        Jenkins h = Jenkins.getInstance();
        if (h!=null)    // null only during tests.
View Full Code Here

TOP

Related Classes of org.apache.xbean.asm5.ClassWriter

Copyright © 2018 www.massapicom. 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.