Skip to main content



      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 10:23 Go to next message
Eclipse UserFriend
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 07:20 Go to previous messageGo to next message
Eclipse UserFriend
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 09:38 Go to previous messageGo to next message
Eclipse UserFriend
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 09:48 Go to previous messageGo to next message
Eclipse UserFriend
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 10:20 Go to previous messageGo to next message
Eclipse UserFriend
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 16:57 Go to previous message
Eclipse UserFriend
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: Mon Apr 28 23:00:23 EDT 2025

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

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

Back to the top