Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » more problem with non null and final fields
more problem with non null and final fields [message #1103801] Sat, 07 September 2013 06:15 Go to next message
Eclipse UserFriend
In the example below, i found two problem:
1) CONST is static final, so can't be null, but the 'o = new B(CONST)' give warning
2) 'o' is final, and it is initialized in constructor, so can't be null

public class TestCase {
    static class B {
        B(@NonNull String s)  { }
    }
        
    public static final String CONST = "";

    public final B o;    
    
    TestCase()  {
        o = new B(CONST);
        test1(o);
    }
    
    void test1(@NonNull B b)  {        
    }
    
}
Re: more problem with non null and final fields [message #1103806 is a reply to message #1103801] Sat, 07 September 2013 06:21 Go to previous message
Eclipse UserFriend
Specific analysis for final fields has been proposed via https://bugs.eclipse.org/237236
Just recently I resumed that discussion in the light that
- null annotations for fields have been introduced meanwhile
- we don't perform *flow analysis* for fields (and don't plan to do it for the general case)

Stephan
Previous Topic:null for integral types ?
Next Topic:wrong null analysis with enum
Goto Forum:
  


Current Time: Wed Jul 02 03:41:12 EDT 2025

Powered by FUDForum. Page generated in 0.05893 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top