Java Assembly Language

ClassCracker can convert a class file to a jasm Java Assembly Language file. The jasm file produced is useful for gaining a greater understanding of the Java Virtual Machine (JVM) and for understanding how Java source code compilers produce JVM code.

Although some Java Assemblers do exist, there is no official specification for a Java Assembler Language (JASM). Each Assembler has its own specification (although these specifications tend to be similar).

ClassCracker has its own JASM specification which is based on "standard" assembly language conventions. The instruction opcodes used are those in the book:

"The Java Virtual Machine Specification 2nd Edition", by Tim Lindholm and Frank Yellin (published by Addison-Wesley)

The JASM code produced by ClassCracker is not intended to be assembled, although it could be modified manually to suit the conventions of a particular assembler.

ClassCracker JASM Specification

JASM classes and methods look much the same as Java classes and methods. For example, in both Java and JASM a typical method might have the following structure:

  void methodName( parameter list)
  {
    local variables;
    ...
    code
    ...
  }

What differs between Java and JASM is the code section. In JASM, the code section consists of labels, JVM opcodes, operands and comments. Comments are preceeded by '//'. A typical JASM code line is of the form:

  label  opcode  operand1, operand2, ...    // comments

The majority of JVM opcodes are self-explanatory. however there are a few special cases:

a) the 'lookupswitch' opcode has the form:

  lookupswitch
  match1  : label1
  match2  : label2
  ...     : ...
  default : labelN     // comment

where the 'match' corresponds to the value in a  case  statement, and the corresponding 'label' is the label jumped to if the match is satisfied.

b) the 'tableswitch' opcode has the form:

  tableswitch
  index1  : label1
  index2  : label2
  ...     : ...
  default : labelN     // comment

where the 'index' corresponds to the value in a  case  statement, and the corresponding 'label' is the label jumped to if the index is satisfied.

c) In addition to JVM opcodes, ClassCracker defines extra opcodes:

  try                   -  corresponds to  try { 
  endtry                -  corresponds to  }  /*endtry*/ 
  catch  exceptionType  -  corresponds to  catch( exceptionType e) { 
  finally               -  corresponds to  finally { 


Copyright © 2002 Mayon Enterprises Pty Ltd.