Print

Integration Watch: Java to C: No mean feat



Andrew Binstock
Email
September 15, 2008 —  (Page 2 of 3)
Another approach, I believe, is more likely to work: Start not from the Java source, but from the Java bytecodes.

Interestingly, there are ways to convert C code without having to emulate JVM operations. One is to translate the bytecodes back into a simple, declarative language from which C statements can be generated. A package that does this translation is Soot, from McGill University in Canada. Soot, which is open source, was originally designed as a framework for optimizing bytecodes. One of its byproducts was the ability to translate those bytecodes into a variety of easily parsed formats.

The conversion to compilable C that faithfully replicates the Java functionality is nontrivial. Part of the problem is that some data is lost when the Java compiler, javac, creates bytecodes (for example, enums are enforced by javac, but the type data is not passed to the bytecodes). Another issue is the lack of symmetry between Java’s assembly-level constructs and C. In a thesis on the topic, one student lists many of the issues, ranging from the prosaic, such as name length (C can require that names be disambiguated in the first 63 characters), to the seemingly intractable, such as C’s lack of reflection and its vastly different security model. To be fair, such problems are not unique to this approach; they would have to be solved in a source-level port as well.

The JC compiler claims to have solved most of these problems. But the project has been suspended since 2005, and even then it had specific requirements. Nevertheless, it did manage, per its docs, to automate C to Java conversion.

Working from binaries has one compelling advantage: It is inherently automatable, so that changes to the original Java codebase simply require a new build (whereas for a source port, each change to the Java side entails painstaking reconstruction in C). Had I accepted the project, I would have exhausted binary before going to source migration.



Related Search Term(s): Java, open source, software development

Pages 1 2 3 


Share this link: http://sdt.bz/32821
 


Comments


02/12/2010 08:23:53 AM EST

Hi, Andrew! A bit belated comment but... Among GCJ and JC projects, I could mention a JCGO (www.ivmaisoft.com/jcgo) one, a Java source to C translator. Given the sources of the Java program, it translates all the sources at once producing readable platform-independent C code which could further be compiled to a binary executable for the targeted platform. The produced executable does not contain nor require a Java Virtual Machine to execute, so its resource requirements are smaller than that required by a typical Java VM.

Russia (Russian Federation)Ivan Maidanski


close
NEXT ARTICLE
News Briefs: July 15, 2008
Enea is named to the board of CP-TA, Teradata introduces a new version of its data warehousing tool and SOA Software upgraded its Repository Manager to accommodate its Policy Manager software Read More...
 
 
 




News on Monday  more>>
Android Developer News  more>>
SharePoint Tech Report  more>>
Big Data TechReport  more>>

   
 
 

 


Download Current Issue
JUNE 2013 PDF ISSUE

Need Back Issues?
DOWNLOAD HERE

Want to subscribe?


 
 
 
 

Events calendar tab
Mobile Commerce World
6/24/2013 to 6/26/2013
San Francisco
UBM TechWeb
USENIX Federated Conference
6/24/2013 to 6/28/2013
San Jose, Calif.
USENIX
Microsoft Build
6/26/2013 to 6/28/2013
San Francisco
Microsoft
Conf. on Big Data Security
7/17/2013 to 7/18/2013
Boston
MIS Training Institute
ACM SIGGRAPH
7/21/2013 to 7/25/2013
Anaheim, Calif.
ACM SIGGRAPH