Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8038994

AnnotatedType.getType() of a TypeVariable boundary without annotations return null

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 9
    • 8
    • core-libs
    • b15
    • x86_64
    • linux
    • Verified

    Backports

      Description

        FULL PRODUCT VERSION :
        1.8.0-b132

        ADDITIONAL OS VERSION INFORMATION :
        Linux ivostmaina 3.13.6-gentoo #1 SMP Thu Mar 20 02:22:16 CET 2014 x86_64 AMD FX(tm)-8350 Eight-Core Processor AuthenticAMD GNU/Linux

        A DESCRIPTION OF THE PROBLEM :
        The getAnnotatedBounds(); method of the TypeVariable interface may return AnnotatedType instances where the getType(); method returns null.

        class MyClass<T> {
        }

        TypeVariable<Class<MyClass>> tv = MyClass.class.getTypeParameters()[0];
        tv.getAnnotatedBounds()[0].getType() is NULL

        I expect that
        tv.getAnnotatedBounds()[0].getType() equals tv.getBounds()[0]


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        @Test
        public void java8_typevariable_bug_or_not1() {

        class MyClass<T> {

        }

        assertEquals(1, MyClass.class.getTypeParameters().length);

        @SuppressWarnings("rawtypes")
        TypeVariable<Class<MyClass>> tv = MyClass.class.getTypeParameters()[0];
        assertNotNull(tv);

        Type[] bs = tv.getBounds();
        assertNotNull(bs);
        assertEquals(1, bs.length);

        AnnotatedType[] abs = tv.getAnnotatedBounds();
        assertNotNull(abs);
        assertEquals(1, abs.length);

        Type t = bs[0];
        assertNotNull(t);
        assertEquals(Object.class, t);

        AnnotatedType at = abs[0];
        assertNotNull(at);
        assertNotNull(at.getType()); // FAILS HERE

        assertEquals(t, at);
        }

        @Test
        public void java8_typevariable_bug_or_not2() {

        class MyClass<T extends Number> {

        }

        assertEquals(1, MyClass.class.getTypeParameters().length);

        @SuppressWarnings("rawtypes")
        TypeVariable<Class<MyClass>> tv = MyClass.class.getTypeParameters()[0];
        assertNotNull(tv);

        Type[] bs = tv.getBounds();
        assertNotNull(bs);
        assertEquals(1, bs.length);

        AnnotatedType[] abs = tv.getAnnotatedBounds();
        assertNotNull(abs);
        assertEquals(1, abs.length);

        Type t = bs[0];
        assertNotNull(t);
        assertEquals(Number.class, t);

        AnnotatedType at = abs[0];
        assertNotNull(at);
        assertNotNull(at.getType()); // FAILS HERE

        assertEquals(t, at);
        }
        ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

                jfranck Joel Borggrén-Franck (Inactive)
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: