Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Should the same declaration type bindings have the same Java object?
Should the same declaration type bindings have the same Java object? [message #1796510] Mon, 15 October 2018 14:23 Go to next message
Sergey Toshin is currently offline Sergey ToshinFriend
Messages: 56
Registered: May 2015
Member
Hi, I've noticed that correct declaration type bindings are always the same, I mean they could be compared using == operation, but not only ITypeBinding.isEqualTo(ITypeBinding). On the other hand, I detected MissingTypeBindings that have different Java objects, but isEqualTo(...) returns true. Is that a bug? I prefer to get the declaration type binding and use == operator because of performance, but MissingTypeBindings ruin everything
Re: Should the same declaration type bindings have the same Java object? [message #1796588 is a reply to message #1796510] Tue, 16 October 2018 11:20 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
We cannot give any guarantees about MissingTypeBinding, since failure in name resolution means, we don't know which exact type was meant.

There's, however, another reason where '==' might be more specific than clients may want: when type annotations are used. Consider "String" and "@NonNull String": test using '==' and also 'equals()' both answer false, but 'isEqualTo()' should answer true. See also the javadoc of equals and isEqualTo in IBinding.

HTH
Re: Should the same declaration type bindings have the same Java object? [message #1796611 is a reply to message #1796588] Tue, 16 October 2018 13:38 Go to previous messageGo to next message
Sergey Toshin is currently offline Sergey ToshinFriend
Messages: 56
Registered: May 2015
Member
Stephan Herrmann, I get type declaration, in this case annotation should be ignored, isn't it?
Re: Should the same declaration type bindings have the same Java object? [message #1796612 is a reply to message #1796611] Tue, 16 October 2018 13:48 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
I get type declaration, in this case annotation should be ignored, isn't it? 


If you are referring to ITypeBinding.getTypeDeclaration(), then: yes, those have annotations stripped off, and are thus "more equal" then their annotated counter parts :)
Re: Should the same declaration type bindings have the same Java object? [message #1796621 is a reply to message #1796612] Tue, 16 October 2018 14:20 Go to previous messageGo to next message
Sergey Toshin is currently offline Sergey ToshinFriend
Messages: 56
Registered: May 2015
Member
Yea, to ITypeBinding.getTypeDeclaration(). Is there a possibility to make MissingTypeBinding return the same declaration objects all the times?
Re: Should the same declaration type bindings have the same Java object? [message #1797437 is a reply to message #1796621] Tue, 30 October 2018 20:57 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Sergey Toshin wrote on Tue, 16 October 2018 16:20
Is there a possibility to make MissingTypeBinding return the same declaration objects all the times?


No, those are distinct by design.

On a side note I wonder what tool would be keen on identifying different MissingTypeBindings. Tools usually work best on error free code, no?
Previous Topic: Installing JDT onto CDT Eclipse(Error when setting up JDT onto CDT
Next Topic:Eclipse 2018-09 and JavaFX 11 adventure
Goto Forum:
  


Current Time: Fri Apr 26 21:12:46 GMT 2024

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

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

Back to the top