JavaPoly.js polyfills native JVM support in the browser

263 views
Skip to first unread message

Paul Norman

unread,
May 10, 2016, 10:22:48 PM5/10/16
to DroidScript
Hi,

Here's something that may prove eventually to have some interesting implications and useful application to increasing DroidScript functionality...

"JavaPoly.js is a library that polyfills native JVM support in the browser.
It allows you to import your existing Java code, and invoke the code directly from Javascript.

"JavaPoly works even if the user does not have Java installed on their computer. It finally allows Java to become a first class citizen by running directly in the browser's script tags (and interacting directly with the DOM), instead of being confined to an applet sandbox."

https://www.javapoly.com

Paul

Gerard Hernandez

unread,
May 11, 2016, 11:00:35 AM5/11/16
to DroidScript
Im thinking in a lot of crazy stuff that can be achieved with this if it turns out to work in Droidscript. 

I will give it a try. Thanks a lot Paul for sharing it.

Paul Norman

unread,
May 12, 2016, 12:48:23 AM5/12/16
to DroidScript
Yes, apart from anything more foreign/ exotic, you also wonder about a future direct link/bridge like
<script src='file:///android_asset/app.js'></script>

... is for JavaScript, for raw Java then to the DroidScript "engine" etc... still trying to get my mind thinking clearly through all that :-)

Paul

Dave Smart

unread,
May 12, 2016, 6:29:08 AM5/12/16
to DroidScript
I expect it could be useful for re-using some popular Java utility libraries, but it must be very restricted when it comes to IO because it is running inside a browser and things like TCP and local file access etc won't work (I assume).  

How do they do graphics, do they use the HTML canvas?

Gerard Hernandez

unread,
May 12, 2016, 10:32:25 AM5/12/16
to DroidScript
Yeah, I was also thinking on the linkage between graphics components, I guess it would be more useful for non UI features.

Warren Downs

unread,
May 12, 2016, 12:21:24 PM5/12/16
to DroidScript
I read their paper and didn't see anything about graphics.

For file I/O they emulate a unix filesystem with an internal API compatible with nodejs.  They allow filesystems to be mounted, and currently support ones such as DropBox, browser persistent storage, an in-memory tmp filesystem, and a read-only remote http server filesystem.  None of which are local file storage.

They emulate TCP/IP using WebSockets and a proxy application (native) outside the browser that translates TCP/IP connections to WebSockets so the browser can interact with them.

I'm sure HTML canvas could be used, but before the system becomes practical it needs more optimization.  Currently it's 24-40 times slower than the Hotspot Java virtual machine.

Warren Downs

unread,
May 12, 2016, 12:22:19 PM5/12/16
to DroidScript
(Don't get me wrong, I'm very impressed with what they've accomplished so far)
Reply all
Reply to author
Forward
0 new messages