| Jasml Syntax
In JASML, attributes are enclosed between '[' and ']', the following attributes are supported:
Besides, the Exceptions attribute are not enclosed with "[" and "]", but are defined in throws clause of the method declaration. And the ConstantValue attribute are part of the field declaration.
Besides, the exception_table,max_stack,max_locals structure of Code attribute are also enclosed between '[' and ']'.
These two attributes are simply :[Synthetic]
SourceFile attribute should be in the format of "[SourceFile : filename]". Generally, the filename is only the name without the parth, but a filename with path in it is also supported.
Code attribute is composed of labels and macro instructions. Label names must be valid java names, and can not be the same with any of the macro instruction names.
When generating .jasm files, for each instruction which is referred elsewhere in the method(the brach instructions, LocalVariableTable etc.), a label is inserted before the instruction. The label is named as lable[line number]. When naming your own labels, you dose not need to follow this rule, only remember that the label name must be unique in the the method.
The Code attribute also has exception_table,max_stack,max_locals structure and it's own attributes, these should be defined as different attributes in the same method where this code attribute is located.
max_stack and max_locals are part of Code attribute, but they should be defined separately as attribute in the same method where the Code attribute is located, such that:
exception_table is part of the code attribute, but should be defined separately as attribute in the same method where the code attribute is located.
exception_table attribute must start with "[Exceptions:", and followed by exception_table entries, then end with "]".
Each exception_table entry in the .class file has the structure like :
Each entry maps to a line in exception_table attribute, such that:
start=start_label , end=end_label , handler=handler_label , catch_type=exception_type
These label must have aready been defined in the insctructions, and each entry can only, and must, occupy one line.
InnerClass attribute must start with "[InnerClasses:", followed by innter class entries, then end with "]".
Each inner class are defined such that:
access = inner class access flags , name = inner class name(without the package name) , fullname = fully qualfied inner class name(outername+"$"+name) , outername = fully qualified outer class name with the package name
Each Inner class entry can only, and must, occupy one line.
When generating .jasm files, with the "-l" option, line number will be outputed.
LineNumberTable attribute must start with "[LineNumber:", followed by line number mappings, then end with "]".
labelname -> lineNumber
This lineNumber is the line number of the source .java files, when compiling from .jasm to .class, lineNumbers will be ignored.
Each local variable entry in the .class file are of such a structure:
Each entry maps to a line in LocalVariableTable attribute, such that:
localvariable-type localvariable-name start=start_label, end=end_label, index=index_number
For example, an int local variable may be defined as
int c start=line0, end=line3, index=1
And for each instance method, there must be an local variable named "this", of the same type to which this method is belongs, and of index 0.
For example, for each instance method in testpackage.SimpleClass, there must be such an local variable entry defined:
testpackage.SimpleClass this start=line_start, end=line_end, index=0
The labels referred here must have aready been defined in the insctructions, and each entry can only, and must, occupy one line.
Note: LocalVariableTable is not a necessary attribute. Some compilers even do not generate a LocalVariableTable in .class files, e.g. the jdk 1.4.2_11.
Also, remember if a local variable is of type double or long, it must occupy two index. Although this is out of the scope of this document, but most people often forget this.
Copyright 2006 - Jiang Yang , All Rights Reserved