Tuesday, June 23, 2015

Re: Convert Java library to JS lib.

 
Looks like GWT project must be run to make accessible all Java functionality from JS. Is it true? 

Yes, the getting started of gwt-exporter also point that out (at the bottom of the "Quick Start Guide" section). You need a JS callback so you know when the JS produced by GWT has been executed by the browser. Only then the exported Java code is available in JavaScript.

 
And back to my original problem: Is it possible to create standalone JS lib with embedded bitcoinj Java lib? Or it's just not possible technically due to JS limitations?

Depends on what you want to use from that library. GWT does not support the full JRE API because some APIs simply won't work in browsers, others won't work efficiently in browsers and again others are not really demanded by web app developers.

To see what GWT supports out of the box take a look at: 

http://www.gwtproject.org/doc/latest/RefJreEmulation.html
https://gwt.googlesource.com/gwt/+/master/user/super/com/google/gwt/emul (thats the latest right from git master branch)

You will quickly notice that there is no crypto api, no reflection, no multi threading which might all be used by your bitcoin library. So when your Bitcoin library uses JRE APIs that GWT does not support you would need to emulate them yourself using GWT's "super-source" mechanism or mark them as @GwtIncompatible so that the GWT compiler will simply ignores them.


-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@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.

No comments:

Post a Comment