When I invoke java method 'func2(JavaScriptObject str)' using jsni, an
error occurs when the type of argument 'str' is javascript string
type, such as var ss = 'aabbcc', However, the method 'func2' does work
while its argument is JavaScriptObject type. In addition, this error
only happen in the dev mode. When I compile the whole module, and run
it in IE6, it works fine. So, I want to know what happen to it. Is it
a potential bug that exists in GWT? The following is the code:

         public class JsniErrorTest implements EntryPoint {
        protected static native void func1()/*-{
                debugger;
                var ss = 'aabbcc'; //error
                var obj = new Object();//ok. because it is javascript object 
type
                //can't run in dev mode
                
@com.sxf.errtest.client.JsniErrorTest::func2(Lcom/google/gwt/core/
client/JavaScriptObject;)(ss);
        }-*/;

        public static void func2(JavaScriptObject str){
                System.out.println(str);
        }

        /**
         * This is the entry point method.
         */
        public void onModuleLoad() {
                final Button sendButton = new Button("interface impl");

                ClickHandler handler = new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {

                                func1();

                        }
                };
                sendButton.addClickHandler(handler);
                RootPanel.get().add(sendButton);
        }
         }

the error:

11:18:31.000 [ERROR] [jsnierrortest] Uncaught exception escaped
java.lang.ClassCastException: null
    at java.lang.Class.cast(Class.java:2990)
    at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:166)
    at
com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:65)
    at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:
157)
    at
com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:
1713)
    at
com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:
165)
    at
com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:
120)
    at
com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
507)
    at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:
284)
    at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:
107)
    at com.sxf.errtest.client.JsniErrorTest.func1(JsniErrorTest.java)
    at com.sxf.errtest.client.JsniErrorTest
$1.onClick(JsniErrorTest.java:34)
    at
com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:
54)
    at
com.google.gwt.event.dom.client.ClickEvent.dispatch(ClickEvent.java:1)
    at com.google.gwt.event.shared.HandlerManager
$HandlerRegistry.fireEvent(HandlerManager.java:65)
    at com.google.gwt.event.shared.HandlerManager
$HandlerRegistry.access$1(HandlerManager.java:53)
    at
com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:
178)
    at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:52)
    at
com.google.gwt.event.dom.client.DomEvent.fireNativeEvent(DomEvent.java:
116)
    at com.google.gwt.user.client.ui.Widget.onBrowserEvent(Widget.java:
100)
    at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1307)
    at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1263)
    at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
    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.MethodDispatch.invoke(MethodDispatch.java:71)
    at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:
157)
    at
com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:
1713)
    at
com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:
165)
    at
com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:
120)
    at
com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
507)
    at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:
264)
    at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:
91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188)
    at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
    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.MethodDispatch.invoke(MethodDispatch.java:71)
    at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:
157)
    at
com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:
1668)
    at
com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:
401)
    at
com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:
222)
    at java.lang.Thread.run(Thread.java:619)

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to