Open GoogleCodeExporter opened 9 years ago
I'm with GWT 2.4 and had the same issue with a class with generics. Something
like:
public class A<T> {
T value;
...
}
I get the same error, and if I look at the snapshot the generated A_Reflection
class error is in method:
public void setFieldValue(Object instance, String fieldName, Object value) {
org.sgx.editor.client.editor.event.EditorValueChangeEvent content = (org.sgx.editor.client.editor.event.EditorValueChangeEvent)instance;
if (fieldName.equals("src")) {
content.src=(org.sgx.editor.client.editor.Editor)value;
} else if (fieldName.equals("value")) {
content.value=(T extends java.lang.Object)value;
} else if (fieldName.equals("childEvent")) {
content.childEvent=(org.sgx.editor.client.editor.event.EditorValueChangeEvent)value;
} else super.setFieldValue(instance, fieldName, value);
}
(the line content.value=(T extends java.lang.Object)value; is incorrect. I
think the correct would be content.value=(java.lang.Object)value)
If I declare the "value" attribute using no generics like the following
everiting works ok:
public class A<T> {
Object value;
}
Original comment by sebastigurin
on 8 Feb 2012 at 3:45
Same error here with the following code :
public abstract class GwtController<M extends GwtModel,V extends
GwtViewEntryPoint> {
protected M model;
protected V view;
public void setModel(M model){
this.model = model;
}
public void setView(V view ){
this.view = view;
}
}
The error in the console reads :
Errors in
'generated://A1EED90A4A3755FBA1AF5A2A06300BBE/ro/sft/test/view/mvc/GwtController
___Reflection.java'
See snapshot: C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ro.sft.test.view.mvc.GwtController___Reflection1808921376227693314.java
Ignored 1 unit with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[ERROR] Errors in 'generated://A1EED90A4A3755FBA1AF5A2A06300BBE/ro/sft/test/view/mvc/GwtController___Reflection.java'
[ERROR] Line 71: M cannot be resolved
[ERROR] Line 71: Syntax error on token "extends", . expected
[ERROR] Line 73: V cannot be resolved
[ERROR] Line 73: Syntax error on token "extends", . expected
and the generated output would be:
public void setFieldValue(Object instance, String fieldName, Object value) {
ro.sft.test.view.mvc.GwtController content = (ro.sft.test.view.mvc.GwtController)instance;
if (fieldName.equals("model")) {
content.model=(M extends ro.sft.test.view.mvc.GwtModel)value;
} else if (fieldName.equals("view")) {
content.view=(V extends ro.sft.test.view.mvc.GwtViewEntryPoint)value;
} else super.setFieldValue(instance, fieldName, value);
}
Original comment by victor.b...@gmail.com
on 21 Mar 2012 at 5:37
OK, magic trick is to make the access modifier 'private'. No idea why- it seems
also to cause the GWT compiler to go through !! 11 !! permutations, but at
least you can get an object of type you hoped for.
All I did is make the fields private ( from protected or default) and provide
getters for the value :
@Reflectable(constructors = true)
public abstract class GwtController<M extends GwtModel,V extends
GwtViewEntryPoint> {
private M model;
private V view;
public void setModel(M model){
this.model = model;
}
public void setView(V view ){
this.view = view;
}
public M getModel(){
return model;
}
public V getView(){
return view;
}
}
Original comment by victor.b...@gmail.com
on 21 Mar 2012 at 5:54
Original issue reported on code.google.com by
hyamamot...@gmail.com
on 30 Oct 2010 at 1:59