quarkiverse / quarkus-lucene

Quarkus Lucene Extension
Apache License 2.0
14 stars 5 forks source link

Building a native image inside a container environment with Java 21 fails #175

Open argo1089 opened 5 months ago

argo1089 commented 5 months ago

Setup: Image: quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21 Project java version: 21 Quarkus version: 3.10.2 Lucene version: 2.3.0

Error: undefined reference to `Java_jdk_internal_misc_ScopedMemoryAccess_closeScope0'

vmargerin commented 5 months ago

Hello @argo1089, I ran into the same issue and the only workaround I found is to disable the usage of Memory Segment API: quarkus.native.additional-build-args=-Dorg.apache.lucene.store.MMapDirectory.enableMemorySegments=false

MMapDirectory uses the MemorySegment API on Java 19 and later.

On exactly Java 19 / 20 / 21 this class will use the modern MemorySegment API which allows to safely unmap (if you discover any problems with this preview API, you can disable it by using system property ENABLE_MEMORY_SEGMENTS_SYSPROP)

https://lucene.apache.org/core/9_7_0/core/org/apache/lucene/store/MMapDirectory.html

argo1089 commented 5 months ago

Yes disabling the memory segment api is a workaround