Skip to main content


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 ZanagaFriend
Messages: 56
Registered: July 2009
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 HerrmannFriend
Messages: 1853
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:null for integral types ?
Next Topic:wrong null analysis with enum
Goto Forum:
  


Current Time: Fri Apr 26 07:45:45 GMT 2024

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

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

Back to the top