uschindler commented on PR #2634: URL: https://github.com/apache/solr/pull/2634#issuecomment-2291460770
> I'll share my thought process on how I used forbidden APIs. Initially, I added entries to the config files while we were still using Java 11. Once we move to Java 21, there will be no need to include those in the forbiddenapis config file, as it will automatically detects them. So why did I add them now? To ensure that if someone uses these "deprecated" APIs, they receive a warning, and the plugin forces them to either handle it differently or apply annotations. > > Additionally, the Java compiler only fails the build if an API is marked for "removal," which is why I used two different annotations: one to suppress Java warnings and another for forbidden APIs. Some might question the need for both. I think it conveys the "risk factor." If an API is only deprecated, the forbidden annotation will do the job, but if it's marked for removal, another annotation is necessary. Forbiddenapis automatically fails in Java 17 on *all* deprecated methods inside the JDK. You can make this a fatal error in javac, too, but this would prevent you from consuming your own deprecated APIs outside of the JDK. Therefore, forbiddenapis has "jdk-deprecated" bundled signatures, which fails the build. If you want to check today for deprecated methods in java 17, you could temporarily change the forbiddenapis configuration to use "jdk-deprecated-17" instead of "jdk-deprecated" (which gets version of javac automatically): https://github.com/apache/solr/blob/e5051e8bed85646f268cb93af9305c0842e02c71/gradle/validation/forbidden-apis.gradle#L63 -- 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...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org