[foreign] RFR 8219119: Need API to create a null Callback

Jorn Vernee jbvernee at xs4all.nl
Mon Feb 18 10:08:29 UTC 2019


I see there is a test for asFunction() throwing an NPE. I think the NPE 
is being triggered from somewhere else already. It looks like this 
happens by calling

     LibrariesHelper.getCallbackImplClass(funcIntfClass); -> 
Util.isCallback(c) -> c.isAnnotationPresent(NativeCallback.class);

 From CallbackImpl::asFunction. So, maybe the overridden impl is not 
needed? It might be simpler to just add an isNull() check to the regular 
implemenation.

Jorn

Jorn Vernee schreef op 2019-02-18 10:30:
> Hi Sundar,
> 
> You've changed the implementation of theNullCallback to throw an
> exception in an overridden asFunction(), but the boxing code in
> References.OfFunction and DirectSignatureShuffler (others?) would
> still have to be updated to return theNullCallback explicitly when the
> address is 0.
> 
> Jorn
> 
> Sundararajan Athijegannathan schreef op 2019-02-18 04:52:
>> Updated: https://cr.openjdk.java.net/~sundar/8219119/webrev.01/
>> 
>> Thanks
>> -Sundar
>> 
>> On 15/02/19, 10:33 PM, Maurizio Cimadamore wrote:
>>> Looks good - but I think it can be simplified further - there's no 
>>> need to accept a carrier type in Callback::ofNull.
>>> 
>>> You can just create a CallbackImpl which throws NPE whenever you try 
>>> to call 'asFunction'.
>>> 
>>> Maurizio
>>> 
>>> On 15/02/2019 17:00, Sundararajan Athijegannathan wrote:
>>>> Please review.
>>>> 
>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8219119
>>>> Webrev: https://cr.openjdk.java.net/~sundar/8219119/webrev.00/
>>>> 
>>>> Thanks,
>>>> -Sundar


More information about the panama-dev mailing list