gwtproject / gwt

GWT Open Source Project
http://www.gwtproject.org
1.51k stars 372 forks source link

GWT crashes with the following error "ClassCastException" in the hosted mode (in class JsValueGlue) #2847

Closed dankurka closed 9 years ago

dankurka commented 9 years ago

Originally reported on Google Code with ID 2841

Found in GWT Release: 1.5.2

Detailed description:

java.lang.ClassCastException
    at java.lang.Class.cast(Class.java:2990)
    at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:122)
    at 
com.google.gwt.dev.shell.ie.SwtOleGlue.convertVariantsToObjects(SwtOleGlue.
java:57)
    at 
com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:119
)
    at 
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
    at 
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
    at 
com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
    at 
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
    at org.eclipse.swt.internal.ole.win32.COM.VtblCall(Native Method)
    at 
org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
    at 
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:493)
    at 
org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:417)
    at 
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvokeOnWindow(ModuleSpaceIE6.
java:67)
    at 
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvoke(ModuleSpaceIE6.java:152
)
    at 
com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:447)
    at 
com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:248)
    at 
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.jav
a:107)
    at com.gwtext.client.widgets.Component.render(Component.java)
    at 
com.gwtext.client.widgets.Component.getElement(Component.java:427)
    at 
com.gwtext.client.widgets.Component.getElement(Component.java:405)
    at 
com.google.gwt.user.client.ui.Composite.initWidget(Composite.java:83)
    at 
com.infovista.vbtx.ui.client.console.widgets.ConsoleTree.<init>(ConsoleTree
.java:85)
    at 
com.infovista.vbtx.ui.client.console.Console.displayConsole(Console.java:95
)
    at 
com.infovista.vbtx.ui.client.console.ConsolePage.activate(ConsolePage.java:
62)
    at 
com.infovista.vbtx.ui.client.Reports$10.onTabChange(Reports.java:392)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3
9)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp
l.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at 
com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at 
com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126
)
    at 
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
    at 
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
    at 
com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
    at 
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native 
Method)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
    at 
org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
    at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
    at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
    at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)

Workaround if you have one:

none

Links to the relevant GWT Developer Forum posts:

- It's the same problem like is described here: http://www.gwt-
ext.com/forum/viewtopic.php?f=8&t=2614 (more users found it earlier).

- http://code.google.com/p/gwt-google-apis/issues/detail?id=166&sort=-
id#makechanges

Reported by cristescu.sorinel on 2008-09-03 11:21:40

dankurka commented 9 years ago
Here is simple example that demonstrated the issue. The code works correctly under
1.5.1 and older versions. With 1.5.2, ClassCastException gets thrown.

package com.mycompany.project.client;
public class Parent{
    public static Parent instance(){
        System.out.println("Creating child");
        return new Parent();
    }
}

package com.mycompany.project.client;
public class Child extends Parent {
    public static Child instance(){
        System.out.println("Creating child");
        return new Child();
    }
}

package com.mycompany.project.client;
import com.google.gwt.core.client.EntryPoint;
public class Gwt152StaticCallBug implements EntryPoint {

    public static void handle(Child o){
        System.out.println("Handle method called "+ o);
    }

    public static native void fail()/*-{
        var child = @com.mycompany.project.client.Child::instance()();

@com.mycompany.project.client.Gwt152StaticCallBug::handle(Lcom/mycompany/project/client/Child;)(child);
    }-*/;

    public void onModuleLoad() {
        fail();
    }
}

Reported by michal.bergmann on 2008-09-03 12:58:14

dankurka commented 9 years ago

Reported by scottb+legacy@google.com on 2008-09-03 18:31:24

dankurka commented 9 years ago
Could one of you guys please review this fix targeted for the 1.5 branch?  Thanks!

Reported by scottb+legacy@google.com on 2008-09-03 22:11:12


dankurka commented 9 years ago
LGTM, provided you remove the dingleberries in CCL and IEDispatchProxy.

Reported by bobv%google.com@gtempaccount.com on 2008-09-03 22:31:22

dankurka commented 9 years ago
Likewise here.

Reported by jat+personal@google.com on 2008-09-03 22:40:13

dankurka commented 9 years ago
Thanks guys, committed to 1.5 branch at r3612.

Reported by scottb+legacy@google.com on 2008-09-03 22:41:24

dankurka commented 9 years ago

