Package org.codehaus.backport175.compiler.parser.ast

Examples of org.codehaus.backport175.compiler.parser.ast.ASTOct


     * @param field
     */
    private void handleFieldAnnotations(final AnnotationEnhancer enhancer, final JavaField field) {
        DocletTag[] tags = field.getTags();
        for (int i = 0; i < tags.length; i++) {
            RawAnnotation rawAnnotation = getRawAnnotation(
                    tags[i], enhancer.getClassName(), enhancer.getClassFileName()
            );
            if (rawAnnotation == null) {
                continue;
            }
            enhancer.insertFieldAnnotation(field, rawAnnotation);
            logInfo("\tprocessing field annotation [" + rawAnnotation.getName() + " @ " + field.getName() + ']');
        }
    }
View Full Code Here


        public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
            // handles runtime retention to expose 1.4 annotations under 1.5
            boolean hasRetention = false;
            for (Iterator iterator = m_classAnnotations.iterator(); iterator.hasNext();) {
                RawAnnotation rawAnnotation = (RawAnnotation) iterator.next();
                if (rawAnnotation.getName().equals("java.lang.annotation.Retention")) {
                    hasRetention = true;
                    break;
                }
            }
            if (hasRetention) {
View Full Code Here

            return methodVisitor;
        }

        public void visitEnd() {
            for (Iterator it = m_classAnnotations.iterator(); it.hasNext();) {
                final RawAnnotation rawAnnotation = (RawAnnotation)it.next();
                final Class annIntf = rawAnnotation.getAnnotationClass();
                final AnnotationVisitor bytecodeMunger = visitAnnotation(
                        Type.getDescriptor(annIntf),
                        true
                );
                AnnotationParser.parse(bytecodeMunger, annIntf, rawAnnotation);
View Full Code Here

        if (m_reader == null) {
            throw new IllegalStateException("annotation enhancer is not initialized");
        }
        MethodAnnotationInfo info = new MethodAnnotationInfo(method, annotation);
        if (hasMethodAnnotation(info)) {
            throw new ParseException(
                    "duplicate method annotation " + annotation,
                    SourceLocation.render(annotation)
            );
        }
        m_methodAnnotations.add(new MethodAnnotationInfo(method, annotation));
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

        java.lang.annotation.Annotation[] annotations = Target5.METHOD.getAnnotations();
        assertEquals(1, annotations.length);
    }

    public void testJava5ClassAnnotation() {
        Annotation reader = org.codehaus.backport175.reader.Annotations.getAnnotation(
                Target5.Test.class, Target5.class
        );
        Class type = reader.annotationType();
        assertEquals(Target5.Test.class, type);

        Target5.Test test = (Target5.Test)reader;
        assertEquals("test", test.test());
    }
View Full Code Here

        Target5.Test test = (Target5.Test)reader;
        assertEquals("test", test.test());
    }

    public void testJava5ConstructorAnnotation() {
        Annotation reader = org.codehaus.backport175.reader.Annotations.getAnnotation(
                Target5.Test.class, Target5.CONSTRUCTOR
        );
        Class type = reader.annotationType();
        assertEquals(Target5.Test.class, type);

        Target5.Test test = (Target5.Test)reader;
        assertEquals("test", test.test());
    }
View Full Code Here

        Target5.Test test = (Target5.Test)reader;
        assertEquals("test", test.test());
    }

    public void testJava5MethodAnnotation() {
        Annotation reader = org.codehaus.backport175.reader.Annotations.getAnnotation(
                Target5.Test.class, Target5.METHOD
        );
        Class type = reader.annotationType();
        assertEquals(Target5.Test.class, type);

        Target5.Test test = (Target5.Test)reader;
        assertEquals("test", test.test());
    }
View Full Code Here

        Target5.Test test = (Target5.Test)reader;
        assertEquals("test", test.test());
    }

    public void testJava5FieldAnnotation() {
        Annotation reader = org.codehaus.backport175.reader.Annotations.getAnnotation(
                Target5.Test.class, Target5.FIELD
        );
        Class type = reader.annotationType();
        assertEquals(Target5.Test.class, type);

        Target5.Test test = (Target5.Test)reader;
        assertEquals("test", test.test());
    }
View Full Code Here

        AnnotationElement.Annotation e = AnnotationDefaults.getDefaults(Target5.DefaultedTest.class);
        assertEquals(2, e.getElements().size());
        assertEquals("test=1", (e.getElements().get(0)).toString());
        assertEquals("test2=default", (e.getElements().get(1)).toString());

        Annotation defaulted = Annotations.getAnnotation(Target5.DefaultedTest.class, Target5.class);
        assertNotNull(defaulted);
        assertEquals(1, ((Target5.DefaultedTest)defaulted).test());
        assertEquals("notdefault", ((Target5.DefaultedTest)defaulted).test2());
    }
View Full Code Here

TOP

Related Classes of org.codehaus.backport175.compiler.parser.ast.ASTOct

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.