Skip to content

Commit

Permalink
Remove ByteBufferIndexInput and update all Panama implementations (MM…
Browse files Browse the repository at this point in the history
…ap and Vector) to Java 21 (#13146)
  • Loading branch information
uschindler authored Feb 29, 2024
1 parent dfce6ee commit e446904
Show file tree
Hide file tree
Showing 40 changed files with 60 additions and 3,085 deletions.
4 changes: 2 additions & 2 deletions gradle/generation/extract-jdk-apis.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ def resources = scriptResources(buildscript)
configure(rootProject) {
ext {
// also change this in extractor tool: ExtractForeignAPI
vectorIncubatorJavaVersions = [ JavaVersion.VERSION_20, JavaVersion.VERSION_21, JavaVersion.VERSION_22 ] as Set
vectorIncubatorJavaVersions = [ JavaVersion.VERSION_21, JavaVersion.VERSION_22 ] as Set
}
}

configure(project(":lucene:core")) {
ext {
apijars = layout.projectDirectory.dir("src/generated/jdk")
mrjarJavaVersions = [ 19, 20, 21 ]
mrjarJavaVersions = [ 21 ]
}

configurations {
Expand Down
10 changes: 2 additions & 8 deletions gradle/generation/extract-jdk-apis/ExtractJdkApis.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ public final class ExtractJdkApis {
private static final String PATTERN_VECTOR_VM_INTERNALS = "java.base/jdk/internal/vm/vector/VectorSupport{,$Vector,$VectorMask,$VectorPayload,$VectorShuffle}";

static final Map<Integer,List<String>> CLASSFILE_PATTERNS = Map.of(
19, List.of(PATTERN_PANAMA_FOREIGN),
20, List.of(PATTERN_PANAMA_FOREIGN, PATTERN_VECTOR_VM_INTERNALS, PATTERN_VECTOR_INCUBATOR),
21, List.of(PATTERN_PANAMA_FOREIGN)
21, List.of(PATTERN_PANAMA_FOREIGN, PATTERN_VECTOR_VM_INTERNALS, PATTERN_VECTOR_INCUBATOR)
);

public static void main(String... args) throws IOException {
Expand Down Expand Up @@ -143,7 +141,7 @@ static class Cleaner extends ClassVisitor {

@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
super.visit(Opcodes.V11, access, name, signature, superName, interfaces);
super.visit(Opcodes.V21, access, name, signature, superName, interfaces);
if (isVisible(access)) {
classesToInclude.add(name);
}
Expand Down Expand Up @@ -188,10 +186,6 @@ public void visitInnerClass(String name, String outerName, String innerName, int
}
}

@Override
public void visitPermittedSubclass(String c) {
}

}

}
2 changes: 1 addition & 1 deletion gradle/testing/defaults-tests.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ allprojects {

// Lucene needs to optional modules at runtime, which we want to enforce for testing
// (if the runner JVM does not support them, it will fail tests):
jvmArgs '--add-modules', 'jdk.unsupported,jdk.management'
jvmArgs '--add-modules', 'jdk.management'

// Enable the vector incubator module on supported Java versions:
if (rootProject.vectorIncubatorJavaVersions.contains(rootProject.runtimeJavaVersion)) {
Expand Down
3 changes: 0 additions & 3 deletions gradle/testing/randomization/policies/replicator-tests.policy
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ grant {
permission java.lang.RuntimePermission "getStackTrace";
// needed for mock filesystems in tests
permission java.lang.RuntimePermission "fileSystemProvider";
// needed to test unmap hack on platforms that support it
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
};

// Permissions to support ant build
Expand Down
3 changes: 0 additions & 3 deletions gradle/testing/randomization/policies/tests.policy
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ grant {
permission java.lang.RuntimePermission "getStackTrace";
// needed for mock filesystems in tests
permission java.lang.RuntimePermission "fileSystemProvider";
// needed to test unmap hack on platforms that support it
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
// needed by cyberneko usage by benchmarks on J9
permission java.lang.RuntimePermission "accessClassInPackage.org.apache.xerces.util";

Expand Down

This file was deleted.

Binary file removed lucene/core/src/generated/jdk/jdk19.apijar
Binary file not shown.
Binary file removed lucene/core/src/generated/jdk/jdk20.apijar
Binary file not shown.
Binary file modified lucene/core/src/generated/jdk/jdk21.apijar
Binary file not shown.
1 change: 0 additions & 1 deletion lucene/core/src/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
@SuppressWarnings("module") // the test framework is compiled after the core...
module org.apache.lucene.core {
requires java.logging;
requires static jdk.unsupported; // this is optional but without it MMapDirectory won't be enabled
requires static jdk.management; // this is optional but explicit declaration is recommended

exports org.apache.lucene.analysis;
Expand Down
7 changes: 0 additions & 7 deletions lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
import org.apache.lucene.store.Lock;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.store.LockValidatingDirectoryWrapper;
import org.apache.lucene.store.MMapDirectory;
import org.apache.lucene.store.MergeInfo;
import org.apache.lucene.store.TrackingDirectoryWrapper;
import org.apache.lucene.util.Accountable;
Expand Down Expand Up @@ -1303,12 +1302,6 @@ private void messageState() {
+ Version.LATEST.toString()
+ "\n"
+ config.toString());
final StringBuilder unmapInfo =
new StringBuilder(Boolean.toString(MMapDirectory.UNMAP_SUPPORTED));
if (!MMapDirectory.UNMAP_SUPPORTED) {
unmapInfo.append(" (").append(MMapDirectory.UNMAP_NOT_SUPPORTED_REASON).append(")");
}
infoStream.message("IW", "MMapDirectory.UNMAP_SUPPORTED=" + unmapInfo);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

package org.apache.lucene.internal.vectorization;

import java.lang.Runtime.Version;
import java.lang.StackWalker.StackFrame;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
import java.util.OptionalInt;
Expand Down Expand Up @@ -97,20 +95,11 @@ public static VectorizationProvider getInstance() {

private static final Logger LOG = Logger.getLogger(VectorizationProvider.class.getName());

/** The minimal version of Java that has the bugfix for JDK-8301190. */
private static final Version VERSION_JDK8301190_FIXED = Version.parse("20.0.2");

// visible for tests
static VectorizationProvider lookup(boolean testMode) {
final int runtimeVersion = Runtime.version().feature();
if (runtimeVersion >= 20 && runtimeVersion <= 22) {
// is locale sane (only buggy in Java 20)
if (isAffectedByJDK8301190()) {
LOG.warning(
"Java runtime is using a buggy default locale; Java vector incubator API can't be enabled: "
+ Locale.getDefault());
return new DefaultVectorizationProvider();
}
assert runtimeVersion >= 21;
if (runtimeVersion <= 22) {
// only use vector module with Hotspot VM
if (!Constants.IS_HOTSPOT_VM) {
LOG.warning(
Expand Down Expand Up @@ -169,13 +158,11 @@ static VectorizationProvider lookup(boolean testMode) {
} catch (ClassNotFoundException cnfe) {
throw new LinkageError("PanamaVectorizationProvider is missing in Lucene JAR file", cnfe);
}
} else if (runtimeVersion >= 23) {
LOG.warning(
"You are running with Java 23 or later. To make full use of the Vector API, please update Apache Lucene.");
} else if (lookupVectorModule().isPresent()) {
} else {
LOG.warning(
"Java vector incubator module was enabled by command line flags, but your Java version is too old: "
+ runtimeVersion);
"You are running with unsupported Java "
+ runtimeVersion
+ ". To make full use of the Vector API, please update Apache Lucene.");
}
return new DefaultVectorizationProvider();
}
Expand All @@ -189,15 +176,6 @@ private static Optional<Module> lookupVectorModule() {
.findModule("jdk.incubator.vector");
}

/**
* Check if runtime is affected by JDK-8301190 (avoids assertion when default language is say
* "tr").
*/
private static boolean isAffectedByJDK8301190() {
return VERSION_JDK8301190_FIXED.compareToIgnoreOptional(Runtime.version()) > 0
&& !Objects.equals("I", "i".toUpperCase(Locale.getDefault()));
}

// add all possible callers here as FQCN:
private static final Set<String> VALID_CALLERS = Set.of("org.apache.lucene.util.VectorUtil");

Expand Down
156 changes: 0 additions & 156 deletions lucene/core/src/java/org/apache/lucene/store/ByteBufferGuard.java

This file was deleted.

Loading

0 comments on commit e446904

Please sign in to comment.