Reported by scottb+legacy@google.com on 2008-09-03 22:41:37

dankurka commented 9 years ago
I've verified the fix works. Thanks! Any idea when this will be incorporated in an
official release? 

Reported by sanjiv.jivan on 2008-09-03 23:12:42

dankurka commented 9 years ago
I don't know; if we do a 1.5 point release it would be in that.

Reported by scottb+legacy@google.com on 2008-09-04 00:08:09

dankurka commented 9 years ago
Could it be "When we do the next 1.5 point release", instead of "If we do..." ? It'd
make me feel a bit better about the whole thing :-)

Reported by brice.copy on 2008-09-04 07:23:37

dankurka commented 9 years ago
Tested the fix from this location "http://code.google.com/p/google-web-
toolkit/source/detail?r=3612" and it's working fine! Good job - Thanks !

Sorinel C

Reported by cristescu.sorinel on 2008-09-04 09:54:27

dankurka commented 9 years ago
This problem is giving us some trouble in the gwt-google-apis library as manifested
in this issue:  

  http://code.google.com/p/gwt-google-apis/issues/detail?id=171

Reported by galgwt.reviews on 2008-09-16 10:08:33

dankurka commented 9 years ago
Sorry for being such a bloody newbie, but I have the same problem and I would like to
use above fix and I do not know how to get it?

Do I have to download the source from
/releases/1.5/dev/core/src/com/google/gwt/dev/shell/DispatchClassInfo.java  compile
it
and patch the jar file?

Reported by zuendorf.se on 2008-09-16 21:00:53

dankurka commented 9 years ago
Sorry again, found the patch file. Will try to apply it. Thanks. 

Reported by zuendorf.se on 2008-09-16 21:17:35

dankurka commented 9 years ago
This seems not to be fixed yet in trunk. What is your plan for that?

Reported by forster+personal@google.com on 2008-09-29 13:23:28

dankurka commented 9 years ago
I'm getting a nearly identical ClassCastException but under different circumstances.
 See
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/f5816b66dec81b05

The two issues are different in that

1. The ClassCastException in Issue 2847 happens [I’m assuming] all within the same
RootPanel, whereas the exception I see only happens when data is passed from one
RootPanel to another
2. The exception in Issue 2847 deals with subclasses having the same static method
names as their parents, whereas mine doesn’t.

The two issues are similar in that

1. The exceptions are nearly identical
2. The problem only happens in hosted mode, i.e. everything behaves correctly in web
mode.

Is it possible the two issues have the same root cause, or are they really separate?

Reported by wyatt.bertel on 2008-10-08 19:58:16

dankurka commented 9 years ago

Reported by scottb+legacy@google.com on 2008-10-10 21:16:54

dankurka commented 9 years ago
Still seeing this issue after 1.5.3 was released and incorporated into my
application, I looked at the source and it looks like the fix was added to that
release.  Is anyone else having any issues?

Reported by gcstang on 2008-10-21 16:47:19

dankurka commented 9 years ago
Can you supply a new stack trace for 1.5.3?

Reported by scottb+legacy@google.com on 2008-10-22 03:12:03

dankurka commented 9 years ago
My stack trace:

java.lang.ClassCastException
    at java.lang.Class.cast(Class.java:2990)
    at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:122)
    at com.google.gwt.dev.shell.ie.SwtOleGlue.convertVariantsToObjects(SwtOleGlue.java:57)
    at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:119)
    at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
    at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
    at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
    at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
    at org.eclipse.swt.internal.ole.win32.COM.VtblCall(Native Method)
    at org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
    at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:493)
    at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:417)
    at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvokeOnWindow(ModuleSpaceIE6.java:67)
    at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvoke(ModuleSpaceIE6.java:152)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:447)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:248)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
    at com.gwtext.client.widgets.tree.TreePanel.expandAllRendered(TreePanel.java)
    at com.gwtext.client.widgets.tree.TreePanel.expandAll(TreePanel.java:167)
    at com.gwtext.client.widgets.tree.TreePanel$2$1.execute(TreePanel.java:161)
    at
com.google.gwt.user.client.CommandExecutor.doExecuteCommands(CommandExecutor.java:311)
    at com.google.gwt.user.client.CommandExecutor$2.run(CommandExecutor.java:206)
    at com.google.gwt.user.client.Timer.fireImpl(Timer.java:164)
    at com.google.gwt.user.client.Timer.fireAndCatch(Timer.java:150)
    at com.google.gwt.user.client.Timer.fire(Timer.java:142)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
    at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
    at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
    at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
    at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
    at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
    at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
    at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)

