LUCENE-6420: Use forbidden-apis annotation @SuppressForbidden; cleanup maven build

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1674926 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2015-04-20 15:22:06 +00:00
parent c617356a29
commit 5b4fe002ba
63 changed files with 193 additions and 733 deletions

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -167,6 +167,9 @@
-->
<failOnUnsupportedJava>false</failOnUnsupportedJava>
<targetVersion>${java.compat.version}</targetVersion>
<suppressAnnotations>
<suppressAnnotation>**.SuppressForbidden</suppressAnnotation>
</suppressAnnotations>
</configuration>
</plugin>
<plugin>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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"/>

View File

@ -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;

View File

@ -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]);

View File

@ -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>

View File

@ -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"/>

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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) {

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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")

View File

@ -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">

View File

@ -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;

View File

@ -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">

View File

@ -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++) {

View File

@ -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 {
/**

View File

@ -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 {

View File

@ -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 displayed
public 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"

View File

@ -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.");
}
}

View File

@ -28,6 +28,7 @@ import java.nio.file.Path;
import org.apache.lucene.store.Directory; // javadoc
import 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;

View File

@ -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} mallocs

View File

@ -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">

View File

@ -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 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];

View File

@ -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)

View File

@ -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)

View File

@ -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];

View File

@ -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)

View File

@ -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">

View File

@ -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();

View File

@ -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}"/>

View File

@ -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"/>

View File

@ -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);
}

View File

@ -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) -->

View File

@ -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;

View File

@ -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();
}

View File

@ -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();
}