Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » NullLiteral.resolveConstantExpressionValue() gives null
NullLiteral.resolveConstantExpressionValue() gives null [message #1712343] Fri, 23 October 2015 08:16 Go to next message
Ivan Ivan is currently offline Ivan IvanFriend
Messages: 57
Registered: May 2015
Member
Hi,
I have a code like
Object returnValue = null;
return returnValue;

When I call SimpleName.resolveConstantExpressionValue() (this is returnValue), I always get null, but it's the same result when resolving was failed. How to make sure that this null is related to NullLiteral, but not just a unsucceeded result?

Thanks
Re: NullLiteral.resolveConstantExpressionValue() gives null [message #1712403 is a reply to message #1712343] Fri, 23 October 2015 15:46 Go to previous messageGo to next message
Erick Hagstrom is currently offline Erick HagstromFriend
Messages: 107
Registered: April 2014
Location: USA
Senior Member
I don't think you can, short of doing some sort of flow analysis that brings you back to the NullLiteral.

<microrant>Null is evil.</microrant>
Re: NullLiteral.resolveConstantExpressionValue() gives null [message #1712419 is a reply to message #1712403] Fri, 23 October 2015 23:31 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
SimpleName.resolveConstantExpressionValue() will only ever return a non-null value, if the name is a compile time constant, i.e., it must be final and the exact value is known to the compiler.
The null type is represented by an ITypeBinding answering true to #isNullType().
Previous Topic:Google Maps API v3 Code Assist
Next Topic:Why is simpleName.resolveBinding().getType() != simpleName.resolveTypeBinding()?
Goto Forum:
  


Current Time: Wed Sep 25 02:11:50 GMT 2024

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

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

Back to the top