Monday, August 21, 2017

Re: ClassCastException in generics

Ok, according to the doc, the name:
 Customizes the name of the type in generated JavaScript. If not provided, the simple Java name will be used.

That means that for my case  

@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public abstract class ArrayBuffer { ... }

This is equvavlent to (name = "ArrayBuffer"). Which was suggested above. Right ? 

I tried the following without any success:
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "ArrayBuffer")

JavaScriptObject jsType is stil null and checkcast failed.

But this works:

@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")

In that case GWT calls castToJsObject, which does not do type checking, instead of castToNative. castToNative does type checks.

However I still don`t think that name="Object" is correct for native ArrayBuffer. 
If I understand JsInterop correctly, when want to call a @JsConstructor form java I must assign a proper name, right ?

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
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment