cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.46k stars 158 forks source link

Wrappers for JDK types #100

Closed mbektimirov closed 8 years ago

mbektimirov commented 8 years ago

Is it possible to wrap standard JDK classes into own implementations? For example, I have a lot of InputStream references in my java code, can I smoothly replace this class with alternative js implementation to compile it with jsweet?

renaudpawlak commented 8 years ago

Yes it is possible. You can implement your own JDK class in TypeScript or in JSweet and package the result within a JSweet candy that you can then add in your pom.xml as a dependency. The new j4ts project provides a basis to do it quite easily in TypeScript (just follow the build instructions).

FYI, I am currently working on adapting the GWT JRE runtime (emulation) so that most JRE classes (including streams) should be soon available in JSweet (if everything goes as expected ;)).

At this point you can contribute to j4ts in the meantime, and switch to the coming JRE runtime when available.

mbektimirov commented 8 years ago

Thanks, that makes sense.

micaelgallego commented 8 years ago

Hi @renaudpawlak,

I'm very interested in your work adapting GWT JRE runtime to be used with TypeScript. Please can you give us more information about it? Thanks in advance.

renaudpawlak commented 8 years ago

Hi! I have good news. I have finally managed to compile a fork of the GWT's Java emulation with JSweet :)

You can use this emulation in JSweet, in JavaScript and in TypeScript. You can already access the code and the generated bundles on the J4TS project. Right now it is beta and I have only (partially) tested the java.util package and some of the java.io package. I have decided not to port the java.math package for good reasons that I will explain later.

It is not public yet because I am planing to communicate on it with the 1.1.0 release, which I am currently working on (should be released early this coming week if everything goes right).

BTW, if you like what is going on here, please don't hesitate to talk about it, to contribute, and to star the project on Github ;) Upcoming 1.1.0 version will bring major improvements and it would be the right timing to try to build up a bigger community :) Thank you for your help.

ssatguru commented 8 years ago

Good news indeed !