Menu

#673 Annotations incorrectly applied/ignored for synthetic access

closed-rejected
Core (142)
3
2017-10-22
2008-11-18
Jon Kean
No

DefaultAnnotation appears to be applied for any access to a class, including methods/fields generated by the compiler (synthetic access).

See NPNonNullReturnViolationBug:

The DefaultAnnotation(NonNull.class) is (incorrectly?) applied to the compiler generated private method used by the anonymous class for reading junkField.

Similarly, any compiler generated access will ignore all annotations that may exist.

See NonNullFalseNegative:
The CheckForNull annotation on the private field, but is ignored when called from the anonymous inner class.

I imagine the first problem could be fixed by not applying DefaultAnnotation (or any other 'default' style annotation), to synthetic methods or fields.

Discussion

  • Jon Kean

    Jon Kean - 2008-11-18
     
  • Jon Kean

    Jon Kean - 2008-11-18

    File Added: NonNullFalseNegative.java

     
  • Jon Kean

    Jon Kean - 2008-11-18

    should generate a violation, but currently does not.

     
  • William Pugh

    William Pugh - 2008-12-12

    Fixed the false positive.
    The false negative will require a little more thought/work.

     
  • William Pugh

    William Pugh - 2008-12-12
    • priority: 5 --> 4
    • assigned_to: nobody --> wpugh
    • status: open --> open-accepted
     
  • William Pugh

    William Pugh - 2009-02-11
    • priority: 4 --> 3
     
  • Andrey Loskutov

    Andrey Loskutov - 2017-10-22
    • Status: open-accepted --> closed-rejected
     

Log in to post a comment.