#1117 $L1 must be nonnull but is marked as nullable

closed-duplicate
5
2012-12-04
2012-09-14
Stephen
No

I'm using the @DefaultAnnotationForParameters(value = CheckForNull.class) for my package. I've found that if an interface has its parameters annotated this way, but the implementation has one of the parameters tagged @javax.annotation.Nonnull then I get the non-obvious error: "$L1 must be nonnull but is marked as nullable"
The error is marked on line 1 of the file.

I think that a better error message would be appropriate here. It took me some time to figure out what this error was about. :)

For those who get here via google - you can solve it by marking the interface parameter @Nonnull or removing the @Nonnull from the implementation method.

Discussion

  • William Pugh

    William Pugh - 2012-09-27

    I need more of a test case. I wasn't able to reproduce this.

    public class Bug3567801 {

    interface Test {
    int foo(@CheckForNull Object x);
    }

    static class Impl implements Test {

    @NoWarning("NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE")
    public int foo(@Nonnull Object x) {
    return x.hashCode();
    }

    public int bar() {
    return foo("abc");
    }
    }

    }

     
  • William Pugh

    William Pugh - 2012-09-27
    • status: open --> open-works-for-me
     
  • William Pugh

    William Pugh - 2012-10-05
    • status: open-works-for-me --> pending-works-for-me
     
  • William Pugh

    William Pugh - 2012-12-04
    • labels: --> false positive
    • assigned_to: nobody --> wpugh
    • status: pending-works-for-me --> closed-duplicate
     
  • William Pugh

    William Pugh - 2012-12-04

    I believe this is a duplicate of 3589328.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks