KOPI | ||
---|---|---|
Prev | Chapter 1. Classfile | Next |
The syntax was designed to be both readable and fully functional. The primary goal was to let the assembler (the classfile API) do as much job as possible. Thus you don't need to specify the maximum amount of stack used or the number of local variables since all this things are deductibles from the program to assemble. In the same spirit, the instructions opcodes are limited to the strict minimum and all the instructions defined to optimize a program (such as load_1) will be replaced by the assembler from generics instructions (from load 1).
The syntax looks like a normal java program for the members definition. Only the method body is describe in assembler. Some special informations found in classfile such as LineNumberTable, LocalVariableTable and attributes are also defined in the method body but all this informations are optional.
File .source source-file ClassOrInterface* The first parameter (optional) is the source file name from which the file was compiled. This information may be used by a debuger to retreive the corresponding source file. ClassOrInterface (public|protected|private|static|abstract|final)* (class|interface) [extends aType] [implements aType (, aType)*] aName { (Field|Method)* } The declarations of interfaces and classes are identicals. This declaration follows the standard java convention. A file may contain more than one class definition. Field (public|protected|private|static|final|native|synchronized|transcient|volatile)* aType aName [ = aValue] ; The declaration of a field is similar to Java one. aValue should by of type aType but this is not checked by the assembler. Method (public|protected|private|static|final|native|synchronized)* aType aName ([aType (, aType)*]) [throws aType (, aType)*] { ByteCodeInstruction* } The declarations of the interface of a method is similar to Java but the body is defined with a list of instruction. ByteCodeInstruction See the ksm-grammar for a full list of available instructions:
To launch ksm from the command line, type java at.dms.ksm.Main. The command line parameters are:
java at.dms.ksm.Main [dhV] file.ksm+ -d file (--destination) to select the output directory for classfiles -h (--help) to show the help -V (--version) to show the version number file the files to assemble
This tool allows you to see the code actually generated by your compiler and may help you to optimize or understand a portion of code. This tool may also help you to modify some classes from their bytecode in conjunction with ksm(to regenerate them).
To launch ksm from the command line, type:
java at.dms.dis.Main.The command line parameters are:
java at.dms.dis.Main [cdhisxV] (file.class | class)+ -c (--stdout) output to stdout instead of a ksm files -d file (--destination) to select the output directory for ksm files -h (--help) to show the help -i (--interface) to display only the interface of classes (remove method body) -s (--sorted) to sort members -x (--stack) to display the stack height in front of each instruction -V (--version) to show the version number file the files to disassemble (prefix must be .classfile) class a class (fully qualified name) accessible from the current classpath
Prev | Home | Next |
Bytecode optimizer | Up | KJC Kopi Java Compiler |