Package org.apache.xbean.asm5

Examples of org.apache.xbean.asm5.FieldVisitor


    }

    // create new field wrapper field and store it's reference into work-data
    wd.wrapperRef = targetFieldName;
    wd.wrapperType = 'L' + name + ';';
    FieldVisitor fv  = wd.dest.visitField(AsmUtil.ACC_PUBLIC, wd.wrapperRef, wd.wrapperType, null, null);
    fv.visitEnd();

    createEmptyCtor();
  }
View Full Code Here


        }

        @Override
        public FieldVisitor visitField(final int access, final String name, final String desc, final String signature,
            final Object value) {
            final FieldVisitor toWrap = wrapped.visitField(access, name, desc, signature, value);
            final ClassInfo classInfo = (ClassInfo) wrapped.getInfo();
            FieldInfo testFieldInfo = null;
            // should be the most recently added field, so iterate backward:
            for (int i = classInfo.getFields().size() - 1; i >= 0; i--) {
                final FieldInfo atI = classInfo.getFields().get(i);
                if (atI.getName().equals(name) && atI.getType().equals(desc)) {
                    testFieldInfo = atI;
                    break;
                }
            }
            if (testFieldInfo == null) {
                return toWrap;
            }
            final FieldInfo fieldInfo = testFieldInfo;
            return new FieldVisitor(Opcodes.ASM4, toWrap) {
                @Override
                public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
                    final AnnotationVisitor toWrap = super.visitAnnotation(desc, visible);
                    return visible ? toWrap : new TopLevelAnnotationInflater(desc, toWrap, fieldInfo);
                }
View Full Code Here

        // EntityBean and Cmp2Entity.
        cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, implClassName, null, beanClassName, new String[]{"org/apache/openejb/core/cmp/cmp2/Cmp2Entity", "javax/ejb/EntityBean"});

        // public static Object deploymentInfo;
        {
            FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_STATIC, "deploymentInfo", "Ljava/lang/Object;", null, null);
            fv.visitEnd();
        }

        // private transient boolean deleted;
        {
            FieldVisitor fv = cw.visitField(ACC_PRIVATE + ACC_TRANSIENT, DELETED, "Z", null, null);
            fv.visitEnd();
        }

        if (Object.class.equals(primKeyClass)) {
            FieldVisitor fv = cw.visitField(ACC_PRIVATE, UNKNOWN_PK_NAME, UNKNOWN_PK_TYPE.getDescriptor(), null, null);
            fv.visitEnd();
        }

        // Generate the set of cmp fields as private attributes.
        // private ${cmpField.type} ${cmpField.name};
        for (CmpField cmpField : cmpFields.values()) {
View Full Code Here

     * with private scope.
     *
     * @param cmpField The Cmp field defined in the metadata.
     */
    private void createField(CmpField cmpField) {
        FieldVisitor fv = cw.visitField(ACC_PRIVATE,
                cmpField.getName(),
                cmpField.getDescriptor(),
                null,
                null);
        fv.visitEnd();
    }
View Full Code Here

     * of the field name.
     *
     * @param cmrField The CMR field descriptor.
     */
    private void createCmrFields(CmrField cmrField) {
        FieldVisitor fv = cw.visitField(ACC_PRIVATE,
                cmrField.getName(),
                cmrField.getDescriptor(),
                cmrField.getGenericSignature(),
                null);
        fv.visitEnd();

        fv = cw.visitField(ACC_PRIVATE + ACC_TRANSIENT,
                cmrField.getName() + "Cmr",
                cmrField.getAccessorDescriptor(),
                cmrField.getAccessorGenericSignature(),
                null);
        fv.visitEnd();
    }
View Full Code Here

        cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, implClassName, null, beanClassName, new String[]{"javax/ejb/EntityBean"});

        // if we have an unknown pk, we need to add a field for the pk
        if (unknownPk) {
            // public Long OpenEJB_pk;
            FieldVisitor fv = cw.visitField(ACC_PUBLIC, "OpenEJB_pk", "Ljava/lang/Long;", null, null);
            fv.visitEnd();
        }

        // there's not much to generate here.  We create a default constructor, then generate the
        // post create methods.  A lot of the work is done by having mapped superclass information that
        // we pass to the JPA engine.
View Full Code Here

    private static byte[] toJava7ByteArray(BCClass bc, byte[] classBytes) throws IOException {
        ByteArrayInputStream bais = new ByteArrayInputStream(classBytes);
        BufferedInputStream bis = new BufferedInputStream(bais);

        ClassWriter cw = new BCClassWriter(ClassWriter.COMPUTE_FRAMES, bc.getClassLoader());
        ClassReader cr = new ClassReader(bis);
        cr.accept(cw, 0);
        return cw.toByteArray();
    }
View Full Code Here

    private static void file(final File file, final KeysAnnotationVisitor visitor) {
        try {
            final InputStream in = IO.read(file);
            try {
                final ClassReader classReader = new ClassReader(in);
                classReader.accept(visitor, ClassWriter.COMPUTE_FRAMES);
            } finally {
                IO.close(in);
            }
        } catch (final IOException e) {
            e.printStackTrace();
View Full Code Here

            final URL resource = classLoader.getResource(className);
            if (resource != null) {
                InputStream in = resource.openStream();
                in = new BufferedInputStream(in);
                try {
                    final ClassReader classReader = new ClassReader(in);
                    classReader.accept(visitor, ASM_FLAGS);
                } finally {
                    in.close();
                }
            } else {
                new Exception("Could not load " + className).printStackTrace();
View Full Code Here

            return;
        }

        try {
            final URL u = c.getResource("/" + c.getName().replace('.', '/') + ".class");
            final ClassReader r = new ClassReader(IO.read(u));
            r.accept(new PersistenceContextReader(contexts), ClassReader.SKIP_DEBUG);
        } catch (final IOException e) {
            throw new OpenEJBException("Unable to read class " + c.getName());
        }

        processed.add(c.getName());
View Full Code Here

TOP

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

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.