[foreign-memaccess+abi] RFR: 8289285: Use records for binding classes

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Jul 11 15:26:25 UTC 2022


On Tue, 28 Jun 2022 10:44:25 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> This PR switches the Binding classes to use records. This results in a clean simplification of the code due to the no longer having the need to implement equals/hashcode/toString as well. When we have type patterns for switch, we will also be able to remove the tag, and just switch on the type.
>> 
>> I also noticed that the UnboxAddress binding had 2 fields that were not being used. In practice this binding always operates on Addressable instances (both in the interpreter and specializer). So, I've cleaned up these 2 fields as well, and related factory method.
>
> src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java line 374:
> 
>> 372: 
>> 373:     static void checkType(Class<?> actualType, Class<?> expectedType) {
>> 374:         if (!expectedType.isAssignableFrom(actualType)) {
> 
> This change is needed to accommodate for the fact that UnboxAddress now accepts an Addressable, but a previous binding still outputs either a MemoryAddress or MemorySegment.

Thanks for cleaning up these (and corresponding binding classes)

-------------

PR: https://git.openjdk.org/panama-foreign/pull/690


More information about the panama-dev mailing list