Apache Lucene open-source search software
LUCENE-6420: Use forbidden-apis annotation @SuppressForbidden; cleanup maven build
Uwe Schindler5b4fe002baa4
diff --git a/dev-tools/maven/lucene/analysis/stempel/pom.xml.template b/dev-tools/maven/lucene/analysis/stempel/pom.xml.templateindex 25036412e1a..44f2b0bdf51 100644--- a/dev-tools/maven/lucene/analysis/stempel/pom.xml.template+++ b/dev-tools/maven/lucene/analysis/stempel/pom.xml.template@@ -69,50 +69,5 @@</excludes></testResource></testResources>- <plugins>- <plugin>- <groupId>de.thetaphi</groupId>- <artifactId>forbiddenapis</artifactId>- <executions>- <execution>- <id>lucene-shared-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution>- <execution>- <id>check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>check</goal>- </goals>- </execution>- <execution>- <id>check-system-out</id> <!-- separate execution to specify excludes -->- <configuration>- <bundledSignatures>- <bundledSignature>jdk-system-out</bundledSignature>- </bundledSignatures>- <excludes>- <!-- exclude command line tools -->- <exclude>org/egothor/stemmer/Compile.class</exclude>- <exclude>org/egothor/stemmer/DiffIt.class</exclude>- </excludes>- </configuration>- <goals>- <goal>check</goal>- </goals>- </execution>- </executions>- </plugin>- </plugins></build></project>diff --git a/dev-tools/maven/lucene/backward-codecs/pom.xml.template b/dev-tools/maven/lucene/backward-codecs/pom.xml.templateindex 6e8857edbdc..0d892ca3b37 100644--- a/dev-tools/maven/lucene/backward-codecs/pom.xml.template+++ b/dev-tools/maven/lucene/backward-codecs/pom.xml.template@@ -71,35 +71,5 @@</excludes></testResource></testResources>- <plugins>- <plugin>- <groupId>de.thetaphi</groupId>- <artifactId>forbiddenapis</artifactId>- <executions>- <execution>- <id>lucene-shared-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution>- <execution>- <id>check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- <bundledSignature>jdk-system-out</bundledSignature>- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>check</goal>- </goals>- </execution>- </executions>- </plugin>- </plugins></build></project>diff --git a/dev-tools/maven/lucene/benchmark/pom.xml.template b/dev-tools/maven/lucene/benchmark/pom.xml.templateindex d328ca72be3..b5e258127c2 100644--- a/dev-tools/maven/lucene/benchmark/pom.xml.template+++ b/dev-tools/maven/lucene/benchmark/pom.xml.template@@ -76,27 +76,8 @@<artifactId>forbiddenapis</artifactId><executions><execution>- <id>lucene-shared-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution>- <execution>- <id>check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- <!-- Skip jdk-system-out -->- <!-- <bundledSignature>jdk-system-out</bundledSignature> -->- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>check</goal>- </goals>+ <id>lucene-shared-check-sysout-forbidden-apis</id>+ <phase>none</phase> <!-- Block inherited execution --></execution></executions></plugin>diff --git a/dev-tools/maven/lucene/core/src/java/pom.xml.template b/dev-tools/maven/lucene/core/src/java/pom.xml.templateindex 22f01c6f3e6..6baced8ce42 100644--- a/dev-tools/maven/lucene/core/src/java/pom.xml.template+++ b/dev-tools/maven/lucene/core/src/java/pom.xml.template@@ -68,51 +68,10 @@<groupId>de.thetaphi</groupId><artifactId>forbiddenapis</artifactId><executions>- <execution>- <id>lucene-shared-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution><execution><id>lucene-shared-test-check-forbidden-apis</id><phase>none</phase> <!-- Block inherited execution --></execution>- <execution>- <id>check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>check</goal>- </goals>- </execution>- <execution>- <id>check-system-out</id> <!-- separate execution to specify excludes -->- <configuration>- <bundledSignatures>- <bundledSignature>jdk-system-out</bundledSignature>- </bundledSignatures>- <excludes>- <!-- exclude command line tools -->- <exclude>org/apache/lucene/index/CheckIndex.class</exclude>- <exclude>org/apache/lucene/index/IndexUpgrader.class</exclude>- <exclude>org/apache/lucene/store/LockVerifyServer.class</exclude>- <exclude>org/apache/lucene/store/LockStressTest.class</exclude>- <!-- not printing, just checking if it's a system stream -->- <exclude>org/apache/lucene/util/PrintStreamInfoStream.class</exclude>- </excludes>- </configuration>- <goals>- <goal>check</goal>- </goals>- </execution></executions></plugin></plugins>diff --git a/dev-tools/maven/lucene/demo/pom.xml.template b/dev-tools/maven/lucene/demo/pom.xml.templateindex 6a4ae483ba0..a03470113af 100644--- a/dev-tools/maven/lucene/demo/pom.xml.template+++ b/dev-tools/maven/lucene/demo/pom.xml.template@@ -75,27 +75,8 @@<artifactId>forbiddenapis</artifactId><executions><execution>- <id>lucene-shared-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution>- <execution>- <id>check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- <!-- demo has mostly command-line programs, so don't do the jdk-system-out check -->- <!-- <bundledSignature>jdk-system-out</bundledSignature> -->- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>check</goal>- </goals>+ <id>lucene-shared-check-sysout-forbidden-apis</id>+ <phase>none</phase> <!-- Block inherited execution --></execution></executions></plugin>diff --git a/dev-tools/maven/lucene/facet/pom.xml.template b/dev-tools/maven/lucene/facet/pom.xml.templateindex d6843da3025..59330f3d184 100644--- a/dev-tools/maven/lucene/facet/pom.xml.template+++ b/dev-tools/maven/lucene/facet/pom.xml.template@@ -71,49 +71,5 @@</excludes></testResource></testResources>- <plugins>- <plugin>- <groupId>de.thetaphi</groupId>- <artifactId>forbiddenapis</artifactId>- <executions>- <execution>- <id>lucene-shared-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution>- <execution>- <id>check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>check</goal>- </goals>- </execution>- <execution>- <id>check-system-out</id> <!-- separate execution to specify excludes -->- <configuration>- <bundledSignatures>- <bundledSignature>jdk-system-out</bundledSignature>- </bundledSignatures>- <excludes>- <!-- exclude command line tools -->- <exclude>org/apache/lucene/facet/taxonomy/PrintTaxonomyStats.class</exclude>- </excludes>- </configuration>- <goals>- <goal>check</goal>- </goals>- </execution>- </executions>- </plugin>- </plugins></build></project>diff --git a/dev-tools/maven/lucene/memory/pom.xml.template b/dev-tools/maven/lucene/memory/pom.xml.templateindex 7e3b2cc4251..08b15cb03dd 100644--- a/dev-tools/maven/lucene/memory/pom.xml.template+++ b/dev-tools/maven/lucene/memory/pom.xml.template@@ -66,35 +66,5 @@</excludes></testResource></testResources>- <plugins>- <plugin>- <groupId>de.thetaphi</groupId>- <artifactId>forbiddenapis</artifactId>- <executions>- <execution>- <id>lucene-shared-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution>- <execution>- <id>check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- <bundledSignature>jdk-system-out</bundledSignature>- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>check</goal>- </goals>- </execution>- </executions>- </plugin>- </plugins></build></project>diff --git a/dev-tools/maven/lucene/misc/pom.xml.template b/dev-tools/maven/lucene/misc/pom.xml.templateindex aed9744e824..16a44b73ffa 100644--- a/dev-tools/maven/lucene/misc/pom.xml.template+++ b/dev-tools/maven/lucene/misc/pom.xml.template@@ -64,54 +64,5 @@</excludes></testResource></testResources>- <plugins>- <plugin>- <groupId>de.thetaphi</groupId>- <artifactId>forbiddenapis</artifactId>- <executions>- <execution>- <id>lucene-shared-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution>- <execution>- <id>check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>check</goal>- </goals>- </execution>- <execution>- <id>check-system-out</id>- <configuration>- <bundledSignatures>- <bundledSignature>jdk-system-out</bundledSignature>- </bundledSignatures>- <excludes>- <!-- exclude command line tools -->- <exclude>org/apache/lucene/index/CompoundFileExtractor.class</exclude>- <exclude>org/apache/lucene/index/IndexSplitter.class</exclude>- <exclude>org/apache/lucene/index/MultiPassIndexSplitter.class</exclude>- <exclude>org/apache/lucene/misc/GetTermInfo.class</exclude>- <exclude>org/apache/lucene/misc/HighFreqTerms.class</exclude>- <exclude>org/apache/lucene/misc/IndexMergeTool.class</exclude>- </excludes>- </configuration>- <goals>- <goal>check</goal>- </goals>- </execution>- </executions>- </plugin>- </plugins></build></project>diff --git a/dev-tools/maven/lucene/pom.xml.template b/dev-tools/maven/lucene/pom.xml.templateindex e7551c4af04..0e9486354d4 100644--- a/dev-tools/maven/lucene/pom.xml.template+++ b/dev-tools/maven/lucene/pom.xml.template@@ -76,16 +76,27 @@<bundledSignatures><bundledSignature>jdk-unsafe</bundledSignature><bundledSignature>jdk-deprecated</bundledSignature>- <bundledSignature>jdk-system-out</bundledSignature></bundledSignatures><signaturesFiles><signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>+ <signaturesFile>${top-level}/lucene/tools/forbiddenApis/lucene.txt</signaturesFile></signaturesFiles></configuration><goals><goal>check</goal></goals></execution>+ <execution>+ <id>lucene-shared-check-sysout-forbidden-apis</id>+ <configuration>+ <bundledSignatures>+ <bundledSignature>jdk-system-out</bundledSignature>+ </bundledSignatures>+ </configuration>+ <goals>+ <goal>check</goal>+ </goals>+ </execution><execution><id>lucene-shared-test-check-forbidden-apis</id><configuration>@@ -98,6 +109,7 @@<signaturesFiles><signaturesFile>${top-level}/lucene/tools/forbiddenApis/tests.txt</signaturesFile><signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>+ <signaturesFile>${top-level}/lucene/tools/forbiddenApis/lucene.txt</signaturesFile></signaturesFiles></configuration><goals>diff --git a/dev-tools/maven/lucene/queryparser/pom.xml.template b/dev-tools/maven/lucene/queryparser/pom.xml.templateindex 70b00f4b6bf..a03970a1537 100644--- a/dev-tools/maven/lucene/queryparser/pom.xml.template+++ b/dev-tools/maven/lucene/queryparser/pom.xml.template@@ -69,51 +69,5 @@</excludes></testResource></testResources>- <plugins>- <plugin>- <groupId>de.thetaphi</groupId>- <artifactId>forbiddenapis</artifactId>- <executions>- <execution>- <id>lucene-shared-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution>- <execution>- <id>check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>check</goal>- </goals>- </execution>- <execution>- <id>check-system-out</id>- <configuration>- <bundledSignatures>- <bundledSignature>jdk-system-out</bundledSignature>- </bundledSignatures>- <excludes>- <!-- not printing, just generated code from javacc -->- <exclude>org/apache/lucene/queryparser/classic/QueryParserTokenManager.class</exclude>- <exclude>org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.class</exclude>- <exclude>org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.class</exclude>- </excludes>- </configuration>- <goals>- <goal>check</goal>- </goals>- </execution>- </executions>- </plugin>- </plugins></build></project>diff --git a/dev-tools/maven/lucene/test-framework/pom.xml.template b/dev-tools/maven/lucene/test-framework/pom.xml.templateindex 87a274114ad..9d575d598ae 100644--- a/dev-tools/maven/lucene/test-framework/pom.xml.template+++ b/dev-tools/maven/lucene/test-framework/pom.xml.template@@ -78,26 +78,14 @@</execution><execution><id>lucene-shared-test-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution>- <execution>- <id>test-check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/tests.txt</signaturesFile>- </signaturesFiles>- </configuration><goals><goal>check</goal> <!-- NOT testCheck --></goals></execution>+ <execution>+ <id>lucene-shared-check-sysout-forbidden-apis</id>+ <phase>none</phase> <!-- Block inherited execution -->+ </execution></executions></plugin></plugins>diff --git a/dev-tools/maven/pom.xml.template b/dev-tools/maven/pom.xml.templateindex d75bbeaf189..9dbe4b7460e 100644--- a/dev-tools/maven/pom.xml.template+++ b/dev-tools/maven/pom.xml.template@@ -167,6 +167,9 @@--><failOnUnsupportedJava>false</failOnUnsupportedJava><targetVersion>${java.compat.version}</targetVersion>+ <suppressAnnotations>+ <suppressAnnotation>**.SuppressForbidden</suppressAnnotation>+ </suppressAnnotations></configuration></plugin><plugin>diff --git a/dev-tools/maven/solr/contrib/analytics/pom.xml.template b/dev-tools/maven/solr/contrib/analytics/pom.xml.templateindex 9ee8f0cc380..757426eb8d0 100644--- a/dev-tools/maven/solr/contrib/analytics/pom.xml.template+++ b/dev-tools/maven/solr/contrib/analytics/pom.xml.template@@ -76,24 +76,5 @@</includes></testResource></testResources>- <plugins>- <plugin>- <groupId>de.thetaphi</groupId>- <artifactId>forbiddenapis</artifactId>- <executions>- <execution>- <id>test-check-forbidden-servlet-api</id>- <configuration>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>testCheck</goal>- </goals>- </execution>- </executions>- </plugin>- </plugins></build></project>diff --git a/dev-tools/maven/solr/contrib/extraction/pom.xml.template b/dev-tools/maven/solr/contrib/extraction/pom.xml.templateindex 51b1ae99692..96b3f70c4c5 100644--- a/dev-tools/maven/solr/contrib/extraction/pom.xml.template+++ b/dev-tools/maven/solr/contrib/extraction/pom.xml.template@@ -77,24 +77,5 @@</includes></testResource></testResources>- <plugins>- <plugin>- <groupId>de.thetaphi</groupId>- <artifactId>forbiddenapis</artifactId>- <executions>- <execution>- <id>test-check-forbidden-servlet-api</id>- <configuration>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>testCheck</goal>- </goals>- </execution>- </executions>- </plugin>- </plugins></build></project>diff --git a/dev-tools/maven/solr/contrib/langid/pom.xml.template b/dev-tools/maven/solr/contrib/langid/pom.xml.templateindex f7d47a46482..67410df187a 100644--- a/dev-tools/maven/solr/contrib/langid/pom.xml.template+++ b/dev-tools/maven/solr/contrib/langid/pom.xml.template@@ -83,24 +83,5 @@</includes></testResource></testResources>- <plugins>- <plugin>- <groupId>de.thetaphi</groupId>- <artifactId>forbiddenapis</artifactId>- <executions>- <execution>- <id>test-check-forbidden-servlet-api</id>- <configuration>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>testCheck</goal>- </goals>- </execution>- </executions>- </plugin>- </plugins></build></project>diff --git a/dev-tools/maven/solr/contrib/map-reduce/pom.xml.template b/dev-tools/maven/solr/contrib/map-reduce/pom.xml.templateindex 6875ba2c652..2c216afcb19 100644--- a/dev-tools/maven/solr/contrib/map-reduce/pom.xml.template+++ b/dev-tools/maven/solr/contrib/map-reduce/pom.xml.template@@ -86,24 +86,5 @@</includes></testResource></testResources>- <plugins>- <plugin>- <groupId>de.thetaphi</groupId>- <artifactId>forbiddenapis</artifactId>- <executions>- <execution>- <id>test-check-forbidden-servlet-api</id>- <configuration>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>testCheck</goal>- </goals>- </execution>- </executions>- </plugin>- </plugins></build></project>diff --git a/dev-tools/maven/solr/contrib/morphlines-cell/pom.xml.template b/dev-tools/maven/solr/contrib/morphlines-cell/pom.xml.templateindex f8a50c3a208..3d9ecd5d971 100644--- a/dev-tools/maven/solr/contrib/morphlines-cell/pom.xml.template+++ b/dev-tools/maven/solr/contrib/morphlines-cell/pom.xml.template@@ -86,24 +86,5 @@</includes></testResource></testResources>- <plugins>- <plugin>- <groupId>de.thetaphi</groupId>- <artifactId>forbiddenapis</artifactId>- <executions>- <execution>- <id>test-check-forbidden-servlet-api</id>- <configuration>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>testCheck</goal>- </goals>- </execution>- </executions>- </plugin>- </plugins></build></project>diff --git a/dev-tools/maven/solr/contrib/morphlines-core/pom.xml.template b/dev-tools/maven/solr/contrib/morphlines-core/pom.xml.templateindex a319566d584..51ef6f00c4c 100644--- a/dev-tools/maven/solr/contrib/morphlines-core/pom.xml.template+++ b/dev-tools/maven/solr/contrib/morphlines-core/pom.xml.template@@ -75,23 +75,6 @@</testResource></testResources><plugins>- <plugin>- <groupId>de.thetaphi</groupId>- <artifactId>forbiddenapis</artifactId>- <executions>- <execution>- <id>test-check-forbidden-servlet-api</id>- <configuration>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>testCheck</goal>- </goals>- </execution>- </executions>- </plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId>diff --git a/dev-tools/maven/solr/contrib/uima/pom.xml.template b/dev-tools/maven/solr/contrib/uima/pom.xml.templateindex e902646c82a..17038a0ea32 100644--- a/dev-tools/maven/solr/contrib/uima/pom.xml.template+++ b/dev-tools/maven/solr/contrib/uima/pom.xml.template@@ -79,24 +79,5 @@</includes></testResource></testResources>- <plugins>- <plugin>- <groupId>de.thetaphi</groupId>- <artifactId>forbiddenapis</artifactId>- <executions>- <execution>- <id>test-check-forbidden-servlet-api</id>- <configuration>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>testCheck</goal>- </goals>- </execution>- </executions>- </plugin>- </plugins></build></project>diff --git a/dev-tools/maven/solr/contrib/velocity/pom.xml.template b/dev-tools/maven/solr/contrib/velocity/pom.xml.templateindex 952572af8c0..d6d24a73064 100644--- a/dev-tools/maven/solr/contrib/velocity/pom.xml.template+++ b/dev-tools/maven/solr/contrib/velocity/pom.xml.template@@ -85,24 +85,5 @@</includes></testResource></testResources>- <plugins>- <plugin>- <groupId>de.thetaphi</groupId>- <artifactId>forbiddenapis</artifactId>- <executions>- <execution>- <id>test-check-forbidden-servlet-api</id>- <configuration>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>testCheck</goal>- </goals>- </execution>- </executions>- </plugin>- </plugins></build></project>diff --git a/dev-tools/maven/solr/core/src/java/pom.xml.template b/dev-tools/maven/solr/core/src/java/pom.xml.templateindex da05bf95ea4..22bde78d042 100644--- a/dev-tools/maven/solr/core/src/java/pom.xml.template+++ b/dev-tools/maven/solr/core/src/java/pom.xml.template@@ -68,33 +68,10 @@<groupId>de.thetaphi</groupId><artifactId>forbiddenapis</artifactId><executions>- <execution>- <id>solr-shared-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution><execution><id>solr-shared-test-check-forbidden-apis</id><phase>none</phase> <!-- Block inherited execution --></execution>- <execution>- <id>check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- <bundledSignature>commons-io-unsafe-@commons-io:commons-io.version@</bundledSignature>- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>check</goal>- </goals>- </execution></executions></plugin></plugins>diff --git a/dev-tools/maven/solr/core/src/test/pom.xml.template b/dev-tools/maven/solr/core/src/test/pom.xml.templateindex 610b30eeb9b..de143041bc1 100644--- a/dev-tools/maven/solr/core/src/test/pom.xml.template+++ b/dev-tools/maven/solr/core/src/test/pom.xml.template@@ -123,43 +123,12 @@</execution><execution><id>solr-shared-test-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution>- <execution>- <id>test-check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- <bundledSignature>commons-io-unsafe-@commons-io:commons-io.version@</bundledSignature>- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>testCheck</goal>- </goals>- </execution>- <execution>- <id>test-check-forbidden-test-apis</id> <!-- Separate execution to specify excludes --><configuration>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/tests.txt</signaturesFile>- </signaturesFiles><excludes>- <!-- not actually a test -->- <exclude>org/apache/solr/search/DocSetPerf.class</exclude>- <!-- imported code -->+ <!-- TODO: remove this - imported code --><exclude>org/apache/solr/internal/**/*.class</exclude></excludes></configuration>- <goals>- <goal>testCheck</goal>- </goals></execution></executions></plugin>diff --git a/dev-tools/maven/solr/pom.xml.template b/dev-tools/maven/solr/pom.xml.templateindex 518748d3ba8..c0d6290a046 100644--- a/dev-tools/maven/solr/pom.xml.template+++ b/dev-tools/maven/solr/pom.xml.template@@ -119,12 +119,17 @@<configuration><!-- disallow undocumented classes like sun.misc.Unsafe: --><internalRuntimeForbidden>true</internalRuntimeForbidden>+ <!-- for simplicty with servlet-api and commons-io checks, disable this: -->+ <failOnUnresolvableSignatures>false</failOnUnresolvableSignatures><bundledSignatures><bundledSignature>jdk-unsafe</bundledSignature><bundledSignature>jdk-deprecated</bundledSignature>+ <bundledSignature>commons-io-unsafe-@commons-io:commons-io.version@</bundledSignature></bundledSignatures><signaturesFiles><signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>+ <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile>+ <signaturesFile>${top-level}/lucene/tools/forbiddenApis/solr.txt</signaturesFile></signaturesFiles></configuration><goals>@@ -136,15 +141,18 @@<configuration><!-- disallow undocumented classes like sun.misc.Unsafe: --><internalRuntimeForbidden>true</internalRuntimeForbidden>+ <!-- for simplicty with servlet-api and commons-io checks, disable this: -->+ <failOnUnresolvableSignatures>false</failOnUnresolvableSignatures><bundledSignatures><bundledSignature>jdk-unsafe</bundledSignature><bundledSignature>jdk-deprecated</bundledSignature>- <!-- Include commons-io-unsafe only in those modules with commons-io on their classpath -->- <!-- <bundledSignature>commons-io-unsafe-@commons-io:commons-io.version@</bundledSignature> -->+ <bundledSignature>commons-io-unsafe-@commons-io:commons-io.version@</bundledSignature></bundledSignatures><signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/tests.txt</signaturesFile><signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>+ <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile>+ <signaturesFile>${top-level}/lucene/tools/forbiddenApis/solr.txt</signaturesFile>+ <signaturesFile>${top-level}/lucene/tools/forbiddenApis/tests.txt</signaturesFile></signaturesFiles></configuration><goals>diff --git a/dev-tools/maven/solr/solrj/src/java/pom.xml.template b/dev-tools/maven/solr/solrj/src/java/pom.xml.templateindex 20ba5eb9a3e..f120eb05c51 100644--- a/dev-tools/maven/solr/solrj/src/java/pom.xml.template+++ b/dev-tools/maven/solr/solrj/src/java/pom.xml.template@@ -67,34 +67,10 @@<groupId>de.thetaphi</groupId><artifactId>forbiddenapis</artifactId><executions>- <execution>- <id>solr-shared-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution><execution><id>solr-shared-test-check-forbidden-apis</id><phase>none</phase> <!-- Block inherited execution --></execution>- <execution>- <id>check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- <bundledSignature>commons-io-unsafe-@commons-io:commons-io.version@</bundledSignature>- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- <!-- Solr-J does NOT depend on servlet-api -->- <!-- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile> -->- </signaturesFiles>- </configuration>- <goals>- <goal>check</goal>- </goals>- </execution></executions></plugin></plugins>diff --git a/dev-tools/maven/solr/solrj/src/test/pom.xml.template b/dev-tools/maven/solr/solrj/src/test/pom.xml.templateindex ee5e4df6600..2946713536c 100644--- a/dev-tools/maven/solr/solrj/src/test/pom.xml.template+++ b/dev-tools/maven/solr/solrj/src/test/pom.xml.template@@ -115,44 +115,6 @@<id>solr-shared-check-forbidden-apis</id><phase>none</phase> <!-- Block inherited execution --></execution>- <execution>- <id>solr-shared-test-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution>- <execution>- <id>test-check-forbidden-servlet-api</id>- <configuration>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile>- </signaturesFiles>- <excludes>- <!-- violates the servlet-api restrictions, but it is safe to do so in this test: -->- <exclude>org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest$DebugServlet.class</exclude>- </excludes>- </configuration>- <goals>- <goal>testCheck</goal>- </goals>- </execution>- <execution>- <id>test-check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- <bundledSignature>commons-io-unsafe-@commons-io:commons-io.version@</bundledSignature>- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/tests.txt</signaturesFile>- </signaturesFiles>- </configuration>- <goals>- <goal>testCheck</goal>- </goals>- </execution></executions></plugin></plugins>diff --git a/dev-tools/maven/solr/test-framework/pom.xml.template b/dev-tools/maven/solr/test-framework/pom.xml.templateindex e06566df3f1..00530cbb879 100644--- a/dev-tools/maven/solr/test-framework/pom.xml.template+++ b/dev-tools/maven/solr/test-framework/pom.xml.template@@ -72,7 +72,7 @@<skip>true</skip></configuration></plugin>- <plugin>+ <plugin><groupId>de.thetaphi</groupId><artifactId>forbiddenapis</artifactId><executions>@@ -82,26 +82,8 @@</execution><execution><id>solr-shared-test-check-forbidden-apis</id>- <phase>none</phase> <!-- Block inherited execution -->- </execution>- <execution>- <id>check-forbidden-apis</id>- <configuration>- <!-- disallow undocumented classes like sun.misc.Unsafe: -->- <internalRuntimeForbidden>true</internalRuntimeForbidden>- <bundledSignatures>- <bundledSignature>jdk-unsafe</bundledSignature>- <bundledSignature>jdk-deprecated</bundledSignature>- <bundledSignature>commons-io-unsafe-@commons-io:commons-io.version@</bundledSignature>- </bundledSignatures>- <signaturesFiles>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/base.txt</signaturesFile>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/servlet-api.txt</signaturesFile>- <signaturesFile>${top-level}/lucene/tools/forbiddenApis/tests.txt</signaturesFile>- </signaturesFiles>- </configuration><goals>- <goal>check</goal> <!-- NOT testcheck -->+ <goal>check</goal> <!-- NOT testCheck --></goals></execution></executions>diff --git a/lucene/analysis/stempel/build.xml b/lucene/analysis/stempel/build.xmlindex 6a2c17faaca..5aaa1ee13e8 100644--- a/lucene/analysis/stempel/build.xml+++ b/lucene/analysis/stempel/build.xml@@ -22,11 +22,6 @@<description>Analyzer for indexing Polish</description>-- <property name="forbidden-sysout-excludes" value="- org/egothor/stemmer/Compile.class- org/egothor/stemmer/DiffIt.class- "/><import file="../analysis-module-build.xml"/>diff --git a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Compile.java b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Compile.javaindex 13b478f5edb..07bf13f92ee 100644--- a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Compile.java+++ b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Compile.java@@ -63,6 +63,8 @@ import java.nio.file.Paths;import java.util.Locale;import java.util.StringTokenizer;+import org.apache.lucene.util.SuppressForbidden;+/*** The Compile class is used to compile a stemmer table.*/@@ -85,6 +87,7 @@ public class Compile {** @param args the command line arguments*/+ @SuppressForbidden(reason = "System.out required: command line tool")public static void main(java.lang.String[] args) throws Exception {if (args.length < 1) {return;diff --git a/lucene/analysis/stempel/src/java/org/egothor/stemmer/DiffIt.java b/lucene/analysis/stempel/src/java/org/egothor/stemmer/DiffIt.javaindex 56c09379d30..963cb104e35 100644--- a/lucene/analysis/stempel/src/java/org/egothor/stemmer/DiffIt.java+++ b/lucene/analysis/stempel/src/java/org/egothor/stemmer/DiffIt.java@@ -61,6 +61,8 @@ import java.nio.file.Paths;import java.util.Locale;import java.util.StringTokenizer;+import org.apache.lucene.util.SuppressForbidden;+/*** The DiffIt class is a means generate patch commands from an already prepared* stemmer table.@@ -87,6 +89,7 @@ public class DiffIt {** @param args the path to a file containing a stemmer table*/+ @SuppressForbidden(reason = "System.out required: command line tool")public static void main(java.lang.String[] args) throws Exception {int ins = get(0, args[0]);diff --git a/lucene/common-build.xml b/lucene/common-build.xmlindex 138fb25a0f5..578e3571993 100644--- a/lucene/common-build.xml+++ b/lucene/common-build.xml@@ -2374,7 +2374,7 @@ ${ant.project.name}.test.dependencies=${test.classpath.list}<!-- applies to both source and test code --><target name="-check-forbidden-all" depends="-init-forbidden-apis,compile-core,compile-test">- <forbidden-apis internalRuntimeForbidden="true" classpathref="forbidden-apis.allclasses.classpath">+ <forbidden-apis internalRuntimeForbidden="true" suppressAnnotation="**.SuppressForbidden" classpathref="forbidden-apis.allclasses.classpath"><bundledSignatures name="jdk-unsafe-${javac.target}"/><bundledSignatures name="jdk-deprecated-${javac.target}"/><signaturesFileSet dir="${common.dir}/tools/forbiddenApis">@@ -2388,7 +2388,7 @@ ${ant.project.name}.test.dependencies=${test.classpath.list}<!-- applies to only test code --><target name="-check-forbidden-tests" depends="-init-forbidden-apis,compile-test">- <forbidden-apis signaturesFile="${common.dir}/tools/forbiddenApis/tests.txt" classpathref="forbidden-apis.allclasses.classpath">+ <forbidden-apis signaturesFile="${common.dir}/tools/forbiddenApis/tests.txt" suppressAnnotation="**.SuppressForbidden" classpathref="forbidden-apis.allclasses.classpath"><fileset dir="${build.dir}/classes/test" excludes="${forbidden-tests-excludes}"/></forbidden-apis></target>@@ -2397,7 +2397,7 @@ ${ant.project.name}.test.dependencies=${test.classpath.list}<target name="-check-forbidden-core" depends="-init-forbidden-apis,compile-core,-check-forbidden-sysout" /><target name="-check-forbidden-sysout" depends="-init-forbidden-apis,compile-core">- <forbidden-apis bundledSignatures="jdk-system-out" classpathref="forbidden-apis.allclasses.classpath">+ <forbidden-apis bundledSignatures="jdk-system-out" suppressAnnotation="**.SuppressForbidden" classpathref="forbidden-apis.allclasses.classpath"><fileset dir="${build.dir}/classes/java" excludes="${forbidden-sysout-excludes}"/></forbidden-apis></target>diff --git a/lucene/core/build.xml b/lucene/core/build.xmlindex 19e571e2d68..2399669580c 100644--- a/lucene/core/build.xml+++ b/lucene/core/build.xml@@ -22,19 +22,6 @@<property name="build.dir" location="../build/core"/>- <property name="forbidden-sysout-excludes" value="- org/apache/lucene/index/CheckIndex.class- org/apache/lucene/index/IndexUpgrader.class- org/apache/lucene/store/LockVerifyServer.class- org/apache/lucene/store/LockStressTest.class- org/apache/lucene/util/PrintStreamInfoStream.class- "/>-- <!-- Needs to start a process -->- <property name="forbidden-tests-excludes" value="- org/apache/lucene/index/TestIndexWriterOnJRECrash.class- "/>-<!-- lucene core can use the minimal JDK profile --><property name="javac.profile.args" value="-profile compact1"/><import file="../common-build.xml"/>diff --git a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.javaindex c354a30ff90..41c97fc4c8a 100644--- a/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java+++ b/lucene/core/src/java/org/apache/lucene/index/CheckIndex.java@@ -57,6 +57,7 @@ import org.apache.lucene.util.FixedBitSet;import org.apache.lucene.util.IOUtils;import org.apache.lucene.util.LongBitSet;import org.apache.lucene.util.StringHelper;+import org.apache.lucene.util.SuppressForbidden;import org.apache.lucene.util.Version;import org.apache.lucene.util.automaton.Automata;import org.apache.lucene.util.automaton.CompiledAutomaton;@@ -2283,6 +2284,7 @@ public class CheckIndex implements Closeable {}// actual main: returns exit code instead of terminating JVM (for easy testing)+ @SuppressForbidden(reason = "System.out required: command line tool")private static int doMain(String args[]) throws IOException, InterruptedException {boolean doExorcise = false;diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java b/lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.javaindex 706b3d44cee..e7a6cba76a0 100644--- a/lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java+++ b/lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java@@ -22,6 +22,7 @@ import org.apache.lucene.store.FSDirectory;import org.apache.lucene.util.CommandLineUtil;import org.apache.lucene.util.InfoStream;import org.apache.lucene.util.PrintStreamInfoStream;+import org.apache.lucene.util.SuppressForbidden;import org.apache.lucene.util.Version;import java.io.IOException;@@ -52,6 +53,7 @@ import java.util.Collection;*/public final class IndexUpgrader {+ @SuppressForbidden(reason = "System.out required: command line tool")private static void printUsage() {System.err.println("Upgrades an index so all segments created with a previous Lucene version are rewritten.");System.err.println("Usage:");@@ -73,6 +75,8 @@ public final class IndexUpgrader {public static void main(String[] args) throws IOException {parseArgs(args).upgrade();}++ @SuppressForbidden(reason = "System.out required: command line tool")static IndexUpgrader parseArgs(String[] args) throws IOException {String path = null;boolean deletePriorCommits = false;diff --git a/lucene/core/src/java/org/apache/lucene/store/LockStressTest.java b/lucene/core/src/java/org/apache/lucene/store/LockStressTest.javaindex 4840ae9ff2a..7726734b675 100644--- a/lucene/core/src/java/org/apache/lucene/store/LockStressTest.java+++ b/lucene/core/src/java/org/apache/lucene/store/LockStressTest.java@@ -26,6 +26,8 @@ import java.nio.file.Path;import java.nio.file.Paths;import java.util.Random;+import org.apache.lucene.util.SuppressForbidden;+/*** Simple standalone tool that forever acquires and releases a* lock using a specific LockFactory. Run without any args@@ -37,6 +39,7 @@ import java.util.Random;public class LockStressTest {+ @SuppressForbidden(reason = "System.out required: command line tool")public static void main(String[] args) throws Exception {if (args.length != 7) {diff --git a/lucene/core/src/java/org/apache/lucene/store/LockVerifyServer.java b/lucene/core/src/java/org/apache/lucene/store/LockVerifyServer.javaindex c61f68c4d71..89da64c3412 100644--- a/lucene/core/src/java/org/apache/lucene/store/LockVerifyServer.java+++ b/lucene/core/src/java/org/apache/lucene/store/LockVerifyServer.java@@ -26,6 +26,7 @@ import java.net.Socket;import java.util.concurrent.CountDownLatch;import org.apache.lucene.util.IOUtils;+import org.apache.lucene.util.SuppressForbidden;/*** Simple standalone server that must be running when you@@ -39,6 +40,7 @@ import org.apache.lucene.util.IOUtils;public class LockVerifyServer {+ @SuppressForbidden(reason = "System.out required: command line tool")public static void main(String[] args) throws Exception {if (args.length != 2) {diff --git a/lucene/core/src/java/org/apache/lucene/util/PrintStreamInfoStream.java b/lucene/core/src/java/org/apache/lucene/util/PrintStreamInfoStream.javaindex 190d0fa86eb..cc03d43c8ff 100644--- a/lucene/core/src/java/org/apache/lucene/util/PrintStreamInfoStream.java+++ b/lucene/core/src/java/org/apache/lucene/util/PrintStreamInfoStream.java@@ -66,6 +66,7 @@ public class PrintStreamInfoStream extends InfoStream {}}+ @SuppressForbidden(reason = "System.out/err detection")public boolean isSystemStream() {return stream == System.out || stream == System.err;}diff --git a/lucene/core/src/java/org/apache/lucene/util/SuppressForbidden.java b/lucene/core/src/java/org/apache/lucene/util/SuppressForbidden.javanew file mode 100644index 00000000000..afe9b302f0b--- /dev/null+++ b/lucene/core/src/java/org/apache/lucene/util/SuppressForbidden.java@@ -0,0 +1,34 @@+package org.apache.lucene.util;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import java.lang.annotation.Retention;+import java.lang.annotation.RetentionPolicy;+import java.lang.annotation.Target;+import java.lang.annotation.ElementType;++/**+ * Annotation to suppress forbidden-apis errors inside a whole class, a method, or a field.+ * @lucene.internal+ */+@Retention(RetentionPolicy.CLASS)+@Target({ ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE })+public @interface SuppressForbidden {+ /** A reason for suppressing should always be given. */+ String reason();+}diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnJRECrash.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnJRECrash.javaindex 6855802d019..3c7c17ec544 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnJRECrash.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnJRECrash.java@@ -35,6 +35,7 @@ import java.util.concurrent.atomic.AtomicBoolean;import org.apache.lucene.store.BaseDirectoryWrapper;import org.apache.lucene.util.Constants;+import org.apache.lucene.util.SuppressForbidden;import org.apache.lucene.util.TestUtil;import com.carrotsearch.randomizedtesting.SeedUtils;@@ -92,6 +93,7 @@ public class TestIndexWriterOnJRECrash extends TestNRTThreads {}/** fork ourselves in a new jvm. sets -Dtests.crashmode=true */+ @SuppressForbidden(reason = "ProcessBuilder requires java.io.File for CWD")public void forkTest() throws Exception {List<String> cmd = new ArrayList<>();cmd.add(System.getProperty("java.home")diff --git a/lucene/facet/build.xml b/lucene/facet/build.xmlindex b8321aa2468..1a568ea369c 100644--- a/lucene/facet/build.xml+++ b/lucene/facet/build.xml@@ -23,10 +23,6 @@Faceted indexing and search capabilities</description>- <property name="forbidden-sysout-excludes" value="- org/apache/lucene/facet/taxonomy/PrintTaxonomyStats.class- "/>-<import file="../module-build.xml"/><path id="classpath">diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/PrintTaxonomyStats.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/PrintTaxonomyStats.javaindex 102e47c9b3c..668a300636f 100644--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/PrintTaxonomyStats.java+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/PrintTaxonomyStats.java@@ -25,6 +25,7 @@ import org.apache.lucene.facet.taxonomy.TaxonomyReader.ChildrenIterator;import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;import org.apache.lucene.store.Directory;import org.apache.lucene.store.FSDirectory;+import org.apache.lucene.util.SuppressForbidden;/** Prints how many ords are under each dimension. */@@ -36,6 +37,7 @@ public class PrintTaxonomyStats {}/** Command-line tool. */+ @SuppressForbidden(reason = "System.out required: command line tool")public static void main(String[] args) throws IOException {boolean printTree = false;String path = null;diff --git a/lucene/misc/build.xml b/lucene/misc/build.xmlindex e4d52d713e6..f076eba9e3e 100644--- a/lucene/misc/build.xml+++ b/lucene/misc/build.xml@@ -23,23 +23,6 @@Index tools and other miscellaneous code</description>- <property name="forbidden-base-excludes" value="- org/apache/lucene/store/NativeUnixDirectory$NativeUnixIndexInput.class- org/apache/lucene/store/NativeUnixDirectory$NativeUnixIndexOutput.class- org/apache/lucene/store/RAFDirectory.class- org/apache/lucene/store/RAFDirectory$RAFIndexInput.class- org/apache/lucene/store/RAFDirectory$RAFIndexOutput.class- "/>-- <property name="forbidden-sysout-excludes" value="- org/apache/lucene/index/CompoundFileExtractor.class- org/apache/lucene/index/IndexSplitter.class- org/apache/lucene/index/MultiPassIndexSplitter.class- org/apache/lucene/misc/GetTermInfo.class- org/apache/lucene/misc/HighFreqTerms.class- org/apache/lucene/misc/IndexMergeTool.class- "/>-<import file="../module-build.xml"/><target name="install-cpptasks" unless="cpptasks.uptodate" depends="ivy-availability-check,ivy-fail,ivy-configure">diff --git a/lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java b/lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.javaindex c4edf5b4ee9..c672ed00bac 100644--- a/lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java+++ b/lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java@@ -29,6 +29,7 @@ import java.util.List;import java.util.Locale;import org.apache.lucene.store.FSDirectory;+import org.apache.lucene.util.SuppressForbidden;/*** Command-line tool that enables listing segments in an@@ -54,6 +55,7 @@ public class IndexSplitter {Path dir;+ @SuppressForbidden(reason = "System.out required: command line tool")public static void main(String[] args) throws Exception {if (args.length < 2) {System.err@@ -93,6 +95,7 @@ public class IndexSplitter {infos = SegmentInfos.readLatestCommit(fsDir);}+ @SuppressForbidden(reason = "System.out required: command line tool")public void listSegments() throws IOException {DecimalFormat formatter = new DecimalFormat("###,###.###", DecimalFormatSymbols.getInstance(Locale.ROOT));for (int x = 0; x < infos.size(); x++) {diff --git a/lucene/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java b/lucene/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.javaindex 3a581682cf8..13632fe651f 100644--- a/lucene/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java+++ b/lucene/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java@@ -29,6 +29,7 @@ import org.apache.lucene.store.Directory;import org.apache.lucene.store.FSDirectory;import org.apache.lucene.util.FixedBitSet;import org.apache.lucene.util.Bits;+import org.apache.lucene.util.SuppressForbidden;import org.apache.lucene.util.Version;/**@@ -47,6 +48,7 @@ import org.apache.lucene.util.Version;* IndexWriter#updateDocuments}, which means it can easily* break up such document groups.*/+@SuppressForbidden(reason = "System.out required: command line tool")public class MultiPassIndexSplitter {/**diff --git a/lucene/misc/src/java/org/apache/lucene/misc/GetTermInfo.java b/lucene/misc/src/java/org/apache/lucene/misc/GetTermInfo.javaindex 9b5f86662ea..6bd9a4b6f17 100644--- a/lucene/misc/src/java/org/apache/lucene/misc/GetTermInfo.java+++ b/lucene/misc/src/java/org/apache/lucene/misc/GetTermInfo.java@@ -19,8 +19,10 @@ package org.apache.lucene.misc;import java.nio.file.Paths;import java.util.Locale;+import org.apache.lucene.store.Directory;import org.apache.lucene.store.FSDirectory;+import org.apache.lucene.util.SuppressForbidden;import org.apache.lucene.index.DirectoryReader;import org.apache.lucene.index.IndexReader;import org.apache.lucene.index.Term;@@ -28,6 +30,7 @@ import org.apache.lucene.index.Term;/*** Utility to get document frequency and total number of occurrences (sum of the tf for each doc) of a term.*/+@SuppressForbidden(reason = "System.out required: command line tool")public class GetTermInfo {public static void main(String[] args) throws Exception {diff --git a/lucene/misc/src/java/org/apache/lucene/misc/HighFreqTerms.java b/lucene/misc/src/java/org/apache/lucene/misc/HighFreqTerms.javaindex 8a5cb0b5ce8..7332a375ccf 100644--- a/lucene/misc/src/java/org/apache/lucene/misc/HighFreqTerms.java+++ b/lucene/misc/src/java/org/apache/lucene/misc/HighFreqTerms.java@@ -27,6 +27,7 @@ import org.apache.lucene.store.Directory;import org.apache.lucene.store.FSDirectory;import org.apache.lucene.util.PriorityQueue;import org.apache.lucene.util.BytesRef;+import org.apache.lucene.util.SuppressForbidden;import java.io.IOException;import java.nio.file.Paths;@@ -47,6 +48,7 @@ public class HighFreqTerms {// The top numTerms will be displayedpublic static final int DEFAULT_NUMTERMS = 100;+ @SuppressForbidden(reason = "System.out required: command line tool")public static void main(String[] args) throws Exception {String field = null;int numTerms = DEFAULT_NUMTERMS;@@ -83,6 +85,7 @@ public class HighFreqTerms {reader.close();}+ @SuppressForbidden(reason = "System.out required: command line tool")private static void usage() {System.out.println("\n\n"diff --git a/lucene/misc/src/java/org/apache/lucene/misc/IndexMergeTool.java b/lucene/misc/src/java/org/apache/lucene/misc/IndexMergeTool.javaindex 780ee7a5bb7..49b7071f718 100644--- a/lucene/misc/src/java/org/apache/lucene/misc/IndexMergeTool.java+++ b/lucene/misc/src/java/org/apache/lucene/misc/IndexMergeTool.java@@ -21,6 +21,7 @@ import org.apache.lucene.index.IndexWriterConfig;import org.apache.lucene.index.IndexWriterConfig.OpenMode;import org.apache.lucene.store.Directory;import org.apache.lucene.store.FSDirectory;+import org.apache.lucene.util.SuppressForbidden;import java.io.IOException;import java.nio.file.Paths;@@ -29,7 +30,9 @@ import java.nio.file.Paths;* Merges indices specified on the command line into the index* specified as the first command line argument.*/+@SuppressForbidden(reason = "System.out required: command line tool")public class IndexMergeTool {+public static void main(String[] args) throws IOException {if (args.length < 3) {System.err.println("Usage: IndexMergeTool <mergedIndex> <index1> <index2> [index3] ...");@@ -53,4 +56,5 @@ public class IndexMergeTool {writer.close();System.out.println("Done.");}+}diff --git a/lucene/misc/src/java/org/apache/lucene/store/NativeUnixDirectory.java b/lucene/misc/src/java/org/apache/lucene/store/NativeUnixDirectory.javaindex 32898c333a4..e547fbc1bdd 100644--- a/lucene/misc/src/java/org/apache/lucene/store/NativeUnixDirectory.java+++ b/lucene/misc/src/java/org/apache/lucene/store/NativeUnixDirectory.java@@ -28,6 +28,7 @@ import java.nio.file.Path;import org.apache.lucene.store.Directory; // javadocimport org.apache.lucene.store.IOContext.Context;+import org.apache.lucene.util.SuppressForbidden;// TODO// - newer Linux kernel versions (after 2.6.29) have@@ -152,6 +153,7 @@ public class NativeUnixDirectory extends FSDirectory {}}+ @SuppressForbidden(reason = "java.io.File: native API requires old-style FileDescriptor")private final static class NativeUnixIndexOutput extends IndexOutput {private final ByteBuffer buffer;private final FileOutputStream fos;@@ -273,6 +275,7 @@ public class NativeUnixDirectory extends FSDirectory {}}+ @SuppressForbidden(reason = "java.io.File: native API requires old-style FileDescriptor")private final static class NativeUnixIndexInput extends IndexInput {private final ByteBuffer buffer;private final FileInputStream fis;diff --git a/lucene/misc/src/java/org/apache/lucene/store/RAFDirectory.java b/lucene/misc/src/java/org/apache/lucene/store/RAFDirectory.javaindex df8f2c30b6d..9c3e9b0fc60 100644--- a/lucene/misc/src/java/org/apache/lucene/store/RAFDirectory.java+++ b/lucene/misc/src/java/org/apache/lucene/store/RAFDirectory.java@@ -23,6 +23,8 @@ import java.io.IOException;import java.io.RandomAccessFile;import java.nio.file.Path;+import org.apache.lucene.util.SuppressForbidden;+/** A straightforward implementation of {@link FSDirectory}* using java.io.RandomAccessFile. However, this class has* poor concurrent performance (multiple threads will@@ -35,6 +37,7 @@ import java.nio.file.Path;* provided for applications that relied on the fact that* RandomAccessFile's IO was not interruptible.*/+@SuppressForbidden(reason = "java.io.File: RAFDirectory is legacy API")public class RAFDirectory extends FSDirectory {/** Create a new RAFDirectory for the named location.@@ -72,6 +75,7 @@ public class RAFDirectory extends FSDirectory {* Reads bytes with {@link RandomAccessFile#seek(long)} followed by* {@link RandomAccessFile#read(byte[], int, int)}.*/+ @SuppressForbidden(reason = "java.io.File: RAFDirectory is legacy API")static final class RAFIndexInput extends BufferedIndexInput {/*** The maximum chunk size is 8192 bytes, because {@link RandomAccessFile} mallocsdiff --git a/lucene/queryparser/build.xml b/lucene/queryparser/build.xmlindex 5df912611fc..671e3445599 100644--- a/lucene/queryparser/build.xml+++ b/lucene/queryparser/build.xml@@ -20,11 +20,6 @@Query parsers and parsing framework</description>- <!-- TODO: remove the stupid debugStream in the JavaCC TokenManager classes with an additional regex below! -->- <property name="forbidden-sysout-excludes" value="- org/apache/lucene/queryparser/**/*TokenManager.class- "/>-<import file="../module-build.xml"/><path id="classpath">@@ -47,12 +42,17 @@<target name="javacc" depends="javacc-QueryParser,javacc-surround,javacc-flexible"/>- <macrodef name="replaceStringBuffer">+ <macrodef name="generalReplaces"><attribute name="dir"/><sequential>+ <!-- StringBuffer -> StringBuilder --><replace token="StringBuffer" value="StringBuilder" encoding="UTF-8"><fileset dir="@{dir}" includes="ParseException.java TokenMgrError.java"/></replace>+ <!-- Remove debug stream (violates forbiddena-apis) -->+ <replaceregexp match="/\*\* Debug.*debugStream\s*=\s*ds;\s*}" replace="" flags="s" encoding="UTF-8">+ <fileset dir="@{dir}" includes="*TokenManager.java"/>+ </replaceregexp></sequential></macrodef>@@ -70,7 +70,7 @@byline="true"match="public QueryParser\(QueryParserTokenManager "replace="protected QueryParser(QueryParserTokenManager "/>- <replaceStringBuffer dir="src/java/org/apache/lucene/queryparser/classic"/>+ <generalReplaces dir="src/java/org/apache/lucene/queryparser/classic"/></sequential></target>@@ -78,7 +78,7 @@<invoke-javacc target="src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj"outputDir="src/java/org/apache/lucene/queryparser/surround/parser"/>- <replaceStringBuffer dir="src/java/org/apache/lucene/queryparser/surround/parser"/>+ <generalReplaces dir="src/java/org/apache/lucene/queryparser/surround/parser"/></target><target name="javacc-flexible" depends="resolve-javacc">@@ -137,7 +137,7 @@ import org.apache.lucene.queryparser.flexible.core.messages.*;"replace=" static private String add_escapes(String str) {"flags="g"byline="true"/>- <replaceStringBuffer dir="src/java/org/apache/lucene/queryparser/flexible/standard/parser"/>+ <generalReplaces dir="src/java/org/apache/lucene/queryparser/flexible/standard/parser"/></target><target name="resolve-javacc" xmlns:ivy="antlib:org.apache.ivy.ant">diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.javaindex af0db955ecf..af93ff0ddaa 100644--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParser.java@@ -164,7 +164,7 @@ public class QueryParser extends QueryParserBase implements QueryParserConstants}final public Query Query(String field) throws ParseException {- List<BooleanClause> clauses = new ArrayList<>();+ List<BooleanClause> clauses = new ArrayList<BooleanClause>();Query q, firstQuery=null;int conj, mods;mods = Modifiers();@@ -630,7 +630,7 @@ public class QueryParser extends QueryParserBase implements QueryParserConstantsreturn (jj_ntk = jj_nt.kind);}- private java.util.List<int[]> jj_expentries = new java.util.ArrayList<>();+ private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();private int[] jj_expentry;private int jj_kind = -1;private int[] jj_lasttokens = new int[100];diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.javaindex cad0ed4cd00..bdb18a29060 100644--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserTokenManager.java@@ -10,16 +10,12 @@ import org.apache.lucene.search.BooleanClause;import org.apache.lucene.search.Query;import org.apache.lucene.search.TermRangeQuery;import org.apache.lucene.search.TermQuery;-import org.apache.lucene.util.Version;/** Token Manager. */public class QueryParserTokenManager implements QueryParserConstants{- /** Debug output. */- public java.io.PrintStream debugStream = System.out;- /** Set debug output. */- public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }+private final int jjStopStringLiteralDfa_2(int pos, long active0){switch (pos)diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.javaindex 0a7cff70da1..21975cd3d31 100644--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java@@ -19,6 +19,7 @@ package org.apache.lucene.queryparser.flexible.standard.parser;import java.io.StringReader;import java.util.Vector;+import java.util.Arrays;import org.apache.lucene.queryparser.flexible.messages.Message;import org.apache.lucene.queryparser.flexible.messages.MessageImpl;import org.apache.lucene.queryparser.flexible.core.QueryNodeParseException;@@ -42,10 +43,7 @@ import org.apache.lucene.queryparser.flexible.standard.nodes.TermRangeQueryNode;public class StandardSyntaxParserTokenManager implements StandardSyntaxParserConstants{- /** Debug output. */- public java.io.PrintStream debugStream = System.out;- /** Set debug output. */- public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }+private final int jjStopStringLiteralDfa_2(int pos, long active0){switch (pos)diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.javaindex c2103022d85..be4d8e04c20 100644--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java@@ -185,7 +185,7 @@ public class QueryParser implements QueryParserConstants {fieldName = jj_consume_token(TERM);jj_consume_token(COLON);if (fieldNames == null) {- fieldNames = new ArrayList<>();+ fieldNames = new ArrayList<String>();}fieldNames.add(fieldName.image);}@@ -211,7 +211,7 @@ public class QueryParser implements QueryParserConstants {oprt = jj_consume_token(OR);/* keep only last used operator */if (queries == null) {- queries = new ArrayList<>();+ queries = new ArrayList<SrndQuery>();queries.add(q);}q = AndQuery();@@ -239,7 +239,7 @@ public class QueryParser implements QueryParserConstants {oprt = jj_consume_token(AND);/* keep only last used operator */if (queries == null) {- queries = new ArrayList<>();+ queries = new ArrayList<SrndQuery>();queries.add(q);}q = NotQuery();@@ -267,7 +267,7 @@ public class QueryParser implements QueryParserConstants {oprt = jj_consume_token(NOT);/* keep only last used operator */if (queries == null) {- queries = new ArrayList<>();+ queries = new ArrayList<SrndQuery>();queries.add(q);}q = NQuery();@@ -293,7 +293,7 @@ public class QueryParser implements QueryParserConstants {break label_5;}dt = jj_consume_token(N);- queries = new ArrayList<>();+ queries = new ArrayList<SrndQuery>();queries.add(q); /* left associative */q = WQuery();@@ -320,7 +320,7 @@ public class QueryParser implements QueryParserConstants {break label_6;}wt = jj_consume_token(W);- queries = new ArrayList<>();+ queries = new ArrayList<SrndQuery>();queries.add(q); /* left associative */q = PrimaryQuery();@@ -401,7 +401,7 @@ public class QueryParser implements QueryParserConstants {final public List<SrndQuery> FieldsQueryList() throws ParseException {SrndQuery q;- ArrayList<SrndQuery> queries = new ArrayList<>();+ ArrayList<SrndQuery> queries = new ArrayList<SrndQuery>();jj_consume_token(LPAREN);q = FieldsQuery();queries.add(q);@@ -644,7 +644,7 @@ public class QueryParser implements QueryParserConstants {return (jj_ntk = jj_nt.kind);}- private java.util.List<int[]> jj_expentries = new java.util.ArrayList<>();+ private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();private int[] jj_expentry;private int jj_kind = -1;private int[] jj_lasttokens = new int[100];diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.javaindex dfbe431d03a..01072f0ce28 100644--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParserTokenManager.java@@ -18,10 +18,7 @@ import org.apache.lucene.queryparser.surround.query.SrndTruncQuery;public class QueryParserTokenManager implements QueryParserConstants{- /** Debug output. */- public java.io.PrintStream debugStream = System.out;- /** Set debug output. */- public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }+private final int jjStopStringLiteralDfa_1(int pos, long active0){switch (pos)diff --git a/lucene/test-framework/build.xml b/lucene/test-framework/build.xmlindex df130d75844..8cc4a07d23b 100644--- a/lucene/test-framework/build.xml+++ b/lucene/test-framework/build.xml@@ -22,11 +22,6 @@<property name="build.dir" location="../build/test-framework"/>- <!-- file is part of the API -->- <property name="forbidden-base-excludes" value="- org/apache/lucene/mockfile/FilterPath.class- "/>-<import file="../common-build.xml"/><path id="classpath">diff --git a/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterPath.java b/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterPath.javaindex 8b824095e4e..918890f50eb 100644--- a/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterPath.java+++ b/lucene/test-framework/src/java/org/apache/lucene/mockfile/FilterPath.java@@ -30,6 +30,8 @@ import java.nio.file.WatchKey;import java.nio.file.WatchService;import java.util.Iterator;+import org.apache.lucene.util.SuppressForbidden;+/*** A {@code FilterPath} contains another* {@code Path}, which it uses as its basic@@ -193,6 +195,7 @@ public class FilterPath implements Path {}@Override+ @SuppressForbidden(reason = "Abstract API requires to use java.io.File")public File toFile() {// TODO: should we throw exception here?return delegate.toFile();diff --git a/solr/common-build.xml b/solr/common-build.xmlindex 84b8b755447..df0b70205cb 100644--- a/solr/common-build.xml+++ b/solr/common-build.xml@@ -491,7 +491,7 @@<!-- Forbidden API Task, customizations for Solr --><target name="-check-forbidden-all" depends="-init-forbidden-apis,compile-core,compile-test"><property file="${common.dir}/ivy-versions.properties"/> <!-- for commons-io version -->- <forbidden-apis internalRuntimeForbidden="true" classpathref="forbidden-apis.allclasses.classpath">+ <forbidden-apis internalRuntimeForbidden="true" suppressAnnotation="**.SuppressForbidden" classpathref="forbidden-apis.allclasses.classpath"><bundledSignatures name="jdk-unsafe-${javac.target}"/><bundledSignatures name="jdk-deprecated-${javac.target}"/><bundledSignatures name="commons-io-unsafe-${/commons-io/commons-io}"/>diff --git a/solr/core/build.xml b/solr/core/build.xmlindex f320f764300..dd9d07fa781 100644--- a/solr/core/build.xml+++ b/solr/core/build.xml@@ -25,7 +25,6 @@<property name="forbidden-tests-excludes" value="org/apache/solr/internal/**- org/apache/solr/search/DocSetPerf.class"/><import file="../common-build.xml"/>diff --git a/solr/core/src/test/org/apache/solr/search/DocSetPerf.java b/solr/core/src/test/org/apache/solr/search/DocSetPerf.javaindex 711c8fff213..8c6024aac89 100644--- a/solr/core/src/test/org/apache/solr/search/DocSetPerf.java+++ b/solr/core/src/test/org/apache/solr/search/DocSetPerf.java@@ -17,10 +17,10 @@package org.apache.solr.search;-import java.util.BitSet;import java.util.Random;import org.apache.lucene.util.FixedBitSet;+import org.apache.lucene.util.SuppressForbidden;/***/@@ -33,13 +33,18 @@ public class DocSetPerf {}}- static Random rand = new Random();-static FixedBitSet bs;static BitDocSet bds;static HashDocSet hds;static int[] ids; // not unique+ static Random rand = getRandom();++ @SuppressForbidden(reason = "No testcase, use of java.util.Random allowed")+ private static Random getRandom() {+ return new Random();+ }+static void generate(int maxSize, int bitsToSet) {bs = new FixedBitSet(maxSize);ids = new int[bitsToSet];@@ -57,8 +62,6 @@ public class DocSetPerf {hds = new HashDocSet(ids,0,count);}--public static void main(String[] args) {String bsSize=args[0];boolean randSize=false;@@ -79,8 +82,7 @@ public class DocSetPerf {FixedBitSet[] sets = new FixedBitSet[numSets];DocSet[] bset = new DocSet[numSets];DocSet[] hset = new DocSet[numSets];- BitSet scratch=new BitSet();-+for (int i=0; i<numSets; i++) {generate(randSize ? rand.nextInt(bitSetSize) : bitSetSize, numBitsSet);sets[i] = bs;@@ -166,7 +168,6 @@ public class DocSetPerf {long end = System.currentTimeMillis();System.out.println("TIME="+(end-start));- // System.out.println("ret="+ret + " scratchsize="+scratch.size());System.out.println("ret="+ret);}diff --git a/solr/solrj/build.xml b/solr/solrj/build.xmlindex e9edefc0198..097171b283e 100644--- a/solr/solrj/build.xml+++ b/solr/solrj/build.xml@@ -20,16 +20,6 @@<property name="test.lib.dir" location="test-lib"/>- <!-- Uses ThreadPoolExecutor constructors directly -->- <property name="forbidden-base-excludes" value="- org/apache/solr/common/util/ExecutorUtil$MDCAwareThreadPoolExecutor.class- "/>-- <!-- violates the servlet-api restrictions, but it is safe to do so in this test: -->- <property name="forbidden-tests-excludes" value="- org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest$DebugServlet.class- "/>-<import file="../common-build.xml"/><!-- Specialized compile classpath: to only depend on what solrj should depend on (e.g. not lucene) -->diff --git a/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java b/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.javaindex ac0e85cb4d1..55b183de121 100644--- a/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java+++ b/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java@@ -104,6 +104,7 @@ public class ExecutorUtil {threadFactory);}+ @SuppressForbidden(reason = "class customizes ThreadPoolExecutor so it can be used instead")public static class MDCAwareThreadPoolExecutor extends ThreadPoolExecutor {private static final int MAX_THREAD_NAME_LEN = 512;diff --git a/solr/solrj/src/java/org/apache/solr/common/util/SuppressForbidden.java b/solr/solrj/src/java/org/apache/solr/common/util/SuppressForbidden.javanew file mode 100644index 00000000000..d388c29a8ad--- /dev/null+++ b/solr/solrj/src/java/org/apache/solr/common/util/SuppressForbidden.java@@ -0,0 +1,34 @@+package org.apache.solr.common.util;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import java.lang.annotation.Retention;+import java.lang.annotation.RetentionPolicy;+import java.lang.annotation.Target;+import java.lang.annotation.ElementType;++/**+ * Annotation to suppress forbidden-apis errors inside a whole class, a method, or a field.+ * @lucene.internal+ */+@Retention(RetentionPolicy.CLASS)+@Target({ ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE })+public @interface SuppressForbidden {+ /** A reason for suppressing should always be given. */+ String reason();+}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.javaindex 86775b4571e..d67641a0f8b 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java@@ -36,6 +36,7 @@ import org.apache.solr.common.SolrException.ErrorCode;import org.apache.solr.common.SolrInputDocument;import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.util.NamedList;+import org.apache.solr.common.util.SuppressForbidden;import org.apache.solr.util.SSLTestConfig;import org.eclipse.jetty.servlet.ServletHolder;import org.junit.BeforeClass;@@ -45,6 +46,7 @@ import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;+import java.io.IOException;import java.io.InputStream;import java.net.Socket;@@ -111,6 +113,7 @@ public class BasicHttpSolrClientTest extends SolrJettyTestBase {}}+ @SuppressForbidden(reason = "fake servlet only")private void setParameters(HttpServletRequest req) {parameters = req.getParameterMap();}