Skip to main content


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 21:03 Go to next message
Nicola Zanaga is currently offline Nicola ZanagaFriend
Messages: 56
Registered: July 2009
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 23:00 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
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 19:33 Go to previous messageGo to next message
Nicola Zanaga is currently offline Nicola ZanagaFriend
Messages: 56
Registered: July 2009
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 22:03 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
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: Tue Apr 23 10:58:34 GMT 2024

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

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

Back to the top