From elena.votchennikova at oracle.com Fri Jul 18 13:26:13 2014 From: elena.votchennikova at oracle.com (elena votchennikova) Date: Fri, 18 Jul 2014 17:26:13 +0400 Subject: [type-annos-observers] AnnotatedWildcardType upper bounds question Message-ID: <53C92075.7030304@oracle.com> Hi all, I have a question regarding AnnotatedWildcardType upper bounds. Could you please look at the following example. Minimized test: ------------------------------------------------------------------------------- public class Test { public Test(List 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 jdk8b132): ------------------------------------------------------------------------------- 0 1 ------------------------------------------------------------------------------- As I understand output should be: ------------------------------------------------------------------------------- 1 1 ------------------------------------------------------------------------------- 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. Or I'm mistaken? By the way, if we have wildcard without definition of lower and upper bounds, wildcardAnnotatedType.getAnnotatedUpperBounds().length will return 1. Thank you, Elena