Package org.codehaus.backport175.compiler.parser

Examples of org.codehaus.backport175.compiler.parser.AnnotationValidator


    public Annotation getAnnotation(final String annotationName) {
        Object cachedAnnotation = m_classAnnotationCache.get(annotationName);
        if (cachedAnnotation != null) {
            return (Annotation)cachedAnnotation;
        } else {
            final Annotation annotation;
            final AnnotationElement.Annotation annotationInfo =
                    (AnnotationElement.Annotation)m_classAnnotationElements.get(annotationName);
            if (annotationInfo != null) {
                annotation = ProxyFactory.newAnnotationProxy(
                        annotationInfo,
View Full Code Here


            // no such annotation
            return null;
        }
        Object annotationElement = annotations.get(annotationName);
        if (annotationElement != null) {
            Annotation annotation = ProxyFactory.newAnnotationProxy(
                    (AnnotationElement.Annotation)annotationElement,
                    constructor.getDeclaringClass().getClassLoader()
            );
            annotationMap.put(annotationName, annotation);
            return annotation;
View Full Code Here

            // no such annotation
            return null;
        }
        Object annotationElement = annotations.get(annotationName);
        if (annotationElement != null) {
            Annotation annotation = ProxyFactory.newAnnotationProxy(
                    (AnnotationElement.Annotation)annotationElement,
                    method.getDeclaringClass().getClassLoader()
            );
            annotationMap.put(annotationName, annotation);
            return annotation;
View Full Code Here

            // no such annotation
            return null;
        }
        Object annotationElement = annotations.get(annotationName);
        if (annotationElement != null) {
            Annotation annotation = ProxyFactory.newAnnotationProxy(
                    (AnnotationElement.Annotation)annotationElement,
                    field.getDeclaringClass().getClassLoader()
            );
            annotationMap.put(annotationName, annotation);
            return annotation;
View Full Code Here

                String annotationClassName = annotationElement.getInterfaceName();
                if (annotationCache.containsKey(annotationClassName)) {
                    // proxy in cache - reuse
                    annotations[i++] = (Annotation)annotationCache.get(annotationClassName);
                } else {
                    final Annotation annotation = ProxyFactory.newAnnotationProxy(annotationElement, loader);
                    annotationCache.put(annotationClassName, annotation);
                    annotations[i++] = annotation;
                }
            }
            return annotations;
View Full Code Here

            final ClassLoader loader = annotationClass.getClassLoader();
            final byte[] bytes;
            try {
                bytes = AnnotationReader.BYTECODE_PROVIDER.getBytecode(className, loader);
            } catch (Exception e) {
                throw new ReaderException("could not retrieve the bytecode from the bytecode provider [" + AnnotationReader.BYTECODE_PROVIDER.getClass().getName() + "]", e);
            }
            ClassReader cr = new ClassReader(bytes);
            ClassWriter cw = new ClassWriter(false, true);
            cr.accept(
                    new ClassAdapter(cw) {
View Full Code Here

        final ClassLoader loader = klass.getClassLoader();
        final byte[] bytes;
        try {
            bytes = BYTECODE_PROVIDER.getBytecode(className, loader);
        } catch (Exception e) {
            throw new ReaderException("could not retrieve the bytecode from the bytecode provider [" + BYTECODE_PROVIDER.getClass().getName() + "]", e);
        }
        ClassReader classReader = new ClassReader(bytes);
        ClassWriter writer = new ClassWriter(true);
        classReader.accept(new AnnotationRetrievingVisitor(writer), false);
    }
View Full Code Here

public class PerfTest extends TestCase {
    private static int INVOCATIONS = 100000;

    public void setUp() {
        // warm up
        final AnnotationReader reader = AnnotationReader.getReaderFor(test.reader.Target.METHOD.getDeclaringClass());
        reader.getAnnotation("test.TestAnnotations$VoidTyped", test.reader.Target.METHOD);
        Target5.METHOD.getAnnotation(Target5.Test.class);
    }
View Full Code Here

    }

    public void testAccessAnnotation() {
        long startTime = System.currentTimeMillis();
        for (int i = 0; i < INVOCATIONS; i++) {
            final AnnotationReader reader = AnnotationReader.getReaderFor(test.reader.Target.METHOD.getDeclaringClass());
            Annotation annotation = reader.getAnnotation("test.TestAnnotations$VoidTyped", test.reader.Target.METHOD);
        }
        long time = System.currentTimeMillis() - startTime;
        double timePerInvocationNormalMethod = time / (double) INVOCATIONS;
        System.out.println("backport175 API : " + timePerInvocationNormalMethod);
    }
View Full Code Here

     * @param annotation the annotation class
     * @param target      the java.lang.Class object to find the annotation on.
     * @return the annotation or null
     */
    public static Annotation getAnnotation(final Class annotation, final Class target) {
        final AnnotationReader reader = AnnotationReader.getReaderFor(target);
        return reader.getAnnotation(getAnnnotationName(annotation));
    }
View Full Code Here

TOP

Related Classes of org.codehaus.backport175.compiler.parser.AnnotationValidator

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.