Content deleted Content added
→Generating bytecode: Jython added, formatting |
Thumperward (talk | contribs) transwiki instructional content to b:Java Programming/Byte Code |
||
Line 1:
'''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)|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.{{Fact|date=June 2008}}
Line 7 ⟶ 5:
A [[Java (programming language)|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 [[assembly Language|assembler]] helps the [[C (programming language)|C]] or [[C++]] programmer."<ref>[http://www-128.ibm.com/developerworks/ibm/library/it-haggar_bytecode/ Understanding bytecode makes you a better programmer]</ref>.
==
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:
Line 16 ⟶ 14:
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 (Java assembler)|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 <ref>[http://jasmin.sourceforge.net Jasmin Home Page<!-- Bot generated title -->]</ref>
* [[Jamaica (Java assembler)|Jamaica]], a [[Macro (computer science)|macro]] [[assembly language]] for the [[Java virtual machine]]. Java syntax is used for class or interface definition. Method bodies are specified using bytecode instructions. <ref>[http://www.judoscript.org/jamaica.html Jamaica: The Java Virtual Machine (JVM) Macro Assembler<!-- Bot generated title -->]</ref>
Others developed compilers for different programming languages targeting Java virtual machine, such as:
* [[JGNAT]] and [[AdaMagic|AppletMagic]], compile from the [[Ada programming language]] to Java bytecode
* [[Jython]], a [[scripting language]] based on [[Python (programming language)|Python]]
Line 25:
* [[C to Java byte-code compiler]]s
==
Java bytecode is designed to be executed in [[Java virtual machine]]. There are several virtual machines available today both free or commercial.
Line 33:
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 [[GCJ|GNU Compiler for Java]].
==Support for dynamic languages==
{{main|list of JVM languages}}
The [[Java Virtual Machine]] has currently no built-in support for [[Type system#Dynamic_typing|dynamically typed languages]], because the existing JVM instruction set is [[Type system#Static typing|statically typed]].<ref>{{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}}</ref>
[[Java Community Process|JSR 292]] (''Supporting Dynamically Typed Languages on the JavaTM Platform'') <ref>[http://www.jcp.org/en/jsr/detail?id=292 see JSR 292]</ref> propose to add a new <code>invokedynamic</code> instruction at the JVM level, to allow method invocation relying on dynamic [[Type system#Type checking|type checking]] (instead of the existing statically type-checked <code>invokevirtual</code> instruction). The [[Da Vinci Machine]] is a prototype virtual machine implementation that hosts JVM extensions aimed at supporting dynamic languages.
== See also ==
Line 552 ⟶ 53:
* [[ARM9E]]
* [[Common Intermediate Language]]
== References ==
{{reflist|2}}
== External links ==
Line 560 ⟶ 64:
{{Java (Sun)}}
{{listdev}}
|