|
From: Benoit X. <bx...@ob...> - 2007-08-07 23:56:33
|
Dear All,
I'm faced with what I believe is a serious issue in Spring RC.
I enclose an example of a typical code that I now face following some
refactoring.
Basically my method getId() used to return int and now is returning Integer.
No sweat one would say but ALL forms fails on trying to convert Object to
String and String to Object!
java.lang.IllegalArgumentException: No converter registered to convert from
sourceClass 'class java.lang.String' to target class 'class
java.lang.Object'
at
org.springframework.binding.convert.support.GenericConversionService.getConv
ersionExecutor(GenericConversionService.java:145)
at
org.springframework.binding.form.support.AbstractFormModel.createConvertingV
alueModel(AbstractFormModel.java:350)
at
org.springframework.binding.form.support.AbstractFormModel.getValueModel(Abs
tractFormModel.java:294)
at
org.springframework.richclient.form.binding.support.AbstractBinding.getValue
Model(AbstractBinding.java:114)
at
org.springframework.richclient.form.binding.swing.TextComponentBinding.doBin
dControl(TextComponentBinding.java:39)
at
org.springframework.richclient.form.binding.support.AbstractBinding.createCo
ntrol(AbstractBinding.java:75)
at
org.springframework.richclient.factory.AbstractControlFactory.getControl(Abs
tractControlFactory.java:85)
at
org.springframework.richclient.form.binding.support.AbstractBindingFactory.i
nterceptBinding(AbstractBindingFactory.java:92)
at
org.springframework.richclient.form.binding.support.AbstractBindingFactory.c
reateBinding(AbstractBindingFactory.java:70)
at
org.springframework.richclient.form.binding.support.AbstractBindingFactory.c
reateBinding(AbstractBindingFactory.java:55)
at
org.springframework.richclient.form.builder.AbstractFormBuilder.createDefaul
tBinding(AbstractFormBuilder.java:78)
at
org.springframework.richclient.form.builder.TableFormBuilder.add(TableFormBu
ilder.java:109)
at
org.springframework.richclient.form.builder.TableFormBuilder.add(TableFormBu
ilder.java:85)
at
net.objectlab.springtest.TestForm.createFormControl(TestForm.java:22)
The issue relates to the use of generics.
The output for the example below is:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
name is of type:class java.lang.String
id is of type:class java.lang.Object
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I would have expected "id" to be of type java.lang.Integer.
Has anyone faced this issue? Did you manage to find a workaround???
Please please! I will also investigate the code in FielMetaData to try to
figure out what is happening.
Many thanks!!
Benoit
----------------
import org.springframework.binding.form.FormModel;
import org.springframework.richclient.form.FormModelHelper;
public class GenericTest {
public static void test() {
IntSuper1 intSuper1 = new IntSuper1(123);
FormModel model = FormModelHelper.createFormModel(intSuper1);
System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++");
System.out.println("name is of type:" +
model.getFieldMetadata("name").getPropertyType());
System.out.println("id is of type:" +
model.getFieldMetadata("id").getPropertyType());
System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++");
}
private static class Super1<T> {
T id;
public Super1(T id) {
this.id = id;
}
public T getId() {
return id;
}
public void setId(T id) {
this.id = id;
}
}
private static class IntSuper1 extends Super1<Integer> {
private String name;
public IntSuper1(Integer id) {
super(id);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: 06/08/2007
16:53
|
|
From: Benoit X. <bx...@ob...> - 2007-08-08 00:05:42
|
The issue seems to be related to the Spring BeanWrapper! (I=92m using =
Spring
2.0.6)
public static void main(String[] a) {
IntSuper1 intSuper1 =3D new IntSuper1(123);
BeanWrapper bw =3D new BeanWrapperImpl(intSuper1);
=20
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++
++++");
System.out.println("name is of type:" + =
bw.getPropertyType("name"));
System.out.println("id is of type:" + bw.getPropertyType("id"));
=20
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++
++++");
=20
}
=20
This returns the same value (incorrect imho)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
name is of type:class java.lang.String
id is of type:class java.lang.Object
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
=20
Same if I use a generic directly like Super1<Integer> it still returns
Object as the type of =93id=94.
=20
Any suggestion apart from jumping off Tower Bridge?
=20
Thanks
=20
Benoit
=20
From: spr...@li...
[mailto:spr...@li...] On Behalf =
Of
Benoit Xhenseval
Sent: 08 August 2007 00:56
To: spr...@li...
Subject: [Springframework-rcp-dev] Serious FieldMetaData issue with
generics? Test included.
Importance: High
=20
Dear All,
=20
I'm faced with what I believe is a serious issue in Spring RC.
=20
I enclose an example of a typical code that I now face following some
refactoring.
Basically my method getId() used to return int and now is returning =
Integer.
No sweat one would say but ALL forms fails on trying to convert Object =
to
String and String to Object!
=20
java.lang.IllegalArgumentException: No converter registered to convert =
from
sourceClass 'class java.lang.String' to target class 'class
java.lang.Object'
at
org.springframework.binding.convert.support.GenericConversionService.getC=
onv
ersionExecutor(GenericConversionService.java:145)
at
org.springframework.binding.form.support.AbstractFormModel.createConverti=
ngV
alueModel(AbstractFormModel.java:350)
at
org.springframework.binding.form.support.AbstractFormModel.getValueModel(=
Abs
tractFormModel.java:294)
at
org.springframework.richclient.form.binding.support.AbstractBinding.getVa=
lue
Model(AbstractBinding.java:114)
at
org.springframework.richclient.form.binding.swing.TextComponentBinding.do=
Bin
dControl(TextComponentBinding.java:39)
at
org.springframework.richclient.form.binding.support.AbstractBinding.creat=
eCo
ntrol(AbstractBinding.java:75)
at
org.springframework.richclient.factory.AbstractControlFactory.getControl(=
Abs
tractControlFactory.java:85)
at
org.springframework.richclient.form.binding.support.AbstractBindingFactor=
y.i
nterceptBinding(AbstractBindingFactory.java:92)
at
org.springframework.richclient.form.binding.support.AbstractBindingFactor=
y.c
reateBinding(AbstractBindingFactory.java:70)
at
org.springframework.richclient.form.binding.support.AbstractBindingFactor=
y.c
reateBinding(AbstractBindingFactory.java:55)
at
org.springframework.richclient.form.builder.AbstractFormBuilder.createDef=
aul
tBinding(AbstractFormBuilder.java:78)
at
org.springframework.richclient.form.builder.TableFormBuilder.add(TableFor=
mBu
ilder.java:109)
at
org.springframework.richclient.form.builder.TableFormBuilder.add(TableFor=
mBu
ilder.java:85)
at
net.objectlab.springtest.TestForm.createFormControl(TestForm.java:22)
=20
The issue relates to the use of generics.
=20
The output for the example below is:
=20
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
name is of type:class java.lang.String
id is of type:class java.lang.Object
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
=20
I would have expected "id" to be of type java.lang.Integer.
=20
Has anyone faced this issue? Did you manage to find a workaround???=20
Please please! I will also investigate the code in FielMetaData to try =
to
figure out what is happening.
=20
Many thanks!!
=20
Benoit
=20
----------------
=20
import org.springframework.binding.form.FormModel;
import org.springframework.richclient.form.FormModelHelper;
=20
public class GenericTest {
public static void test() {
IntSuper1 intSuper1 =3D new IntSuper1(123);
FormModel model =3D FormModelHelper.createFormModel(intSuper1);
=20
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++
++++");
System.out.println("name is of type:" +
model.getFieldMetadata("name").getPropertyType());
System.out.println("id is of type:" +
model.getFieldMetadata("id").getPropertyType());
=20
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++
++++");
}
=20
private static class Super1<T> {
T id;
=20
public Super1(T id) {
this.id =3D id;
}
=20
public T getId() {
return id;
}
=20
public void setId(T id) {
this.id =3D id;
}
}
=20
private static class IntSuper1 extends Super1<Integer> {
private String name;
=20
public IntSuper1(Integer id) {
super(id);
}
=20
public String getName() {
return name;
}
=20
public void setName(String name) {
this.name =3D name;
}
}
}
=20
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: =
06/08/2007
16:53
=20
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: =
06/08/2007
16:53
No virus found in this outgoing message.
Checked by AVG Free Edition.=20
Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: =
06/08/2007
16:53
=20
|
|
From: Jan H. <jh...@sc...> - 2007-08-08 13:48:14
|
I'm guessing this is related to the generic type erasure of java. It
would probably work when stating <T extends Integer> but this probably
isn't what you want. BeanWrapperImpl is only using the
PropertyDescriptor framework of java, so don't blame it on spring. If
you really want to verify this, just use java.beans to access the
IntSuper1 and look at the descriptor signatures.
Don't jump, just take a few more pints and you'll get over it ;-)
Kind Regards,
Jan
On Wed, 2007-08-08 at 01:05 +0100, Benoit Xhenseval wrote:
> The issue seems to be related to the Spring BeanWrapper! (I’m using
> Spring 2.0.6)
>
> public static void main(String[] a) {
>
> IntSuper1 intSuper1 = new IntSuper1(123);
>
> BeanWrapper bw = newBeanWrapperImpl(intSuper1);
>
>
> System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
>
> System.out.println("name is of type:" +
> bw.getPropertyType("name"));
>
> System.out.println("id is of type:" +
> bw.getPropertyType("id"));
>
>
> System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
>
>
>
> }
>
>
>
> This returns the same value (incorrect imho)
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> name is of type:class java.lang.String
>
> id is of type:class java.lang.Object
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
>
> Same if I use a generic directly like Super1<Integer> it still returns
> Object as the type of “id”.
>
>
>
> Any suggestion apart from jumping off Tower Bridge?
>
>
>
> Thanks
>
>
>
> Benoit
>
>
>
> From:spr...@li...
> [mailto:spr...@li...] On
> Behalf Of Benoit Xhenseval
> Sent: 08 August 2007 00:56
> To: spr...@li...
> Subject: [Springframework-rcp-dev] Serious FieldMetaData issue with
> generics? Test included.
> Importance: High
>
>
>
>
> Dear All,
>
>
>
> I'm faced with what I believe is a serious issue in Spring RC.
>
>
>
> I enclose an example of a typical code that I now face following some
> refactoring.
>
> Basically my method getId() used to return int and now is returning
> Integer.
>
> No sweat one would say but ALL forms fails on trying to convert Object
> to String and String to Object!
>
>
>
> java.lang.IllegalArgumentException: No converter registered to convert
> from sourceClass 'class java.lang.String' to target class 'class
> java.lang.Object'
>
> at
> org.springframework.binding.convert.support.GenericConversionService.getConversionExecutor(GenericConversionService.java:145)
>
> at
> org.springframework.binding.form.support.AbstractFormModel.createConvertingValueModel(AbstractFormModel.java:350)
>
> at
> org.springframework.binding.form.support.AbstractFormModel.getValueModel(AbstractFormModel.java:294)
>
> at
> org.springframework.richclient.form.binding.support.AbstractBinding.getValueModel(AbstractBinding.java:114)
>
> at
> org.springframework.richclient.form.binding.swing.TextComponentBinding.doBindControl(TextComponentBinding.java:39)
>
> at
> org.springframework.richclient.form.binding.support.AbstractBinding.createControl(AbstractBinding.java:75)
>
> at
> org.springframework.richclient.factory.AbstractControlFactory.getControl(AbstractControlFactory.java:85)
>
> at
> org.springframework.richclient.form.binding.support.AbstractBindingFactory.interceptBinding(AbstractBindingFactory.java:92)
>
> at
> org.springframework.richclient.form.binding.support.AbstractBindingFactory.createBinding(AbstractBindingFactory.java:70)
>
> at
> org.springframework.richclient.form.binding.support.AbstractBindingFactory.createBinding(AbstractBindingFactory.java:55)
>
> at
> org.springframework.richclient.form.builder.AbstractFormBuilder.createDefaultBinding(AbstractFormBuilder.java:78)
>
> at
> org.springframework.richclient.form.builder.TableFormBuilder.add(TableFormBuilder.java:109)
>
> at
> org.springframework.richclient.form.builder.TableFormBuilder.add(TableFormBuilder.java:85)
>
> at
> net.objectlab.springtest.TestForm.createFormControl(TestForm.java:22)
>
>
>
> The issue relates to the use of generics.
>
>
>
> The output for the example below is:
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> name is of type:class java.lang.String
>
> id is of type:class java.lang.Object
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
>
> I would have expected "id" to be of type java.lang.Integer.
>
>
>
> Has anyone faced this issue? Did you manage to find a workaround???
>
> Please please! I will also investigate the code in FielMetaData to
> try to figure out what is happening.
>
>
>
> Many thanks!!
>
>
>
> Benoit
>
>
>
> ----------------
>
>
>
> import org.springframework.binding.form.FormModel;
>
> import org.springframework.richclient.form.FormModelHelper;
>
>
>
> public class GenericTest {
>
> public static void test() {
>
> IntSuper1 intSuper1 = new IntSuper1(123);
>
> FormModel model = FormModelHelper.createFormModel(intSuper1);
>
>
> System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
>
> System.out.println("name is of type:" +
> model.getFieldMetadata("name").getPropertyType());
>
> System.out.println("id is of type:" +
> model.getFieldMetadata("id").getPropertyType());
>
>
> System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
>
> }
>
>
>
> private static class Super1<T> {
>
> T id;
>
>
>
> public Super1(T id) {
>
> this.id = id;
>
> }
>
>
>
> public T getId() {
>
> return id;
>
> }
>
>
>
> public void setId(T id) {
>
> this.id = id;
>
> }
>
> }
>
>
>
> private static class IntSuper1 extends Super1<Integer> {
>
> private String name;
>
>
>
> public IntSuper1(Integer id) {
>
> super(id);
>
> }
>
>
>
> public String getName() {
>
> return name;
>
> }
>
>
>
> public void setName(String name) {
>
> this.name = name;
>
> }
>
> }
>
> }
>
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date:
> 06/08/2007 16:53
>
>
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date:
> 06/08/2007 16:53
>
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date:
> 06/08/2007 16:53
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________ Springframework-rcp-dev mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev
**** DISCLAIMER ****
http://www.schaubroeck.be/maildisclaimer.htm
|