[foreign-abi] NPE in hashCode() for function without return type (void)
    Henry Jen 
    henry.jen at oracle.com
       
    Wed Oct 23 03:27:28 UTC 2019
    
    
  
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