1

My GWT app is throwing this exception:

Caused by: java.lang.ClassCastException: com.google.gwt.core.client.JavaScriptObject$ cannot be cast to java.lang.String

When getting the String response of this function via JSNI:

public final native String data()/*-{
    return $wnd.getdata();
}-*/;

}

Here's the Javascript code:

  function getdata(){
    var data = MyObject.data();
    console.log(data);
    return data;
  }

I'm logging the data output from Firebug and here's the output (to check if the js function is actually returning something):

-0.00030517578125,0.00006103515625,0.00115966796875,0.00146484375,-0.00091552734375,-0.000946044921875,-0.001983642578125,-0.003997802734375,-0.005126953125,-0.00360107421875,-0.0032958984375,-0.004119873046875,-0.00433349609375,-0.0023193359375,-0.0008544921875,-0.003448486328125,-0.00347900390625,-0.0054931640625,-0.0067138671875,-0.005279541015625,-0.006072998046875,

1 Answer 1

1

A simple solution is probably $wnd.getdata().toString(); but maybe you should try typeof $wnd.getdata() to see what the type really is -- maybe it's a bug lurking somewhere else.

Sign up to request clarification or add additional context in comments.

4 Comments

its weird typeof shows that the type is "object", from the MyObject function data: function(){ return this.flashInterface().data().split(";"); }, but from the Actionscript function it is defined like this : protected function data():String { ... }
Does Actionscript return real JavaScript strings or just objects which have the same API and therefore behave like JavaScript strings?
So I presumed that the return value is ultimately a String, beside the fact that console.log shows that is a string of comma-separated floating point
It seems toString is the way to get the output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.