Apache Lucene open-source search software
Do not place Panama Java 21 class files in MR-JAR section of core.jar file (#13148)
Uwe Schindler6910a4358c83
diff --git a/gradle/java/core-mrjar.gradle b/gradle/java/core-mrjar.gradleindex 40ba769c969..0870ebdbcad 100644--- a/gradle/java/core-mrjar.gradle+++ b/gradle/java/core-mrjar.gradle@@ -46,15 +46,22 @@ configure(project(":lucene:core")) {}tasks.named('jar').configure {+ boolean needMRJAR = false;mrjarJavaVersions.each { jdkVersion ->- into("META-INF/versions/${jdkVersion}") {+ // the sourceSet which corresponds to the mininum/base Java version+ // will copy its output to root of JAR, all other sourceSets will go into MR-JAR folders:+ boolean isBaseVersion = (jdkVersion.toString() == rootProject.minJavaVersion.toString())+ into(isBaseVersion ? '' : "META-INF/versions/${jdkVersion}") {from sourceSets["main${jdkVersion}"].output}+ needMRJAR |= !isBaseVersion}- manifest.attributes(- 'Multi-Release': 'true'- )+ if (needMRJAR) {+ manifest.attributes(+ 'Multi-Release': 'true'+ )+ }}}}diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 9a4883b1053..b1061599876 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -84,8 +84,8 @@ API Changesmake compile() only return the FSTMetadata. For on-heap (default) use case, please useFST.fromFSTReader(fstMetadata, fstCompiler.getFSTReader()) to create the FST. (Anh Dung Bui)-* GITHUB#13146: Remove ByteBufferIndexInput and only use MemorySegment APIs for MMapDirectory.- (Uwe Schindler)+* GITHUB#13146, GITHUB#13148: Remove ByteBufferIndexInput and only use MemorySegment APIs+ for MMapDirectory. (Uwe Schindler)New Features---------------------diff --git a/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestModularLayer.java b/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestModularLayer.javaindex 084a044092f..84d5df2256a 100644--- a/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestModularLayer.java+++ b/lucene/distribution.tests/src/test/org/apache/lucene/distribution/TestModularLayer.java@@ -207,16 +207,25 @@ public class TestModularLayer extends AbstractLuceneDistributionTest {ClassLoader loader = layer.findLoader(coreModuleId);- final Set<Integer> jarVersions = Set.of(21);- for (var v : jarVersions) {- Assertions.assertThat(- loader.getResource(- "META-INF/versions/"- + v- + "/org/apache/lucene/store/MemorySegmentIndexInput.class"))- .isNotNull();- }-+ final Set<Integer> mrJarVersions = Set.of(21);+ final Integer baseVersion = 21;++ // the Java 21 PanamaVectorizationProvider must always be in main section of JAR file:+ final String panamaClassName =+ "org/apache/lucene/internal/vectorization/PanamaVectorizationProvider.class";+ Assertions.assertThat(loader.getResource(panamaClassName)).isNotNull();++ // additional versions must be in MR-JAR part+ mrJarVersions.stream()+ .filter(Predicate.not(baseVersion::equals))+ .forEach(+ v -> {+ Assertions.assertThat(+ loader.getResource("META-INF/versions/" + v + panamaClassName))+ .isNotNull();+ });++ // you must be always able to load MemorySegmentIndexInput:Assertions.assertThat(loader.loadClass("org.apache.lucene.store.MemorySegmentIndexInput")).isNotNull();