test failures

Jonathan Gibbons jonathan.gibbons at oracle.com
Thu Apr 25 19:30:18 PDT 2013

On 04/24/2013 09:51 PM, Jonathan Gibbons wrote:
> tools/javac/processing/model/type/BasicAnnoTests.java

This test is failing because the internal data model for type 
annotations within javac is inconsistent.

The broken test case is this one (and maybe others like it):

>     @Test(posn=1, annoType=TA.class, expect="4")
>     public int m1(@TA(4) float a) throws Exception { return 0; }

If you look at the ExecutableElement for m1, you can navigate to the 
VariableElement for the parameter "a", and from there get to the type 
annotations on the type used for "a".  The debug output from the test 
confirms the existence of @TA(4) on "float".

But there's a second way to get to that instance of "float".

 From the ExecutableElement, you can get an ExecutableType using 
Element.asType(), and from the ExecutableType, you can get the 
ParameterTypes using getParameterTypes().  It seems intuitively 
reasonable to expect that the type of the first parameter obtained in 
this manner should be the annotated type "@TA(4) float".  The debug 
output from the test indicates there are no type annotations here, and 
so the test fails.

Generally speaking, I think all the following pairs should be 
equivalent^[1,2] , for any ExecutableElement ee:

using ExecutableElement
	using ExecutableType

[1] where "equivalent" means that the types and annotations on those 
types should match: something like a recursive evaluation of
         Types.isSameType(a, b) && 
Objects.equals(a.getAnnotationMirrors(), b.getAnnotationMirrors())

[2] In practice, I would expect the values to be ==, but I would not 
mandate that.

The BasicAnnoTests covers some of these cases, but should be extended to 
cover all of them.

-- Jon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/type-annotations-dev/attachments/20130425/06b9b5f9/attachment-0001.html 

More information about the type-annotations-dev mailing list