- Java bytecode
Java bytecode is the form of instructions that the
Java virtual machine executes. Eachbytecode instruction or opcode is one byte in length, however not all of the possible 256 instructions are used. In fact,Sun Microsystems , the original creators of the Java programming language, theJava virtual machine and other components of the Java Runtime Environment (JRE), have set aside a number of values to be permanently unimplemented. [http://java.sun.com/docs/books/jvms/second_edition/html/Instructions.doc.html#60105 VM Spec - Reserved Opcodes] ]Relation to Java
A Java programmer does not need to be aware of or understand Java bytecode at all. However, as suggested in the
IBM developerWorks journal, "Understanding bytecode and what bytecode is likely to be generated by aJava compiler helps the Java programmer in the same way that knowledge of assembler helps the C orC++ programmer." [ [http://www-128.ibm.com/developerworks/ibm/library/it-haggar_bytecode/ Understanding bytecode makes you a better programmer] ] .Generation
The most common language targeting
Java Virtual Machine by producing Java bytecode is Java. Originally only one compiler existed, thejavac compiler from Sun Microsystems, which compilesJava source code to Java bytecode; but because all the specifications for Java bytecode are now available, other parties have supplied compilers that produce Java bytecode. Examples of other compilers include:*
Jikes , compiles from Java to Java bytecode (developed byIBM , implemented inC++ )
* Espresso, compiles from Java to Java bytecode (Java 1.0 only)
*GCJ , the Gnu Compiler for Java, compiles from Java to Java bytecode; it is also able to compile to native machine code and is available as part of the GNU Compiler Collection (GCC).Some projects provide Java assemblers to enable writing Java bytecode by hand. Assembler code may be also generated by machine, for example by compiler targeting
Java virtual machine . Notable Java assemblers include:* Jasmin, takes textual descriptions for Java classes, written in a simple assembler-like syntax using Java Virtual Machine instruction set and generates a Java class file [ [http://jasmin.sourceforge.net Jasmin Home Page ] ]
* Jamaica, a macroassembly language for theJava virtual machine . Java syntax is used for class or interface definition. Method bodies are specified using bytecode instructions. [ [http://www.judoscript.org/jamaica.html Jamaica: The Java Virtual Machine (JVM) Macro Assembler ] ]Others developed compilers for different programming languages targeting Java virtual machine, such as:
*
JRuby andJython , twoscripting language s based on Ruby and Python
* Groovy, ascripting language based on Java
*JGNAT and AppletMagic, compile from theAda programming language to Java bytecode
* C to Java byte-code compilersExecution
Java bytecode is designed to be executed in a
Java virtual machine . There are several virtual machines available today both free or commercial.If executing Java bytecode in a Java virtual machine is not desirable, a developer can also compile Java source code or Java bytecode directly to native machine code with tools such as the GNU Compiler for Java. Some ARM processors have the ability to execute bytecode directly.
upport for dynamic languages
The
Java Virtual Machine has currently no built-in support for dynamically typed languages, because the existing JVM instruction set is statically typed. [cite web
url=http://headius.blogspot.com/2007/01/invokedynamic-actually-useful.html
title=InvokeDynamic: Actually Useful?
date=2007-01-03
last=Nutter|first=Charles
accessdate=2008-01-25]JSR 292 ("Supporting Dynamically Typed Languages on the JavaTM Platform") [ [http://www.jcp.org/en/jsr/detail?id=292 see JSR 292] ] propose to add a new
invokedynamic
instruction at the JVM level, to allow method invocation relying on dynamic type checking (instead of the existing statically type-checkedinvokevirtual
instruction). TheDa Vinci Machine is a prototype virtual machine implementation that hosts JVM extensions aimed at supporting dynamic languages.See also
*
Class (file format)
*List of JVM languages
*C to Java Virtual Machine compilers
*ARM9E
*Common Intermediate Language References
External links
* [http://java.sun.com/docs/books/vmspec/2nd-edition/html/VMSpecTOC.doc.html Sun's Java Virtual Machine Specification]
* [http://www.is-research.de/info/vmlanguages/ Programming Languages for the Java Virtual Machine]
Wikimedia Foundation. 2010.