Annotation on Intersectingtype

Alex Buckley alex.buckley at oracle.com
Fri Jan 24 12:38:22 PST 2014


On 1/23/2014 8:24 PM, Mohan Radhakrishnan wrote:
> Ok. I understand I have to get each bound and get the annotation applied
> on it. There is no annotation applied on the intersection type itself.

Well, in theory you should be able to get the bounds' mirrors 
individually, and read their annotations, but it doesn't currently work. 
So, you have to get the intersection type's mirror (representing all the 
bounds in one go) and read the annotations from there - you even sent 
code yesterday showing how to do that. We are working on cleaning up the 
type annotation reflection for a JDK 8 update release.

> Did you mean  something like this by cast?
>
> |Serializable f2|
> |= (BiPredicate<String,String> & Serializable)|
> |(s,t) -> s.equalsIgnoreCase(t);|

Yes. The use of an intersection type in a cast is brand new in SE 8. 
Although, I guess the Language Model doesn't expose individual 
expressions like casts, so the javadoc would have to be worded carefully.

Alex


More information about the type-annotations-dev mailing list