RFR: 7903649: Field and global variables of array type should have indexed accessors

Maurizio Cimadamore mcimadamore at openjdk.org
Tue Jan 30 16:17:37 UTC 2024


On Tue, 30 Jan 2024 14:18:40 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Quickly running some tests - the above approach runs into some ambiguities between function pointer class names and holder class names:
>> 
>> 
>> test/jtreg/generator/funcPointerInvokers/TestFuncPointerInvokers.java:80: error: reference to fp is ambiguous
>>             fp(fp.allocate((i) -> val.set(i), arena));
>> 
>> 
>> That's because the name used for the function pointer class is the same as the name of the variable which introduced the function pointer. So, if the client code uses a blanket static import of all members of the header class (which is what most jextract clients do), we run into ambiguities (as two classes with same name are available at different levels).
>
> I think this looks great, at least for globals. For struct fields it might be okay as well, but it seems tempting to try and find a way to put these extra fields directly in the struct class.

FTR, if the constant class is called `<varName>$constants` all the ambiguities issues are resolved, and all tests pass. But, we're back with dollar names :-)

If we're fine with dollar names for "less common API points", we could settle by having a single extra layout accessor/descriptor accessor per var/field/function. I think the layout API should expose an handy method for computing dimensions of a possibly nested sequence layout.

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

PR Review Comment: https://git.openjdk.org/jextract/pull/198#discussion_r1471336688


More information about the jextract-dev mailing list