Coder Social home page Coder Social logo

Comments (3)

uschindler avatar uschindler commented on June 3, 2024

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.

uschindler avatar uschindler commented on June 3, 2024

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.

mttjj avatar mttjj commented on June 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.