Symbolic constants

Except where noted, all symbolic constants are defined in the Trek class.

Access flags

An access flag is set for an object if the corresponding keyword is present in its declaration. For example, the ClassFile object for a class declared by public abstract class name would have ACC_PUBLIC and ACC_ABSTRACT set. The access flags that exist are:

  • ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED
  • ACC_STATIC, ACC_FINAL, ACC_ABSTRACT
  • ACC_SUPER, ACC_INTERFACE
  • ACC_SYNCHRONIZED, ACC_THREADSAFE, ACC_VOLATILE, ACC_TRANSIENT, ACC_NATIVE

Comparison operators

The comparison operator of a Call.doIf method may be:

  • DOIF_EQ – execute call being inserted if specified values are equal.
  • DOIF_NE – execute call being inserted if specified values are not equal.
  • DOIF_LT – execute call being inserted if the first value is less than the second value.
  • DOIF_GT – execute call being inserted if the first value is greater than the second value.
  • DOIF_LE – execute call being inserted if the first value is less than or equal to the second value.
  • DOIF_GE – execute call being inserted if the first value is greater than or equal to the second value.

Dump options

The options of the dump method are:

  • DUMP_ATTR – causes class and member attributes to be output
  • DUMP_INST – causes the JVM instructions of each method to be output
  • DUMP_POOL – causes the entries in the classfile’s constant pool to be output
  • DUMP_STMT – causes the source code of each method to be output. If only this flag is specified, the output file can be compiled if renamed from name.dmp to name.java.

Instruction opcodes

Opcodes are defined in the Code class. The name of an opcode is normally Code.its name in JVM spec, for example Code.iload. There are four exceptions though because of collisions with Java keywords. The names in these cases are Code.goto_, Code.instanceof_, Code.new_, and Code.return_.

Instruction types

The instructions in each type are listed in parenthesis. A * means any letters. For example *or means ior, lor, ixor, and lxor. T means a data type letter: a, d, f, i, or l.

  • IN_BINOP – does an operation on the top two items of the stack (*add, *sub, *mul, *div, *rem, *sh*, *and, *or, *cmp*).
  • IN_BRANCH – unconditionally branches to another instruction in its method (goto*)
  • IN_CALL – invokes another method (invoke*)
  • IN_DUP – duplicates item(s) on the top of the stack (dup*)
  • IN_IF – conditionally branches to another instructioin in its method (if*)
  • IN_LOADELEMENT – loads an array element onto the stack (Taload)
  • IN_LOADCONSTANT – loads a constant onto the stack (*const*, *ipush, ldc*)
  • IN_LOADFIELD – loads a field onto the stack (get*)
  • IN_LOADLOCAL – loads a local variable onto the stack (Tload*)
  • IN_NEW – creates a new array or a new object (*new*)
  • IN_RETURN – returns control to another method (*return, athrow)
  • IN_STOREELEMENT – stores a value into an array element (Tastore)
  • IN_STOREFIELD – stores a value into a field (put*)
  • IN_STORELOCAL – stores a value into a local variable (Tstore*)
  • IN_SWITCH – does a multi-target branch (*switch)
  • IN_UNOP – does an operation on the top item of the stack (*neg, *2*, arraylength)
  • IN_OTHER – all other instructions (iinc, jsr*, pop*, ret, swap, nop, monitor*, breakpoint, checkcast, instanceof).

Log item types

Log item types are defined in the RunLog class. RunLog.writeItem outputs a byte containing one of these types prior to writing the data item it was passed.

  • ITEM_BOOLEAN
  • ITEM_DOUBLE
  • ITEM_FLOAT
  • ITEM_INT
  • ITEM_LONG
  • ITEM_STRING a string is written to a data log using writeUTF.
  • ITEM_DATE – a date is represented in a data log as a long. So new Date(readLong()) could be used to access a date in a data log.
  • ITEM_SOURCE – available to subclassers of RunLog for use as the item type describing who is writing this log entry.
  • ITEM_EXTEND – if you define new item types, assign them types starting with this value.

Statement types

  • ST_CLINIT – the code in <clinit>, the method the Java compiler creates to initialize static fields.
  • ST_LOCAL – a statement that defines a local variable but does not initialize it.
  • ST_EMPTY – a statement consisting of only a semi-colon
  • ST_ASSIGN – an assignment statement
  • ST_BREAK, ST_CONTINUE, ST_RETURN, ST_THROW, and ST_CALL
  • ST_IF – if (boolean expression)
  • ST_THEN and ST_ENDTHEN –the { preceding and the } following the statements executed when an if statement is true. However they are omitted when the Then block contains only one statement.
  • ST_ELSE and ST_ENDELSE
  • ST_FOR and ST_ENDFOR
  • ST_WHILE and ST_ENDWHILE
  • ST_DO and ST_ENDDO
  • ST_SWITCH and ST_ENDSWITCH – switch (key) { and the } at the end of all its cases.
  • ST_CASE – a statement consisting of case value: or default:
  • ST_TRY and ST_ENDTRY
  • ST_CATCH and ST_ENDCATCH
  • ST_FINALLY and ST_ENDFINALLY
  • ST_LABEL and ST_ENDLABEL – these statements consist of name: { and } respectively
  • ST_SYNC and ST_ENDSYNC – a synchronize statement and the } following a synchronized block.

The convenience symbols for accessing multiple types of statements at once are:

  • ST_SEMI – only the statement types that end in a semi-colon have a value <= to this symbol.
  • ST_END – only the statement types that end a block have a value >= to this symbol.
  • ST_ENDBREAKABLE – only the types that end break-able blocks have a value >= to this symbol.
  • ST_ENDLOOP – only the types that end loops have a value >= to this symbol.