Package org.codehaus.backport175.reader.bytecode

Examples of org.codehaus.backport175.reader.bytecode.AnnotationElement$NestedAnnotationElement


        assertFalse(Annotations.isAnnotationPresent(Target.class, Target.METHOD));
    }

    public void testMethodNoSuchAnn() throws Throwable {
        Method m = AnnotationReaderTest.class.getDeclaredMethod("testToString", new Class[]{});
        final AnnotationReader reader = AnnotationReader.getReaderFor(m.getDeclaringClass());
        reader.getAnnotation("waza", m);
    }
View Full Code Here


        final AnnotationReader reader = AnnotationReader.getReaderFor(m.getDeclaringClass());
        reader.getAnnotation("waza", m);
    }

    public void testMethodAnn1() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.METHOD.getDeclaringClass());
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$VoidTyped", Target.METHOD);
        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.VoidTyped.class, type);
    }
View Full Code Here

        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.VoidTyped.class, type);
    }

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

        TestAnnotations.DefaultString ann = (TestAnnotations.DefaultString)annotation;
        assertEquals("hello", ann.value());
View Full Code Here

        TestAnnotations.DefaultString ann = (TestAnnotations.DefaultString)annotation;
        assertEquals("hello", ann.value());
    }

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

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

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

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

        TestAnnotations.StringArray ann = (TestAnnotations.StringArray)annotation;
        String[] ss = ann.ss();
View Full Code Here

        assertEquals("hello", ss[0]);
        assertEquals("world", ss[1]);
    }

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

        TestAnnotations.LongArray ann = (TestAnnotations.LongArray)annotation;
        long[] longArr = ann.l();
View Full Code Here

        assertEquals(2l, longArr[1]);
        assertEquals(6l, longArr[2]);
    }

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

        TestAnnotations.NestedAnnotation ann = (TestAnnotations.NestedAnnotation)annotation;
        TestAnnotations.Simple simple = ann.ann();
View Full Code Here

        TestAnnotations.Simple simple = ann.ann();
        assertEquals("foo", simple.val());
    }

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

        TestAnnotations.NestedAnnotationArray ann = (TestAnnotations.NestedAnnotationArray)annotation;
        TestAnnotations.Simple[] simpleAnnArray = ann.annArr();
View Full Code Here

        assertEquals("foo", simpleAnnArray[0].val());
        assertEquals("bar", simpleAnnArray[1].val());
    }

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

        TestAnnotations.Complex ann = (TestAnnotations.Complex)annotation;
        assertEquals(111, ann.i());
View Full Code Here

        assertTrue(set.contains(TestAnnotations.LongArray.class));
        annotations = Annotations.getAnnotations(Target.METHOD);
    }

    public void testReadInResolvedValues() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.METHOD.getDeclaringClass());
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$Complex", Target.METHOD);
        TestAnnotations.Complex ann = (TestAnnotations.Complex)annotation;
        assertEquals(111, ann.i());
        double[] doubleArr = ann.doubleArr();
        assertEquals(1.1D, doubleArr[0], 0);
        assertEquals(2.2D, doubleArr[1], 0);
        assertEquals(3.3D, doubleArr[2], 0);
        assertEquals(4.4D, doubleArr[3], 0);
        assertEquals(double[][][].class, ann.type());
        Class[] types = ann.typeArr();
        assertEquals(Target[].class, types[0]);
        assertEquals(Target.class, types[1]);
        AnnotationElement.Type enumRef = ann.enumeration();
        assertTrue(enumRef.equals(AnnotationElement.Type.ANNOTATION));

        // second time -> values are not resolved again but cache is used
        final AnnotationReader reader1 = AnnotationReader.getReaderFor(Target.METHOD.getDeclaringClass());
        annotation = reader1.getAnnotation("test.TestAnnotations$Complex", Target.METHOD);
        ann = (TestAnnotations.Complex)annotation;
        assertEquals(111, ann.i());
        doubleArr = ann.doubleArr();
        assertEquals(1.1D, doubleArr[0], 0);
        assertEquals(2.2D, doubleArr[1], 0);
View Full Code Here

TOP

Related Classes of org.codehaus.backport175.reader.bytecode.AnnotationElement$NestedAnnotationElement

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.