Interesting project, nice work 8)
I see that the code contains some android source, what’s that used for?
Can you explain how your project is different to these existing frameworks?
Google’s GWT http://www.gwtproject.org/
Or Google’s new J2CL https://github.com/google/j2cl
Thanks for response.
Android is just a trial to parse a dex file (basically a jar file, but better organized). Maybe sometime it will be able to run Android apps.
Thanks for the projects, I knew about GWT. My project is more like it as jsweet. It runs the originall java application. It prints even usual java stacktraces on crash.
So you just delegate the garbage collector task to the browser.
Wow, your skills and investigations have let you explore and master the deep internals of the JVM, impressive. You might be interested in Emscripten which looks like it might be the most performant way to run code in the browser. Our very own @KaiHH (httpdigest) looked into it a few years ago. There’s some interesting dialogue here:
Would be interesting to know where you intend to take this project considering that JSweet and other solutions already exist.
Some advantages to do it in Java would be:
you can use all the tools avaliable for Java development.
Emscripten is also an interesting topic. Currenty I am developing a further JVM implementation with plain C. This impelementation actually needs a Garbage Collector. Maybe it could be compiled to webassembly than…
EDIT: I am planning to implement the JDWP (Java Debuging Wire Protocol). With this you could debug the Java-Application with an IDE (for Example intellij) while it is runnig in the browser.
Maybe a little bit offtopic and a slightly different usecase: I recently used vaadin flow for a project which lets you build an entire webapp with pure Java. No HTML or CSS required. My guess would be that they recreated the entire DOM in Java to make that work. I like it for prototyping but from my experiences it is often a pretty big black box.
Ok, TeaVM is actually convincing. Thank you for the tip. It has an interesting multithreading approath:
I know two bytecode-optimisation techniques: ahead of time compilation and just in time compilation. In both cases you can do some optimisations. For example you can inline all the final getter and setter methods. But yeah there are optimiations that can be done only at runtime with a “just in time compiler”. For example you could gather statistics about method invocations and inline all the final “hot” methods.
There are two interesting bytecode-instructions to invoke a method on an Object:
INVOKESPECIAL and INVOKEVIRTUAL
INVOKEVIRTUAL searches for the method based on its class. This is necessary because the method could be overriden by a subclass. For example:
//following code invokes the method hashCode which should be located in the class String
On the other hand INVOKESPECIAL invokes a method directly without searching. It could be for example a constructor or a method which is private (called in its own class). INVOKESPECIAL is way faster.
To optimize the code you could convert any INVOKEVIRTUAL instruction to INVOKESPECIAL when you can guarantee that the method will not be overriden. This is the case for final methods.
A just in time compiler could furthermore simply mark every method is “final” and drop this assumption when it finds an override.