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: 49
Registered: July 2009
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);
    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: 1596
Registered: July 2009
Senior Member
Specific analysis for final fields has been proposed via
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)

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

Current Time: Thu Apr 19 15:42:54 GMT 2018

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

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