[foreign-jextract] RFR: updating samples. changed constants class to use package constructor [v2]

Athijegannathan Sundararajan sundar at openjdk.java.net
Tue Aug 25 12:42:34 UTC 2020


On Tue, 25 Aug 2020 12:29:37 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Athijegannathan Sundararajan has updated the pull request incrementally with one additional commit since the last
>> revision:
>>   fixed titles of sections of time sample.
>
> doc/panama_jextract.md line 842:
> 
>> 841:         var index = clang_createIndex(0, 0);
>> 842:         var tu = clang_parseTranslationUnit(index, toCString(args[0]),
>> 843:             NULL, 0, NULL, 0, CXTranslationUnit_None());
> 
> This `toCString` should be allocated in the native scope below, so it gets cleaned up as well.

agree

> doc/panama_jextract.md line 848:
> 
>> 847:             var level = new int[1];
>> 848:             var visitor = new MemorySegment[1];
>> 849:
> 
> FWIW, I think you could avoid both of these by using an anonymous class instead of a lambda

While we can take care of level param that way, the function pointer address (visitor) is used inside to call
recursively. Unfortunately we need array hack for that.

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

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


More information about the panama-dev mailing list