[foreign-jextract] RFR: 8266682: sync jextract for LibraryLookup removal

Maurizio Cimadamore mcimadamore at openjdk.java.net
Fri May 7 10:26:19 UTC 2021


On Fri, 7 May 2021 06:25:50 GMT, Athijegannathan Sundararajan <sundar at openjdk.org> wrote:

> Using System.load/.loadLibrary in generated code and jextract code. Class initialisation dummy method to take sure constants classes initialise header-class before looking up names.

src/jdk.incubator.jextract/share/classes/jdk/internal/clang/LibClang.java line 49:

> 47:         if (!CRASH_RECOVERY) {
> 48:             //this is an hack - needed because clang_toggleCrashRecovery only takes effect _after_ the
> 49:             //first call to createIndex.

Maybe add a link to:
https://reviews.llvm.org/D23662

This should really get fixed upstream.

src/jdk.incubator.jextract/share/classes/jdk/internal/clang/libclang/RuntimeHelper.java line 65:

> 63:     private final static SegmentAllocator THROWING_ALLOCATOR = (x, y) -> { throw new AssertionError("should not reach here"); };
> 64: 
> 65:     static final void loadLibraries(String... libNames) {

Perhaps this can be removed? E.g. can't we just emit a static block wherever we call `loadLibraries` ? It seems like we can do the analysis of whether to call load/loadLibrary at jextract time.

src/jdk.incubator.jextract/share/classes/jdk/internal/jextract/impl/ToplevelBuilder.java line 223:

> 221:         }
> 222: 
> 223:         private void emitInit() {

Following offline discussion, I think we can simplify this by removing library loading logic from header classes and sticking it in runtime helper.

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

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


More information about the panama-dev mailing list