Package org.apache.xbean.asm4

Examples of org.apache.xbean.asm4.ClassReader


     * Fast-parse the given class bytecode to determine if it is an
     * annotation class.
     */
    private static boolean isAnnotationClass(final byte[] bytes) {
        final IsAnnotationVisitor isAnnotationVisitor = new IsAnnotationVisitor();
        final ClassReader classReader = new ClassReader(bytes);
        classReader.accept(isAnnotationVisitor, ClassReader.SKIP_DEBUG);
        return isAnnotationVisitor.isAnnotation;
    }
View Full Code Here


    public static byte[] addNewField(final byte[] origBytes) {
        final ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES);

        final FieldAdderClassVisitor visitor = new FieldAdderClassVisitor(classWriter);

        final ClassReader classReader = new ClassReader(origBytes);
        classReader.accept(visitor, 0);

        return classWriter.toByteArray();
    }
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

            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

        // Move all the annotations onto the newly implemented methods
        // Ensures CDI and JAX-RS and JAX-WS still work
        Class clazz = classToProxy;
        while (clazz != null && !clazz.equals(Object.class)) {
            try {
                final ClassReader classReader = new ClassReader(readClassFile(clazz));
                final ClassVisitor copyMethodAnnotations = new CopyMethodAnnotations(visitors);
                classReader.accept(copyMethodAnnotations, ClassReader.SKIP_CODE);
            } catch (final IOException e) {
                throw new ProxyGenerationException(e);
            }
            clazz = clazz.getSuperclass();
        }
View Full Code Here

        }
    }

    private static void copyClassAnnotations(final Class<?> clazz, final ClassVisitor newClass) throws ProxyGenerationException {
        try {
            final ClassReader classReader = new ClassReader(readClassFile(clazz));
            final ClassVisitor visitor = new CopyClassAnnotations(newClass);
            classReader.accept(visitor, ClassReader.SKIP_CODE);
        } catch (final IOException e) {
            throw new ProxyGenerationException(e);
        }
    }
View Full Code Here

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

    public static byte[] addNewField(final byte[] origBytes) {
        final ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES);

        final FieldAdderClassVisitor visitor = new FieldAdderClassVisitor(classWriter);

        final ClassReader classReader = new ClassReader(origBytes);
        classReader.accept(visitor, 0);

        return classWriter.toByteArray();
    }
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

        // Move all the annotations onto the newly implemented methods
        // Ensures CDI and JAX-RS and JAX-WS still work
        Class clazz = classToProxy;
        while (clazz != null && !clazz.equals(Object.class)) {
            try {
                final ClassReader classReader = new ClassReader(readClassFile(clazz));
                final ClassVisitor copyMethodAnnotations = new CopyMethodAnnotations(visitors);
                classReader.accept(copyMethodAnnotations, ClassReader.SKIP_CODE);
            } catch (final IOException e) {
                throw new ProxyGenerationException(e);
            }
            clazz = clazz.getSuperclass();
        }
View Full Code Here

TOP

Related Classes of org.apache.xbean.asm4.ClassReader

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.