Package org.codehaus.backport175.reader.bytecode

Examples of org.codehaus.backport175.reader.bytecode.AnnotationReader


            }
            destDirToUse = classpath[0];
        }

        // set up the parser sources
        final JavaDocParser javaDocParser = new JavaDocParser();
        try {
            // add classloader
            javaDocParser.addClassLoaderToSearchPath(compilationLoader);

            // add src dirs
            StringBuffer logDirs = new StringBuffer("parsing source dirs:");
            for (int i = 0; i < srcDirs.length; i++) {
                logDirs.append("\n\t" + srcDirs[i]);
            }
            messageHandler.info(logDirs.toString());
            javaDocParser.addSourceTrees(srcDirs);

            // add src files
            logDirs = new StringBuffer();
            for (int i = 0; i < srcFiles.length; i++) {
                logDirs.append("\n\t" + srcFiles[i]);
                javaDocParser.addSource(srcFiles[i]);
            }
            if (srcFiles.length > 0) {
                messageHandler.info(logDirs.toString());
            }
View Full Code Here


     * @param clazz
     */
    private void handleClassAnnotations(final AnnotationEnhancer enhancer, final JavaClass clazz) {
        DocletTag[] tags = clazz.getTags();
        for (int i = 0; i < tags.length; i++) {
            RawAnnotation rawAnnotation = getRawAnnotation(
                    tags[i], enhancer.getClassName(), enhancer.getClassFileName()
            );
            if (rawAnnotation == null) {
                continue;
            }
            enhancer.insertClassAnnotation(rawAnnotation);
            logInfo(
                    "\tprocessing class annotation [" + rawAnnotation.getName() + " @ "
                    + clazz.getFullyQualifiedName() + ']'
            );
        }
    }
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

        assertEquals("hello", ann.value());
    }

    public void testFieldAnn3() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.FIELD.getDeclaringClass());
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$Simple", Target.FIELD);
        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.Simple.class, type);

        TestAnnotations.Simple ann = (TestAnnotations.Simple)annotation;
        assertEquals("foo", ann.val());
        assertEquals("bar", ann.s());
View Full Code Here

        assertEquals("bar", ann.s());
    }

    public void testFieldAnn4() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.FIELD.getDeclaringClass());
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$StringArray", Target.FIELD);
        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.StringArray.class, type);

        TestAnnotations.StringArray ann = (TestAnnotations.StringArray)annotation;
        String[] ss = ann.ss();
        assertEquals("hello", ss[0]);
View Full Code Here

TOP

Related Classes of org.codehaus.backport175.reader.bytecode.AnnotationReader

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.