Bug 197390 - [DataBinding] IdentityConverter incorrectly (un)used by UpdateValueStrategy
Summary: [DataBinding] IdentityConverter incorrectly (un)used by UpdateValueStrategy
Status: REOPENED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-21 05:33 EDT by Michael Baranov CLA
Modified: 2019-09-06 16:06 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Baranov CLA 2007-07-21 05:33:58 EDT
Build ID: I20070625-1500

Steps To Reproduce:
Despite the fact that IdentityConverter *IS* able to convert from primitive type values to the respective boxed type, UpdateValueStrategy only creates IdentityConverter in situations as primitive-to-primitive or boxed-to-boxed and not in situations as primitive-to-box or box-to-primitive.

Consequences: binding bramework incorrectly requires com.ibm.icu_xxx.jar (3.9 mb) at runtime (referenced class is: com.ibm.icu.text.NumberFormat from class: org.eclipse.core.databinding.UpdateStrategy)


More information:
this should work out of the box:

new UpdateValueStrategy() {
   @Override
   protected IConverter createConverter(Object fromType, Object toType) {
      return new IdentityConverter(Boolean.class, boolean.class);
   }
}
Comment 1 Brad Reynolds CLA 2007-07-21 10:43:35 EDT
(In reply to comment #0)
> Consequences: binding bramework incorrectly requires com.ibm.icu_xxx.jar (3.9
> mb) at runtime (referenced class is: com.ibm.icu.text.NumberFormat from class:
> org.eclipse.core.databinding.UpdateStrategy)

This is by design.  If you don't want the full ICU4J you can use the replacement plugin[1].

[1] http://wiki.eclipse.org/ICU4J#Replacement_Plug-in
Comment 2 Boris Bokowski CLA 2007-07-23 06:16:16 EDT
Michael, I hope the replacement plug-in solves your issues. Otherwise, please reopen.
Comment 3 Michael Baranov CLA 2007-07-23 06:34:07 EDT
Thank for the tip. 2 Concerns, however:
1) The replacement plugin seems to be a work in progress and not available yet.
2) I still don't see why the described case of box-to-primitive and primitive-to-box should require *any* other library. I still think that org.eclipse.core.databinding.UpdateStrategy is should correctly use (instantiate) IdentityConverter in such cases *before* referencing com.ibm.icu.text.NumberFormat  in the code. 

If you are sure this is as intended, leave it as wontfix. It's easily fixable from  library user code. 
Comment 4 Boris Bokowski CLA 2007-07-23 06:50:33 EDT
(In reply to comment #3)
> 1) The replacement plugin seems to be a work in progress and not available yet.

It is available from the download page for any Eclipse build, starting with Eclipse 3.2, in a separate section called "com.ibm.icu.base binary and source Plug-ins".

> 2) I still don't see why the described case of box-to-primitive and
> primitive-to-box should require *any* other library.

From looking at the code, it seems that the intention was that IdentityConverter be used for the primitive-to-boxed case. I suspect that this is a bug and I'm reopening this bug accordingly.

We could use IdentityConverter for the boxed-to-primitive case as well, but I'm not sure how we currently handle the "null" value - do we throw some kind of exception (like IdentityConverter does), or silently convert to zero?
Comment 5 Michael Baranov CLA 2007-07-23 07:31:28 EDT
> From looking at the code, it seems that the intention was that
> IdentityConverter be used for the primitive-to-boxed case. I suspect that this
> is a bug and I'm reopening this bug accordingly.

primitive-to-boxed is probably the most used type of conversion that occurs with  control-to-bean type binding. IMO this case should not require any side libs.

> 
> We could use IdentityConverter for the boxed-to-primitive case as well, but I'm
> not sure how we currently handle the "null" value - do we throw some kind of
> exception (like IdentityConverter does), or silently convert to zero?
> 
I'm not sure either. IMO the same BindingException thrown from IdentityConverter should be propagated up to the user code. IMO no silent conversion should happen in null-to-primitive case. It's 100% the user's responsibility to make sure it never happens or handle it.

Comment 6 Eclipse Webmaster CLA 2019-09-06 16:06:03 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.