Java bytecode

Java bytecode

Java bytecode is the form of instructions that the Java virtual machine executes. Each bytecode 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, the Java 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 a Java compiler helps the Java programmer in the same way that knowledge of assembler helps the C or C++ 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, the javac compiler from Sun Microsystems, which compiles Java 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 by IBM, implemented in C++)
* 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 macro assembly language for the Java 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 and Jython, two scripting languages based on Ruby and Python
* Groovy, a scripting language based on Java
* JGNAT and AppletMagic, compile from the Ada programming language to Java bytecode
* C to Java byte-code compilers

Execution

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-checked invokevirtual instruction). The Da 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.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Java-Bytecode — In der Informatik ist Bytecode eine Sammlung von Befehlen für eine virtuelle Maschine. Bei Kompilierung eines Quelltextes mancher Programmiersprachen oder Umgebungen, wie z. B. Java, wird nicht direkt Maschinencode sondern ein Zwischencode, der… …   Deutsch Wikipedia

  • Java bytecode — javos baitinė programa statusas T sritis informatika apibrėžtis Programa, parašyta javai pritaikyta tarpine programavimo kalba. Javos tarpinė kalba yra nepriklausoma nuo operacinės sistemos. Todėl ja parašytą programą gali vykdyti bet kuri… …   Enciklopedinis kompiuterijos žodynas

  • Java bytecode — El bytecode es un código intermedio más abstracto que el código máquina. Habitualmente se lo trata como a un fichero binario que contiene un programa ejecutable similar a un módulo objeto, que es un fichero binario que contiene código máquina… …   Enciclopedia Universal

  • Java (Framework) — Java Objektorientierte Programmiersprache Basisdaten Paradigmen: Objektorientierte Programmiersprache Aktuelle  …   Deutsch Wikipedia

  • Java (Softwaretechnologie) — Java Objektorientierte Programmiersprache Basisdaten Paradigmen: Objektorientierte Programmiersprache Aktuelle  …   Deutsch Wikipedia

  • Java (Programmiersprache) — Java Basisdaten Paradigmen: Objektorientierte Programmiersprache Erscheinungsjahr …   Deutsch Wikipedia

  • Java (informatique) — Java (langage) Pour les articles homonymes, voir Java.  Ne doit pas être confondu avec JavaScript …   Wikipédia en Français

  • Java (langage de programmation) — Java (langage) Pour les articles homonymes, voir Java.  Ne doit pas être confondu avec JavaScript …   Wikipédia en Français

  • Java 5 — Java (langage) Pour les articles homonymes, voir Java.  Ne doit pas être confondu avec JavaScript …   Wikipédia en Français

  • Bytecode — is a term which has been used to denote various forms of instruction sets designed for efficient execution by a software interpreter as well as being suitable for further compilation into machine code. Since instructions are processed by software …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”