Skip to content

Commit

Permalink
Do not place Panama Java 21 class files in MR-JAR section of core.jar…
Browse files Browse the repository at this point in the history
… file (#13148)
  • Loading branch information
uschindler authored Feb 29, 2024
1 parent 8ef60b3 commit 6910a43
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
15 changes: 11 additions & 4 deletions gradle/java/core-mrjar.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ API Changes
make compile() only return the FSTMetadata. For on-heap (default) use case, please use
FST.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
---------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,25 @@ public void testMultiReleaseJar() {

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();
Expand Down

0 comments on commit 6910a43

Please sign in to comment.