[foreign-jextract] [Rev 01] RFR: 8239809: Need API to access attributes

Henry Jen henryjen at openjdk.java.net
Thu Feb 27 05:24:03 UTC 2020


On Wed, 26 Feb 2020 10:50:53 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> The pull request has been updated with 1 additional commit.
> 
> src/jdk.incubator.jextract/share/classes/jdk/internal/jextract/impl/DeclarationImpl.java line 44:
> 
>> 43:     private final Position pos;
>> 44:     private final Map<String, List<ConstantDesc>> attributes;
>> 45: 
> 
> I think we want `Map<String, List<Constable>>` here instead? We use Constable for layout annotations as well: https://github.com/openjdk/panama-foreign/blob/foreign-jextract/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/AbstractLayout.java#L47
> 
> We only care that they can be turned into constants, and I guess live values would be easier to work with (as opposed to descriptors).

I gave it some thoughts, and I tend to agree with you.

At beginning, I am thinking we need something universal that can turn into the value as needed by API user, thus ConstantDesc seems to make sense, as we don't need the value necessary to be Constable.

I don't expect to see jextract API to be involved in any direction of that operation, so it really up to the user of attribute, thus ConstantDesc seems to be less restrictive. 

However, require the value to be "Constable" make sense as well and that, as you said, live value is easier to work with. After all, API user may end up generating code/class and care more about turn the value into constants.

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

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


More information about the panama-dev mailing list