mocobeta edited a comment on pull request #567: URL: https://github.com/apache/lucene/pull/567#issuecomment-1001112886
Browsing through this issue, I am wondering if it'd be helpful that we have an entry to forbid ~Class#getClassLoader()~ ClassLoadr#getResourceAsStream() (and so on) by default. When it is really needed (for example, on tests), we can suppress the linter by `@SuppressForbidden`. Correction: not all methods in ClassLoader are caller sensitive (returns null when the package is not opened). getClassLoader() call itself may not be a problem. ``` lucene $ git diff diff --git a/gradle/validation/forbidden-apis/defaults.all.txt b/gradle/validation/forbidden-apis/defaults.all.txt index 6c6e0296cc5..62b1e8fa6e8 100644 --- a/gradle/validation/forbidden-apis/defaults.all.txt +++ b/gradle/validation/forbidden-apis/defaults.all.txt @@ -66,3 +66,6 @@ java.io.ObjectOutputStream @defaultMessage Don't set a dictionary on a Deflater using a method that takes an offset or ByteBuffer (JDK-8252739) java.util.zip.Deflater#setDictionary(byte[],int,int) java.util.zip.Deflater#setDictionary(java.nio.ByteBuffer) + +@defaultMessage caller sensitive method callq +java.lang.ClassLoader#getResourceAsStream(java.lang.String) ``` ``` # on main branch lucene $ ./gradlew -p lucene/analysis/kuromoji/ forbiddenApi > Task :lucene:analysis:kuromoji:forbiddenApisMain FAILED Forbidden method invocation: java.lang.ClassLoader#getResourceAsStream(java.lang.String) [caller sensitive method callq] in org.apache.lucene.analysis.ja.dict.BinaryDictionary (BinaryDictionary.java:207) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org