No segment method for MemoryAddress?
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu Aug 20 21:43:00 UTC 2020
On 20/08/2020 21:32, Ty Young wrote:
> So, apparently the <MemoryAddress>.segment() method was removed and
> now provides a seemingly redundant address() method:
This was all described here:
https://mail.openjdk.java.net/pipermail/panama-dev/2020-July/009928.html
Basically, a MemoryAddress no longer has a link to a segment. An address
is just a thin wrapper around an Object/long unsafe addressing pair.
Addressable is mostly there so that _everything_ that can be converted
to an address can be passed to a function. We use this in jextract, so
that clients can avoid a lot of calls to ".baseAddress()". If you don't
need it, you can ignore it.
Maurizio
>
>
> private final MemoryAddress address;
>
>
> ...
>
>
> this.address.address();
>
>
> which has the Javadoc:
>
>
> "Map this object into a MemoryAddress instance."
>
>
> ...but it is already a MemoryAddress? What is going on here? How are
> you supposed to get a segment from an address? Why is there a
> seemingly redundant address() method?
>
>
> Reading the Javadoc of Addressable:
>
>
> "Represents a type which is addressable. An addressable type is one
> which can be projected down to a memory address instance (see
> address()). Examples of addressable types are MemorySegment,
> MemoryAddress, LibraryLookup.Symbol and CSupport.VaList."
>
>
> provides context on why the address() method exists but not why
> segment() has been removed.
>
>
> Personally, I think the address() method should be removed and the
> components that make up a MemoryAddress be exposed instead if
> possible, but that's my 2 cents.
>
>
>
>
>
More information about the panama-dev
mailing list