[foreign-abi] [Rev 03] RFR: 8241504: Expose MemoryLayout annotations/attributes in the public API
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Thu Mar 26 11:09:41 UTC 2020
On Tue, 24 Mar 2020 17:38:20 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> Hi,
>>
>> This PR exposed MemoryLayout attributes in the public API.
>>
>> A summary of the changes:
>> - Renamed annotation -> attribute everywhere to avoid confusion with Java language annotations
>> - Made sure that annotations were being serialized as part of a MemoryLayout's ConstantDesc, as well as the alignment
>> which was previously left out. (The latter also meant changing PaddingLayout::hasNaturalAlignment to always return
>> `true`, so serializing alignment is skipped for padding). Removed special casing for the abiType attribute. This can
>> now instead be handled through the generic attribute mechanism.
>>
>> Thanks,
>> Jorn
>
> Jorn Vernee has updated the pull request incrementally with two additional commits since the last revision:
>
> - Merge branch 'Attributes' of https://github.com/JornVernee/panama-foreign into Attributes
> - Remove ML::attribute(String, Class) helper method.
Some more comments
src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/windows/CallArranger.java line 187:
> 186: if (type.attribute(VARARGS_ATTRIBUTE_NAME)
> 187: .filter(String.class::isInstance)
> 188: .map(String.class::cast)
Not convinced by the `filter` here? You get an Optional<Constable>, you do a cast to String and then parse as boolean -
why the filtering? If there's an annotation with that name, but different type, I'd prefer to crash than to end up
doing something wrong. Same applies elsewhere.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/64
More information about the panama-dev
mailing list