annotate src/clojure/asm/package.html @ 10:ef7dbbd6452c

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