This appendix is based on Jasmin Home Page
Copyright (c) Jonathan Meyer, 2004

.catch
.catch classname from label1 to label2 using label3

.catch java/io/IOException from L1 to L2 using IO_Handler
.catch all from L1 to L2 using ALL_Handler

This directive indicates that when an exception which is an instance of classname (or any exception for all keyword) or one of its subclasses is thrown while executing the code between label1 and label2, then the runtime system should jump to label3.
.class
.class [public | final | super | interface | abstract] my/package/example/ClassName

my/package/example/ClassName describes class ClassName in package my.package.example

Jasmin looks at the .class directive contained in the *.j file to decide where to place the output class file. It will create the my/package/example directories, if they do not exist and then create class ClassName.class.
.end
.end method

This directive is used to indicate the end of the method.

.method public myMethod()V
    ; method body
.end method
.fields
.field [public | private | protected | static | final | volatile | transient] fieldName type [= value]

.field public foo Ljava/lang/String;
.field public static final PI F = 3.14

This directive is used to define fields. The initial value (if present) must be an integer, a quoted string or a decimal number.
.implements
.implements MyInterface

After .source, .class and .super, you can list the interfaces that are implemented by the class you are defining.
.interface
.interface public foo/Bar

This directive can be used instead of .class directive. They both have the same syntax, but .interface directive indicates that the Jasmin file is defining a Java interface.
.limit
.limit stack 10
.limit locals 5

These directives can only be used inside .method block.
.limit stack sets the maximum size of the operand stack required by the method.
.limit locals sets the maximum number of local variables required by the method.
.line
.line integer

This directive can only be used within method definition. It is used to tag the subsequent instructions with a line number. Debuggers use this information together with the name of the source file (.source directive). to show at what line in a method things went wrong.

.method foo()
.line 3
    bipush 10
    istore_2
.line 4
...
.method
.method [public | private | protected | static | final | synchronized | native | abstract] methodName(arg1Type, arg2Type ...)returnType

.method public myMethod(Ljava/lang/String;)V
    ; method body
.end method

Method definitions can be put after all field definitions. Method definitions cannot be nested. Also, Jasmin does not insert an implicit 'return' instruction at the end of the method. It is up to you to ensure that your methods return cleanly.
.source
.source MyClass.j

The .source directive is optional. It specifies the value of the source file. It is used for debugging info. Note that the source file name should not include any pathname. If no .source directive is given, the name of the Jasmin file you are compiling is used instead.
.super
.super java/lang/Object

This directive tells the Java Virtual Machine the name of the superclass of the defined class.
.throws
.method public myMethod()V
    .throws java/io/IOException
    ...
.end method


This directive indicates that this method can throw exception described by the given class type. It can only be used inside method block.
.var
.var number is name type from label1 to label2

.var 0 is Count I from LabelA to LabelB

The .var directive is used to define the name, type descriptor and scope of a local variable number. This information is used by debuggers so that they can be more helpful when printing out the values of local variables (rather that printing just a local variable number, the debugger can actually print out the name of the variable).
This directive cannot be used outsibe .method block.