AnnotatedWildcardType.getAnnotatedUpperBounds() returns wrong result if wildcard declares no upper bound

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P2
    • None
    • Affects Version/s: 8
    • Component/s: core-libs
    • None

      According to the spec for j.l.r.WildcardType:
      "Note that if no upper bound is explicitly declared, the upper bound is
      Object."
      And looks like this should be also true for j.l.r.AnnotatedWildcardType.

      If we have wildcard without definition of lower and upper
      bounds, AnnotatedWildcardType.getAnnotatedUpperBounds().length will
      return 1.

      Minimized test:
      -------------------------------------------------------------------------------
      public class Test {

           public Test(List<? super String> p) {}

           public static void main(String[] args) throws NoSuchMethodException {
               Constructor constructor = Test.class.getConstructor(List.class);
               AnnotatedParameterizedType at = (AnnotatedParameterizedType)
      constructor.getAnnotatedParameterTypes()[0];
               System.out.println(((AnnotatedWildcardType)
      at.getAnnotatedActualTypeArguments()[0]).getAnnotatedUpperBounds().length);

               ParameterizedType t = (ParameterizedType)
      constructor.getGenericParameterTypes()[0];
               System.out.println(((WildcardType)
      t.getActualTypeArguments()[0]).getUpperBounds().length);
           }

      }
      -------------------------------------------------------------------------------


      Output (tested with jdk8u20):
      -------------------------------------------------------------------------------
      0
      1
      -------------------------------------------------------------------------------


      As I understand output should be:
      -------------------------------------------------------------------------------
      1
      1
      -------------------------------------------------------------------------------

            Assignee:
            Alex Buckley
            Reporter:
            Elena Votchennikova (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: