Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » wrong null analysis with enum
wrong null analysis with enum [message #1102507] Thu, 05 September 2013 17:03 Go to next message
Nicola  Zanaga is currently offline Nicola Zanaga
Messages: 9
Registered: July 2009
Junior Member
With eclipse kepler release, build id: 20130614-0229
the non null analysis is wrong on enum when the enum is declared in another class.
In fact, in the example below, method test1 correctly don't give a warning, while test2 give a warning

public class TestCase2 {
    public enum testenum2  {
        X,
        Y
    }
}




import org.eclipse.jdt.annotation.NonNull;

public class TestCase {
    public enum testenum  {
        A,
        B
    }
    
    public void test1(@NonNull testenum te) {
    }

    public void test2(@NonNull TestCase2.testenum2 te) {
    }

    public void test3() {
        test1(testenum.A);
        test2(TestCase2.testenum2.X);
    }
}




Re: wrong null analysis with enum [message #1102581 is a reply to message #1102507] Thu, 05 September 2013 19:00 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan Herrmann
Messages: 924
Registered: July 2009
Senior Member
Yes, in Kepler the information that all enum constants are non-null is not generated for enums read from .class file, a patch is being prepared in https://bugs.eclipse.org/411771

You may try doing a full clean build, to see if the bogus warning goes away.

Stephan

Re: wrong null analysis with enum [message #1104041 is a reply to message #1102507] Sat, 07 September 2013 15:33 Go to previous messageGo to next message
Nicola  Zanaga is currently offline Nicola Zanaga
Messages: 9
Registered: July 2009
Junior Member
but if I want to use the patch that is in the bug, how should I do?
i need to download the nigthly build of eclipse ?
Re: wrong null analysis with enum [message #1104108 is a reply to message #1104041] Sat, 07 September 2013 18:03 Go to previous message
Stephan Herrmann is currently offline Stephan Herrmann
Messages: 924
Registered: July 2009
Senior Member
sorry, the patch isn't ready for testing yet.

What I meant is that invoking "Project > Clean" on you project might make the warning disappear (until that class is changed next).
Previous Topic:more problem with non null and final fields
Next Topic:Calling PlatformUI.getWorkbench().close() throws Exception (NullPointer?)
Goto Forum:
  


Current Time: Thu Apr 17 17:38:33 EDT 2014

Powered by FUDForum. Page generated in 0.04026 seconds