Reported by gcstang on 2008-10-22 16:06:59

dankurka commented 9 years ago
When I run the test case outlined in

http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/f5816b66dec81b05

against GWT 1.5.3 I get this stack trace:

java.lang.ClassCastException
        at java.lang.Class.cast(Class.java:2951)
        at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:122)
        at
com.google.gwt.dev.shell.ie.SwtOleGlue.convertVariantsToObjects(SwtOleGlue.java:57)
        at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:119)
        at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
        at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
        at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
        at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
        at org.eclipse.swt.internal.ole.win32.COM.VtblCall(Native Method)
        at org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:64)
        at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:493)
        at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:417)
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvokeOnWindow(ModuleSpaceIE6.java:67)
        at com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvoke(ModuleSpaceIE6.java:152)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:447)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:248)
        at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
        at test.frames.client.Sender.sendNative(Sender.java)
        at test.frames.client.Sender.send(Sender.java:25)
        at test.frames.client.Sender.access$0(Sender.java:22)
        at test.frames.client.Sender$1.onClick(Sender.java:16)
        at
com.google.gwt.user.client.ui.ClickListenerCollection.fireClick(ClickListenerCollection.java:34)
        at com.google.gwt.user.client.ui.FocusWidget.onBrowserEvent(FocusWidget.java:102)
        at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1308)
        at com.google.gwt.user.client.DOM.dispatchEventAndCatch(DOM.java:1287)
        at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1255)
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
        at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
        at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
        at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
        at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
        at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
        at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
        at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
        at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
        at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)

Scottb, should I open this up as a separate bug (since the test case is so different)?

Reported by wyatt.bertel on 2008-10-22 19:21:02

dankurka commented 9 years ago
Yeah, let's open a new one.  Please comment here on the new issue number.  Thanks!

Reported by scottb+legacy@google.com on 2008-10-22 20:57:06

dankurka commented 9 years ago
Are these the same issue as the original?

Reported by gcstang on 2008-10-22 21:03:35

dankurka commented 9 years ago
I opened Issue 3024 describing the other case that produces this exception (i.e.
passing an object via JSNI from one RootPanel to another).

Reported by wyatt.bertel on 2008-10-22 22:06:49

dankurka commented 9 years ago
Gcstang, I don't know the guts of GWT, so I can't speak to how similar these issues
are.  However the case that produces the exception in this issue is rather different
than the case that produces the exception (however similar) in Issue 3024.

One possible point of confusion is that the current title of Issue 2847 exactly
describes Issue 3024.  Can the title of Issue 2847 please be modified to be more
definitive?

Reported by wyatt.bertel on 2008-10-22 22:15:05

dankurka commented 9 years ago
wyatt: I marked issue 3024 AsDesigned because passing Java objects between two 
different GWT apps is not supported.

gcstang: Could you open a new issue with your own stack trace and sample code?

Reported by scottb+legacy@google.com on 2008-10-22 22:57:36

dankurka commented 9 years ago
FYI: I get a similar exception while using gwt-api for multiple file upload(using
gears's Desktop wrapper written by a contributor). The wrapper is really simple and
I
think it is not responsible for this issue. I tested the gears original js code and
it works great. Here is the link to original thread: 
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/f015f8b277a2f8c2/7e81e3b921cc8bbd

This issue makes working in hosted mode almost impossible. 

Pasted below is the stack trace: 
java.lang.ClassCastException
    at java.lang.Class.cast(Class.java:2951)
    at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:128)
    at com.google.gwt.dev.shell.ie.SwtOleGlue.convertVariantsToObjects(SwtOleGlue.java:57)
    at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:119)
    at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
    at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
    at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
    at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
    at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
    at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
    at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)

Reported by rakeshw on 2008-11-03 00:02:50

dankurka commented 9 years ago
FYI to earlier post: 
http://code.google.com/p/gwt-google-apis/issues/detail?id=201

Reported by rakeshw on 2008-11-03 00:04:31

dankurka commented 9 years ago
This is not necessarily a hosted mode issue.  Let's open a new issue if you can 
provide a simple repro case.

Reported by scottb+legacy@google.com on 2008-11-03 20:44:43