Dot42 project moves to new format (C # 2 Java)
- Transfer
Project dot42

The main goal of the dot42 project is to create Android applications using the C # language, without having to install the Mono interpreter using Microsoft Visual Studio or SharpDevelop. The project has attracted strong interest from the developers of mobile software since the publication of a technical preview in January 2013. Unfortunately, due to the complexity of the subject area, starting in January 2014, community activity began to decline significantly.
The main function and at the same time the fundamental problem of the project is the conversion of compiled C # code (IL code) to Java bytecode, which is executed on Android on a Davlik or ART virtual machine. The development and support of such a project requires deep and highly specialized knowledge in both compiled bytecode formats and strong knowledge in the field of creating and supporting compilers and cross-compilers. The number of specialists in this field is currently small.
Convert to DEX
There are many shortcomings in decoding IL code in Dex, which are gradually eliminated during the development of the dot42 project. Currently, a decision has been made to extend the .Net SDK with the addition of Java. The dot42 team recruited a PhD specialist in cross-compilation and software conversion to analyze the current status of the project. His first task is to decide how to convert C # code to Java code.
Fundamentally, there are two approaches:
- Bytecode conversion (from IL to Java bytecode);
- Conversion at the source level (from C # to Java);

Bytecode Conversion vs. Source Code Conversion
Debugging problem
An error in converting bytecode from IL to Dex often leads to the Java virtual machine throwing a java.lang.VerifyError exception . This exception is thrown when the Java interpreter notices that an attempt is being made to load a class that has not previously passed the validation phase. Finding errors in this code is like trying to determine what was messed up in a dinner while picking on a restaurant’s toilet. A typical example in this case is that the DEX code is successfully executed in the Davlik virtual machine, but crashes inside the ART.
Conversion of source codes does not have this drawback, the Java compiler takes care of the correct location of the application bytecode.
Implementation experiments
Imagine that the dot42 team needs to add new functionality to a project, for example, support async / await from C #. Work on PoC in byte codes in this case is much more difficult and costly than similar improvements when converting source codes from C # to Java.
Using compiler
Compilers for various virtual machines and CPU architectures use various code optimization mechanisms. The IL code generated by the C # compiler uses a stack architecture. On the other hand, Davlik and ART virtual machines use a register model. Compiled by the C # compiler, the IL code no longer contains information that would be useful for the Java compiler. In contrast, when converting source codes, we allow the Java compiler to generate more efficient bytecode.
Roslyn
Now that Microsoft is providing the Roslyn open source C # compiler with rich code analysis APIs, the dot42 team has a powerful tool for converting source code from C # to Java.
Transparent development
Ultimately, for developers using dot42, converting source code from C # to Java will make the process more transparent and maintainable. This process will allow you to open ready-made Java code in the popular Eclipse IDE or Android Studio.
Further development of the project
The dot42 team plans to release compiler utilities under the GPLv2 license. It should be noted that the GPL does not apply to software created using dot42. Thus, thanks to the project, developers will have the opportunity to create native Android applications using C #.
The library execution code has already been posted in Git under the Apache License 2.0. Anyone can create a fork of the dot42 project and expand the approach to converting IL code to DEX.
Users no longer need a Professional license to create commercial applications using dot42. The next update plans to remove activation.
The dot42 team is about to replace the bytecode converter with a source converter. All utilities under development will also use the GPLv2 license, and the library execution code will use the Apache License 2.0.
Thank you very much for reading to the end!