Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 10:15 Go to next message
Nicola  Zanaga is currently offline Nicola Zanaga
Messages: 21
Registered: July 2009
Junior Member
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 10:21 Go to previous message
Stephan Herrmann is currently offline Stephan Herrmann
Messages: 1007
Registered: July 2009
Senior Member
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:Override workspace/project compiler settings for a specific file
Next Topic:wrong null analysis with enum
Goto Forum:
  


Current Time: Tue Sep 30 18:13:00 GMT 2014

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

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