3.3    JavaScript Image Linker



JaSIL is a compiler/linker which translates applications developed with Java to JavaScript. The currently used JDK is Apache Harmony. The optimized runtime image created by the linker does contain only the referenced classes, fields and methods. The JaSIL project offers the possibility to explore the usage of preemptive Java threads with JavaScript and their application in clients of Web-Applications.

JaSIL does translate Java bytecode to JavaScript and does therefore use a more general approach than similar projects which use special Java front-ends. The system does use the garbage collector of JavaScript for memory management.


• Motivation for the Translation of Java to JavaScript

JavaScript is a functional language available on all popular current web browsers. In this way it is one of the most available and used platforms in the world. Java is a popular object oriented programming language with strong typing, which is available on many different platforms also. Very good IDE support allows developers to efficiently create and maintain complex Java applications. Using Java simplifies the development of complex web applications, but it is in general not enough to translate an existing Java program to JavaScript, because further special adaptions to the web browser environment are required.


• Java/JVM Compatibility

JaSIL does provide options to provide less or more Java/JVM compatibility of the generated JavaScript code. Generating support for preemptive Java threads, including synchronization is therefore optional. These threads are realized in software and do not provide real hardware based multiprocessing. It is currently not intended to support dynamic class loading and runtime reflection of Java classes is limited. If threads are not required then jumps can be eliminated [ Ero95 ] optionally, to generate more efficient code. The performance of JavaScript code without jumps is around 11 % faster.


• Example with Threads

Clicking on the button below opens a dialog and starts a simple word counting task. It reads a file from the server, counts the words and displays the results in a table. Closing the dialog does terminate this task. A thread with low priority is used for this task.

Because threads are used, the GUI remains responsive, the window can be moved or minimized to the WEB-Dock and the table is constantly updated. Java programmers can use thread concepts they are already familiar with. The system does support threads with priorities and GUI activity can therefore slow down the word counting thread.


• Example with WebGL

Clicking on the button below opens a dialog and starts a simple WebGL application. Threads are not used in this example, which means the application does run in the "GUI thread".


• Related Projects