Brought to you by EarthWeb
ITKnowledge Logo Login Graphic Click to go to the Oscars.
Click to go to the Oscars.
ITKnowledge
Find:
 
EXPERT SEARCH ----- nav

EarthWeb Direct

EarthWeb sites: other sites

Previous Table of Contents Next


JVM Instruction Set

The last piece of the JVM is not a region, or a device, or even a physical element of the JVM. Rather, the JVM Instruction Set is the driving entity that gives the JVM life. The Instruction Set tells the processor to perform an action. In the case of the JVM Instruction Set, those actions equate into 160 instructions, partitioned in 17 different categories.

In native-compiled programs, the executable contains that program’s associated set of operations, which perform the desired functionality. The difference with Java-executable program files is that the operations contained with the file are JVM instructions and not native instructions. In this manner, Java executables are identical to normal executables, except Java executables are compiled to run on the JVM.


Note:  None of the 160 instructions are testable items in either the Java Certified Programmer or Java Certified Developer examinations. For this reason, there will not be a detailed discussion of each individual instruction. However, the following is a list of JVM instructions for reference purposes.
bipush sipush ldc1
ldc2 ldc2w aconst
iconst iconst lconst
fconst dconst Iliad
iload lload fload
dload aload istore
lstore fstore dstore
astore astore iinc
newarray anewarray multianewarray
arraylength iaload laload
faload daload aaload
caload saload iastore
lastore fastore dastore
aastore bastore castore
sastore nop pop
pop2 dup dup2
dup_x1 dup2_x1 dup_x2
dup2_x2 swap iadd
ladd fadd dadd
isub lsub fsub
dsub imul fmul
dmul idiv ldiv
fdiv ddiv imod
lmod fmod ddiv
ineg lneg fneg
dneg ishl ishr
iushr lshl lshr
lshur iand land
ior lor ixor
lxor i2l i2f
i2d l2i l2f
l2d f2i f2l
f2d d2i d2l
d2f int2byte int2char
int2short ifeq iflt
ifle ifne ifgt
if_icmpeq if_icmpne if_icmplt
if_icmple if_icmpgt if_icmpge
lcmp fcmpl fcmpg
dcmpl dcmpg if_acmpeq
if_acmpne goto jsr
ret ireturn lreturn
freturn dreturn areturn
return tableswitch lookupswitch
putfield getstatic putfstatic
getfield invokevirtual invokestatic
invokeinterface athrow new
checkcast newfromname instanceof
verifystack monitorenter monitorexit
breakpoint

Anatomy of a Class File

The structure of a class encapsulates an entire object. For this reason, class file structure is required knowledge for the Certified Programmer Examination.

You know that Java executables run on a JVM and are directly interpreted into native instructions, so now it’s time to discuss the concept of a Java executable file, or class file.

In the PC world, an executable directly equates to an .exe file, and, on most platforms, executable files contain an entire program sequence. Java does things a little differently. Each executable file holds a single compiled object. One object acts as the entry point and calls supporting class files for needed functionality. For example, upon execution of an Applet, the Java runtime environment loads the main executable class and java.applet.Applet class into the JVM for execution.

Unlike native file executables, which contain a grouping of functionality in a single file, Java executables are constructed in such a way as to contain only a single object per file. In this way, each executable file is a reusable, self-contained application component. To facilitate this, the file is broken into fifteen separate Java class file regions, which are as follow:

  magic
  version
  constant_pool_count
  constant_pool[constant_pool_count - 1]
  access_flags
  this_class
  super_class
  interfaces_count
  interfaces[interfaces_count]
  fields_count
  fields[fields_count]
  methods_count
  methods[methods_count]
  attributes_count
  attributes[attribute_count]

Each region contains a different piece of the developed object. Figure 1.5 illustrates the regions of a class file. The following sections analyze each of the regions in turn.

The Magic Region

The Magic Region must contain a magic value of 0xCAFEBABE. This value simply has to be there. There is not much more to say about this region except to ask, “Why is it called magic?” It just is!


Previous Table of Contents Next
HomeAbout UsSearchSubscribeAdvertising InfoContact UsFAQs
Use of this site is subject to certain Terms & Conditions.
Copyright (c) 1996-1999 EarthWeb Inc. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.