[foreign] RFR 8218678: Binder does not understand wildcard in generic carriers

Sundararajan Athijegannathan sundararajan.athijegannathan at oracle.com
Fri Feb 8 16:07:13 UTC 2019


Looks good

-Sundar

On 08/02/19, 9:26 PM, Maurizio Cimadamore wrote:
> Hi,
> this issue has been discovered by Sundar (thanks!) when playing with 
> sqlite3.
>
> We have recently improved the jextract codebase in order to generate 
> wildcards for nested pointer and arrays. Unfortunately, the binder 
> gives up when parsing generic signature types containing wildcard type 
> parameters.
>
> This patch fixes that. As you can see the fix is not exactly trivial - 
> WildcardType has both upper bounds and lower bounds arrays. In reality 
> the lower bound is either null or a one element array (in the case of 
> '? super' wildcard). The upper bound is _at least_ a one element 
> array. The first element can be j.l.Object or not, but typically is a 
> class type.
>
> So we have X cases:
>
> * there is one lower bound - easy, then this is a ? super T wildcard 
> and the type argument is T
> * there is one upper bound - we have two subcases:
>     - the upper bound is j.l.Object - uninteresting, we should treat 
> as if no type-argument was found
>     - otherwise, the upper bound is some other type T, return that as 
> the type argument
> * there are 2 upper bounds, and the first is j.l.Object - this 
> corresponds to '? super I' where I is an interface, return I as the 
> type-argument
> * otherwise, we have multiple upper/lower bounds - in which case we 
> should throw; jextract will never generate something like this, and I 
> believe the user won't write something like it either :-)
>
>
> http://cr.openjdk.java.net/~mcimadamore/panama/8218678/
>
>
> Cheers
> Maurizio
>


More information about the panama-dev mailing list