]> gitweb.factorcode.org Git - factor.git/blob - org/objectweb/asm/package.html
new-guide is now devel-guide
[factor.git] / org / objectweb / asm / package.html
1 <html>
2 <!--
3  * ASM: a very small and fast Java bytecode manipulation framework
4  * Copyright (c) 2000,2002,2003 INRIA, France Telecom
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the copyright holders nor the names of its
16  *    contributors may be used to endorse or promote products derived from
17  *    this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29  * THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * Contact: Eric.Bruneton@rd.francetelecom.com
32  *
33  * Author: Eric Bruneton
34 -->
35 <body>
36 Provides a small and fast bytecode manipulation framework.
37
38 <p>
39 The <a href="http://www.objectweb.org/asm">ASM</a> framework is organized
40 around the {@link org.objectweb.asm.ClassVisitor ClassVisitor} and {@link
41 org.objectweb.asm.CodeVisitor CodeVisitor} interfaces, which allows one to
42 visit the fields and methods of a class, including the bytecode instructions of
43 each method.
44
45 <p>
46 In addition to these two main interfaces, ASM provides a {@link
47 org.objectweb.asm.ClassReader ClassReader} class, that can parse an
48 existing class and make a given visitor visit it. ASM also provides
49 a {@link org.objectweb.asm.ClassWriter ClassWriter} class, which is
50 a visitor that generates Java class files.
51
52 <p>
53 In order to generate a class from scratch, only the {@link
54 org.objectweb.asm.ClassWriter ClassWriter} class is necessary. Indeed,
55 in order to generate a class, one must just call its visit<i>XXX</i>
56 methods with the appropriate arguments to generate the desired fields
57 and methods. See the "helloworld" example in the ASM distribution for
58 more details about class generation.
59
60 <p>
61 In order to modify existing classes, one must use a {@link
62 org.objectweb.asm.ClassReader ClassReader} class to analyse
63 the original class, a class modifier, and a {@link org.objectweb.asm.ClassWriter
64 ClassWriter} to construct the modified class. The class modifier
65 is just a {@link org.objectweb.asm.ClassVisitor ClassVisitor}
66 that delegates most of the work to another {@link org.objectweb.asm.ClassVisitor
67 ClassVisitor}, but that sometimes changes some parameter values,
68 or call additional methods, in order to implement the desired
69 modification process. In order to make it easier to implement such
70 class modifiers, ASM provides the {@link org.objectweb.asm.ClassAdapter
71 ClassAdapter} and {@link org.objectweb.asm.CodeAdapter CodeAdapter}
72 classes, which implement the {@link org.objectweb.asm.ClassVisitor ClassVisitor} and
73 {@link org.objectweb.asm.CodeVisitor CodeVisitor} interfaces by delegating
74 all work to other visitors. See the "adapt" example in the ASM distribution
75 for more details about class modification.
76
77 <p>
78 The size of the core ASM library, <tt>asm.jar</tt>, is only 25KB, which is much
79 more smaller than
80 the size of the <a href="http://jakarta.apache.org/bcel">BCEL</a> library (350KB
81 without the class verifier), and than the size of the
82 <a href="http://serp.sourceforge.net">SERP</a> library (150KB). ASM is also
83 much more faster than these tools. Indeed the overhead of a load time class
84 transformation process is of the order of 60% with ASM, 700% or more with BCEL,
85 and 1100% or more with SERP (see the <tt>test/perf</tt> directory in the ASM
86 distribution)! kASM is a subset of ASM, for class generation only (it includes
87 the {@link org.objectweb.asm.ClassWriter ClassWriter}, but not the {@link
88 org.objectweb.asm.ClassReader ClassReader}). The size of this library,
89 <tt>kasm.jar</tt>, is only 16KB.
90
91 @since ASM 1.3
92 </body>
93 </html>