[foreign-jextract] RFR: 8248415: Create VarHandles for pointer fields through the MemoryHandles API

Jorn Vernee jvernee at openjdk.java.net
Thu Jul 2 14:04:48 UTC 2020


On Sat, 27 Jun 2020 09:14:14 GMT, Filip Krakowski <github.com+7255767+krakowski at openjdk.org> wrote:

> This PR creates an adapted
> [`VarHandle`](https://github.com/openjdk/panama-foreign/blob/foreign-jextract/src/java.base/share/classes/java/lang/invoke/VarHandle.java)
> usable with
> [`MemoryAddress`](https://github.com/openjdk/panama-foreign/blob/foreign-jextract/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryAddress.java)
> carriers for pointer fields. It uses
> [`MemoryHandles#asAddressVarHandle`](https://github.com/openjdk/panama-foreign/blob/foreign-jextract/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryHandles.java#L334-L350)
> and a previously created `long` VarHandle to do so.

One of the tests is failing, and it looks like there's a bug. I've left an inline comment about that.

src/jdk.incubator.jextract/share/classes/jdk/incubator/jextract/tool/ConstantHelper.java line 141:

> 140:             Map.entry(Float.TYPE,               desc(Short.TYPE)),
> 141:             Map.entry(Double.TYPE,              desc(Short.TYPE)),
> 142:             Map.entry(MemoryAddress.class,      desc(Long.TYPE))

These should not use `Short.TYPE`, but the corresponding type of the key (Long.TYPE, Float.TYPE, Double.TYPE).

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

PR: https://git.openjdk.java.net/panama-foreign/pull/216


More information about the panama-dev mailing list