Monday, August 21, 2017

Re: ClassCastException in generics

This is perfectly fine ArrayBuffer which I got from the system call to FileReader.onLoad callback. 
It correct, it loads and I finally read a 3d ojbect form it.

What else can it be if not ArrayBuffer (hence the need of generic)? An ArrayBuffer extension?
I`m trying to generalize the drag-drop code across GWT and JVM clients. 
We have a portable UI code and it is fine to move as much code as possible to portable segment in order to reduce deplicates and bugs.

And I think one expect native JsType`s to be working for generic arguments. 

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

Yes and this is the problem I can not understand.
With the default name and name=ArrayBuffer the generic crashes in generated call to castToNative.
With name=Object the GWT does not generate type checking, instead it generates call to castToJsObject.

What am I doing wrong ?

And again, I hope using name=Object is not the best way to solve it. It looks like a hack to fool the GWT to avoid the crash.

Any suggestions ? 


понедельник, 21 августа 2017 г., 17:06:26 UTC+3 пользователь Vassilis Virvilis написал:
Oh I see. I forgot about that.

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

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

I don't know what else may be the problem.

What else is it going on java side?
Maybe the instance you are trying to cast is null?
What else can it be if not ArrayBuffer (hence the need of generic)? An ArrayBuffer extension?
If you print the variable you are trying to cast in the console? Does it says that's an ArrayBuffer?

I jave been fighting with jsinterop exceptions for some time and I know that it can be very frustrating.



On Mon, Aug 21, 2017 at 4:52 PM, Kirill Prazdnikov <> wrote:
Im talking about standard ArrayBuffer

From the console of the web browser: What is it required to create a new ArrayBuffer?

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