Here is another variant, failing with the same exception

//In Java
package com.acme;

@JsType
public class IntParser {
  public static int parseArray(String[] args) {
    return Integer.parseInt(args[0]);
  }
}

//In Javascript
var num = com.acme.IntParser.parseArray(["42"]); // Should return 42, but 
throws 'Uncaught [object Object]'!



Den mandag den 2. november 2015 kl. 11.11.35 UTC+1 skrev Brian Pedersen:
>
> Thank you Gortug for making my aware of the isNative attribute. 
> Unfortunately the cast issue remains.
>
> I have taken the example from the new jsinterop doc, and modified it to 
> illustrate this: 
> https://github.com/bitwerk/jspoc/tree/master/src/main/java/com/acme
>
> // in Java
> package com.acme;
>
> @JsType(isNative = true)
> interface Foo {
> }
>
> @JsType(isNative = true)
> class Baz implements Foo{
>   public int qux;
> }
>
> class Bar {
>   @JsMethod
>   public static int action(Foo foo) {
>     Baz baz = (Baz) foo;
>     return baz.qux;
>   }
> }
>
> // in JavaScript
>
> var baz = { qux: 42 };
> com.acme.Bar.action(baz); // will return 42!
>
> The image below demonstrates the issue at runtime.
>
>
> <https://lh3.googleusercontent.com/-9z2t_Q8R0oI/Vjc1qBoQgfI/AAAAAAAABEc/CAbDBqNfUZc/s1600/debugger3.png>
>
>
> I can't seem to find anywhere inside the generated javascript, where a 
> class literal is assigned to the value 33.
>
> /Brian
>
> Den torsdag den 29. oktober 2015 kl. 09.37.48 UTC+1 skrev Goktug Gokdogan:
>>
>> You can only implement java contract (e.g. PayLoad class) in javascript 
>> if they are marked as isNative. See the related section in the new 
>> jsinterop doc.
>>
>>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to