Start from command line
and that is it! Just three shell commands and you have all the environment you need!
Test Your Code!
Follow the advice of the previous article
to write your code into
DataModel.java class, if you want, but as
our main focus is on finding the problems, let’s do something else.
and let’s add there the Java code we are about to check for misbehaving:
there is already a
@Test method present, so let’s write another one:
to test the behavior of
String.format (which is known to be slightly less
optimally implemented in Bck2Brwsr virtual
machine). After saving the file it is time to run the code:
That is it! The system executes your
stringBehavior test in classical Java HotSpot VM,
and in Bck2Brwsr VM, compares the results
and fails. Fails as the HotSpot VM throws an
while Bck2Brwsr produces some string output.
Report a Bug
If you have such failing test, it is time to report a bug. Either use DukeScript forum or premium support or report the bug directly to Bck2Brwsr issue tracker. Attach the test case you have written, so the failure can be easily reproduced.
Simplify your Code
While waiting for resolution of the bug, it may be reasonable to simplify
your code to use constructs fully supported by all VMs you are about to target.
For example by rewriting the
@Test code to:
mvn -f client-web/ package again one gets code that is behaving
the same in HotSpot as well as in Bck2Brwsr VM.
Improve Java in the Browser!
Long live transpiled Java code!