See: Description
Interface | Description |
---|---|
Opcodes |
Defines the JVM opcodes, access flags and array type codes.
|
Class | Description |
---|---|
AnnotationVisitor |
A visitor to visit a Java annotation.
|
Attribute |
A non standard class, field, method or code attribute.
|
ByteVector |
A dynamically extensible vector of bytes.
|
ClassReader |
A Java class parser to make a
ClassVisitor visit an existing class. |
ClassVisitor |
A visitor to visit a Java class.
|
ClassWriter |
A
ClassVisitor that generates classes in bytecode form. |
FieldVisitor |
A visitor to visit a Java field.
|
Handle |
A reference to a field or a method.
|
Label |
A label represents a position in the bytecode of a method.
|
MethodVisitor |
A visitor to visit a Java method.
|
Type |
A Java field or method type.
|
TypePath |
The path to a type argument, wildcard bound, array element type, or static
inner type within an enclosing type.
|
TypeReference |
A reference to a type appearing in a class, field or method declaration, or
on an instruction.
|
The ASM framework is organized
around the ClassVisitor
,
FieldVisitor
,
MethodVisitor
and
AnnotationVisitor
abstract classes,
which allow one to visit the fields, methods and annotations of a class,
including the bytecode instructions of each method.
In addition to these main abstract classes, ASM provides a ClassReader
class, that can parse an
existing class and make a given visitor visit it. ASM also provides
a ClassWriter
class, which is
a visitor that generates Java class files.
In order to generate a class from scratch, only the ClassWriter
class is necessary. Indeed,
in order to generate a class, one must just call its visitXxx
methods with the appropriate arguments to generate the desired fields
and methods. See the "helloworld" example in the ASM distribution for
more details about class generation.
In order to modify existing classes, one must use a ClassReader
class to analyze
the original class, a class modifier, and a ClassWriter
to construct the modified class. The class modifier
is just a ClassVisitor
that delegates most of the work to another ClassVisitor
, but that sometimes changes some parameter values,
or call additional methods, in order to implement the desired
modification process. In order to make it easier to implement such
class modifiers, the ClassVisitor
and MethodVisitor
classes delegate by default all the method calls they receive to an
optional visitor. See the "adapt" example in the ASM
distribution for more details about class modification.
The size of the core ASM library, asm.jar, is only 45KB, which is much smaller than the size of the BCEL library (504KB), and than the size of the SERP library (150KB). ASM is also much faster than these tools. Indeed the overhead of a load time class transformation process is of the order of 60% with ASM, 700% or more with BCEL, and 1100% or more with SERP (see the test/perf directory in the ASM distribution)!
Copyright © 2016 Oracle Corporation. All Rights Reserved.