Using Javascript HTML5 typed arrays from Java using ScriptManager (Rhino), how?

I also ported the application that I developed on client-side Javascript on my server (for multiplayer game purposes). I execute some parts using ScriptEngine because I want to use the same code on the client and server, without killing everything twice.

It worked fine in the beginning, but then I came across the problem of new typed arrays from HTML5 (Float32Array, Uint8Array ...). These arrays are not supported by ScriptEngine (Rhino), and I need them for performance reasons, so I cannot redefine them in javascript using non-typed arrays.

I decided to redefine them using Java and import the package, but there is no way to redefine [] in Java and extend the base arrays (AFAIK).

So, in the end I do a hack and set some rules for the developer.

Does anyone know a solution or a way to override typed arrays in Java and export them to Javascript ?.

thanks

+6
source share
1 answer

If I'm not mistaken, this can help you.

http://json.org/java/

-3
source

Source: https://habr.com/ru/post/893705/


All Articles