Apache Lucene open-source search software
Upgrade forbiddenapis to 3.4 (#11834)
Uwe Schindleraae293437f52
diff --git a/build.gradle b/build.gradleindex 03f4a372ffc..59027748a97 100644--- a/build.gradle+++ b/build.gradle@@ -22,7 +22,7 @@ plugins {id "base"id "com.palantir.consistent-versions" version "2.11.0"id "org.owasp.dependencycheck" version "7.2.0"- id 'de.thetaphi.forbiddenapis' version '3.3' apply false+ id 'de.thetaphi.forbiddenapis' version '3.4' apply falseid "de.undercouch.download" version "5.2.0" apply falseid "net.ltgt.errorprone" version "2.0.2" apply falseid 'com.diffplug.spotless' version "6.5.2" apply falsediff --git a/gradle/validation/forbidden-apis.gradle b/gradle/validation/forbidden-apis.gradleindex 8fbe82a6efd..6de4c7d8aec 100644--- a/gradle/validation/forbidden-apis.gradle+++ b/gradle/validation/forbidden-apis.gradle@@ -57,7 +57,7 @@ allprojects { prj ->}// Configure defaults for sourceSets.main- forbiddenApisMain {+ tasks.matching { it.name in ["forbiddenApisMain", "forbiddenApisMain19"] }.all {bundledSignatures += ['jdk-unsafe','jdk-deprecated',@@ -73,6 +73,13 @@ allprojects { prj ->doFirst dynamicSignatures.curry(configurations.compileClasspath, "lucene")}+ // Configure defaults for the MR-JAR feature sourceSets by setting java version and ignore missing classes+ // TODO: Get hold of warning messages, see https://github.com/policeman-tools/forbidden-apis/issues/207+ tasks.matching { it.name == "forbiddenApisMain19" }.all {+ failOnMissingClasses = false+ targetCompatibility = 19+ }+// Configure defaults for sourceSets.testtasks.matching { it.name in ["forbiddenApisTest", "forbiddenApisTestFixtures"] }.all {bundledSignatures += [@@ -115,11 +122,6 @@ allprojects { prj ->inputs.dir(file(resources))}- // TODO: Remove this when forbiddenapis supports Java 19 class files- tasks.matching { it.name == "forbiddenApisMain19" }.all {- enabled = false- }-// We rely on resolved configurations to compute the relevant set of rule// files for forbiddenApis. Since we don't want to resolve these configurations until// the task is executed, we can't really use them as task inputs properly. This is adiff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex cd535e09edb..e9032231b9e 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -140,7 +140,9 @@ Other---------------------* LUCENE-10423: Remove usages of System.currentTimeMillis() from tests. (Marios Trivyzas)-* GITHUB#11811: upgrade google java format to 1.15.0 (Dawid Weiss)+* GITHUB#11811: Upgrade google java format to 1.15.0 (Dawid Weiss)++* GITHUB#11834: Upgrade forbiddenapis to version 3.4. (Uwe Schindler)======================== Lucene 9.4.0 =======================diff --git a/lucene/core/src/java19/org/apache/lucene/store/MemorySegmentIndexInput.java b/lucene/core/src/java19/org/apache/lucene/store/MemorySegmentIndexInput.javaindex 7754645c708..089a848d700 100644--- a/lucene/core/src/java19/org/apache/lucene/store/MemorySegmentIndexInput.java+++ b/lucene/core/src/java19/org/apache/lucene/store/MemorySegmentIndexInput.java@@ -24,6 +24,7 @@ import java.lang.foreign.ValueLayout;import java.nio.ByteOrder;import java.util.Arrays;import java.util.Objects;+import org.apache.lucene.util.ArrayUtil;/*** Base IndexInput implementation that uses an array of MemorySegments to represent a file.@@ -408,7 +409,7 @@ abstract class MemorySegmentIndexInput extends IndexInput implements RandomAcces// we always allocate one more slice, the last one may be a 0 byte one after truncating with// asSlice():- final MemorySegment slices[] = Arrays.copyOfRange(segments, startIndex, endIndex + 1);+ final MemorySegment slices[] = ArrayUtil.copyOfSubArray(segments, startIndex, endIndex + 1);// set the last segment's limit for the sliced view.slices[slices.length - 1] = slices[slices.length - 1].asSlice(0L, sliceEnd & chunkSizeMask);