[foreign-abi] [Rev 01] RFR: 8241504: Expose MemoryLayout annotations/attributes in the public API

Jorn Vernee jvernee at openjdk.java.net
Tue Mar 24 17:33:15 UTC 2020


On Tue, 24 Mar 2020 17:06:40 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Jorn Vernee has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Addressed review comments + added basic tests
>
> src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryLayout.java line 303:
> 
>> 302:      */
>> 303:     default <T extends Constable> Optional<T> attribute(String name, Class<T> type) {
>> 304:         return attribute(name).filter(type::isInstance).map(type::cast);
> 
> Not sure I like this method. While it works assuming all constable implementation are non-generic, it will stop working
> correctly as soon as you have a generic class implementing a constable. Maybe save the sugar for later?
> (btw this was there in the previous iteration too but I've missed - guess because it was a default method and I focused
> on AbstractLayout)

I see what you mean. It's not that easy to get a `Class<T>` when `T` is a generic type. I'll remove this helper for
now. (adding SystemABI.Type::fromLayout removed most use-cases we currently have as well).

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

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


More information about the panama-dev mailing list