Comments (3)
Hi,
This unfortunately cannot be fixed.
The retention policy set to at least class or runtime is correct. This ensures that the annotation can be seen after compilation in class files. But this is correct in you case and hasn't anything to do with the problem at all.
Field initialization here is the main problem. Actually in class files there is no way to see the right side of field declarations in field declarations. The suppressions are only be visible for the declaration of the field. The right side is of field (initializer) is hidden by the java compiler behind a invisible method:
- for static fields it is called
static void clinit()
. There is no way to add a suppression to this field. Workaround is to wrap the call into a method. - for instance fields you can add suppression to constructor of class.
In generat the workaround for field initialization is to add a static method that can get the suppression.
Sorry this is a limitation of class files format.
from forbidden-apis.
Actually there might be a way to identify those calls from byte code analysis by heuristics: any putfield opcode in constructor that has a line number different than the others might be a way to detect it. But this is very hard and depends on the internals of compiler and may break.
from forbidden-apis.
Unfortunate but totally understandable. Thankfully, the scenario I described is rare in our codebase and the annotation at the class level won't cause too many problems for us for these particular classes. Thanks for looking into this!
from forbidden-apis.
Related Issues (20)
- Add support for Java 19 HOT 3
- Do not log message about missing classes (while parsing class files; not signatures) multiple times HOT 2
- Add limited support for bundled signatures of a later JDK version than currently executing HOT 1
- [JDK-19] Method not found while parsing signature: java.text.NumberFormat#getCompactNumberInstance() HOT 1
- Annotate task with `@CacheableTask` so that the build cache can be used HOT 2
- Project Loom does not play well with synchronized, so WDYT of adding support for "forbid use of synchronized"? HOT 3
- Add HttpResponse.BodyHandlers.ofFile(Path) to banned method lists (buggy) HOT 2
- Startup issues on Java 20 HOT 14
- idea: check proper use of declaration-site type variance HOT 8
- (Gradle) How to avoid creation of a forbiddenApisTest task HOT 2
- Allow to ignore failures for some signature files only HOT 3
- Improve messsages in the bundled signatures so they are actionable HOT 1
- Forbidding constructors doesn't always work HOT 2
- build warning about parameter "localRepository" after upgrading to maven 3.9.1 HOT 28
- Remove HttpResponse.BodyHandlers.ofFile(Path) from banned method list in Java 21 signatures HOT 2
- Provide option to enabled DEBUG level logging when using the CLI HOT 12
- Clarify Maven configuration parameter "includes" and "excludes" HOT 2
- Consider JEP 400 for jdk-unsafe Bundled Signatures HOT 1
- Check fails with "Bundled signatures resource not found: jdk-unsafe-21" despite failOnUnsupportedJava/failOnViolation disabled HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forbidden-apis.