Thursday, December 15, 2016

Re: Strange ClassCastException with GWT 2.8 and SDM

Hi Kirill,

Yes, I know, but I think it a bit strange that this only happens on direct accessing the model and not when I assign the value to a variable and use String.valueOf on this. 

GXT uses internally their FastMap, a HashMap that is based on JSNI if running on the client. This seems to be the problem.

BTW, I switched to GWT 2.7.0 and the problem disappears. So there's something in GWT 2.8.0 that triggers the problem. 


Thanks anyway

Norbert


Am Mittwoch, 14. Dezember 2016 17:53:03 UTC+1 schrieb Kirill Prazdnikov:
Hi

It seems here you are trying to cast a native js object to java type. 

Sometimes GWT generates ClassCastException when I cast type "@JsType(isNative=true) A" to type B which is also native type. This is also kind of magic for me and I also have a strange workaround: write a native method that does the cast by "return arg".  

I wrote about that earlier:


-Kirill


среда, 14 декабря 2016 г., 19:29:39 UTC+3 пользователь Norbert Bartels написал:

Hi all,

I'm migrating our GWT app to GWT 2.8 as a PoC because we like to use the SDM.

While testing the SDM I see some strange ClassCastExceptions in the console.

We use gxt 2 and changed some things to make it work with GWT > 2.5.1.

Here's the error message (stacktrace) of the the class cast exception:

java.lang.ClassCastException      at Unknown.java_lang_Throwable_Throwable__V(Unknown Source)      at Unknown.java_lang_Exception_Exception__V(Unknown Source)      at Unknown.java_lang_RuntimeException_RuntimeException__V(Unknown Source)      at Unknown.java_lang_ClassCastException_ClassCastException__V(Unknown Source)      at Unknown.javaemul_internal_InternalPreconditions_checkCriticalType__ZV(Unknown Source)      at Unknown.javaemul_internal_InternalPreconditions_checkType__ZV(Unknown Source)      at Unknown.com_google_gwt_lang_Cast_castTo__Ljava_lang_Object_2Lcom_google_gwt_core_client_JavaScriptObject_2Ljava_lang_Object_2(Unknown Source)      at Unknown.com_extjs_gxt_ui_client_widget_treegrid_TreeGridCellRenderer_getText__Lcom_extjs_gxt_ui_client_widget_treegrid_TreeGrid_2Lcom_extjs_gxt_ui_client_data_ModelData_2Ljava_lang_String_2IILjava_lang_String_2(Unknown Source)      at Unknown.com_extjs_gxt_ui_client_widget_treegrid_TreeGridCellRenderer_render__Lcom_extjs_gxt_ui_client_data_ModelData_2Ljava_lang_String_2Lcom_extjs_gxt_ui_client_widget_grid_ColumnData_2IILcom_extjs_gxt_ui_client_store_ListStore_2Lcom_extjs_gxt_ui_client_widget_grid_Grid_2Ljava_lang_Object_2(Unknown Source)    ...  

The code that triggers this exception is this (http://grepcode.com/file/repo1.maven.org/maven2/com.extjs/gxt/2.3.1-gwt22/com/extjs/gxt/ui/client/widget/treegrid/TreeGridCellRenderer.java/#59):

return String.valueOf(model.get(property));  

My temporary solution to fix this is:

Object obj = model.get(property);  String.valueOf(obj);  

I already found several places where the class cast exception occurs and where this fix solves the problem, but I'm afraid that there's something going wrong somewhere in GWT.

Cheers,
Norbert

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment