Re: How to translate a language that runs on JVM?

sgganesh@gmail.com
9 Jan 2005 20:49:12 -0500

          From comp.compilers

Related articles
How to translate a language that runs on JVM? jrefactors@hotmail.com (2005-01-03)
Re: How to translate a language that runs on JVM? sgganesh@gmail.com (2005-01-09)
Re: How to translate a language that runs on JVM? holycall@paran.com (Seokwoo Choi) (2005-01-09)
Re: How to translate a language that runs on JVM? vbdis@aol.com (2005-01-09)
Re: How to translate a language that runs on JVM? news8573@paulcager.com (Paul Cager) (2005-01-09)
Re: How to translate a language that runs on JVM? napi@cs.indiana.edu (2005-01-12)
Re: How to translate a language that runs on JVM? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-01-12)
Re: How to translate a language that runs on JVM? pohjalai@cc.helsinki.fi (A Pietu Pohjalainen) (2005-01-12)
[1 later articles]
| List of all articles for this month |
From: sgganesh@gmail.com
Newsgroups: comp.compilers
Date: 9 Jan 2005 20:49:12 -0500
Organization: http://groups.google.com
References: 05-01-012
Keywords: Java, translator
Posted-Date: 09 Jan 2005 20:49:12 EST

I would say that, it depends on the level of abstraction of your
"Non-Java Source Code". Based only my experience in writing a Java
compiler and parts of a JVM (for the purpose of learning) it appears
to me that JVM was originally designed keeping Java as the only source
language in mind. However, note that there are translators for more
than a dozen languages available targetting JVM.


There are many portions in .class file format that makes writing
translators for other versatile languages to JVM difficult, if not
impossible. For example, consider directly translating C++ programs to
.class files: things like not having support for multiple inheritance
are obvious reasons, but there are many subtle language features, for
example, how const and final are treated in C++ and Java; also the
runtime allocation and memory models aren't just compatible. The JVM
specification mandates that the Java security model is adhered to, and
hence generating valid .class files is non-trivial (particularly when
the source language is not Java, but something different).


So, it depends on the level of abstraction your non-java source code
is and how close it is to the semantics of Java. If the semantics is
closer to Java, and significant information need not be lost when
expressed as Java programs, the first option is fine (your translator
would be simple in that case). In the other case, the second
alternative is better. In the second case, you would need to refer the
Java virtual machine specification book from Sun. The "Inside Java
Virtual Machine" book by Bill Venners will also be handy.


-Ganesh


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.