[foreign-abi] NPE in hashCode() for function without return type (void)

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Oct 23 10:01:53 UTC 2019


Looks good - noted that too in the past, but forgot to circle back.

Thanks
Maurizio

On 23/10/2019 04:27, Henry Jen wrote:
> Hi,
>
> Please review a trivial patch to prevent NPE caused by null resLayout, which is null when the function has no return type.
>
> Cheers,
> Henry
>
>
> diff -r b3f1601a8c8e -r ad6f9f2becdc src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/FunctionDescriptor.java
> --- a/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/FunctionDescriptor.java     Tue Oct 22 15:21:59 2019 +0100
> +++ b/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/FunctionDescriptor.java     Tue Oct 22 19:55:38 2019 -0700
> @@ -135,7 +135,8 @@
>        */
>       @Override
>       public int hashCode() {
> -        return resLayout.hashCode() ^ Arrays.hashCode(argLayouts) ^ Boolean.hashCode(variadic);
> +        int hashCode = Arrays.hashCode(argLayouts) ^ Boolean.hashCode(variadic);
> +        return resLayout == null ? hashCode : resLayout.hashCode() ^ hashCode;
>       }
>
>       @Override


More information about the panama-dev mailing list