Mercurial > lasercutter
view 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 |
line wrap: on
line source
1 <html>2 <!--3 * ASM: a very small and fast Java bytecode manipulation framework4 * Copyright (c) 2000-2005 INRIA, France Telecom5 * All rights reserved.6 *7 * Redistribution and use in source and binary forms, with or without8 * modification, are permitted provided that the following conditions9 * are met:10 * 1. Redistributions of source code must retain the above copyright11 * notice, this list of conditions and the following disclaimer.12 * 2. Redistributions in binary form must reproduce the above copyright13 * notice, this list of conditions and the following disclaimer in the14 * documentation and/or other materials provided with the distribution.15 * 3. Neither the name of the copyright holders nor the names of its16 * contributors may be used to endorse or promote products derived from17 * 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, THE21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF29 * THE POSSIBILITY OF SUCH DAMAGE.30 -->31 <body>32 Provides a small and fast bytecode manipulation framework.34 <p>35 The <a href="http://www.objectweb.org/asm">ASM</a> framework is organized36 around the {@link clojure.asm.ClassVisitor ClassVisitor},37 {@link clojure.asm.FieldVisitor FieldVisitor} and38 {@link clojure.asm.MethodVisitor MethodVisitor} interfaces, which allow39 one to visit the fields and methods of a class, including the bytecode40 instructions of each method.42 <p>43 In addition to these main interfaces, ASM provides a {@link44 clojure.asm.ClassReader ClassReader} class, that can parse an45 existing class and make a given visitor visit it. ASM also provides46 a {@link clojure.asm.ClassWriter ClassWriter} class, which is47 a visitor that generates Java class files.49 <p>50 In order to generate a class from scratch, only the {@link51 clojure.asm.ClassWriter ClassWriter} class is necessary. Indeed,52 in order to generate a class, one must just call its visit<i>XXX</i>53 methods with the appropriate arguments to generate the desired fields54 and methods. See the "helloworld" example in the ASM distribution for55 more details about class generation.57 <p>58 In order to modify existing classes, one must use a {@link59 clojure.asm.ClassReader ClassReader} class to analyze60 the original class, a class modifier, and a {@link clojure.asm.ClassWriter61 ClassWriter} to construct the modified class. The class modifier62 is just a {@link clojure.asm.ClassVisitor ClassVisitor}63 that delegates most of the work to another {@link clojure.asm.ClassVisitor64 ClassVisitor}, but that sometimes changes some parameter values,65 or call additional methods, in order to implement the desired66 modification process. In order to make it easier to implement such67 class modifiers, ASM provides the {@link clojure.asm.ClassAdapter68 ClassAdapter} and {@link clojure.asm.MethodAdapter MethodAdapter}69 classes, which implement the {@link clojure.asm.ClassVisitor ClassVisitor}70 and {@link clojure.asm.MethodVisitor MethodVisitor} interfaces by71 delegating all work to other visitors. See the "adapt" example in the ASM72 distribution for more details about class modification.74 <p>75 The size of the core ASM library, <tt>asm.jar</tt>, is only 42KB, which is much76 smaller than the size of the77 <a href="http://jakarta.apache.org/bcel">BCEL</a> library (504KB), and than the78 size of the79 <a href="http://serp.sourceforge.net">SERP</a> library (150KB). ASM is also80 much faster than these tools. Indeed the overhead of a load time class81 transformation process is of the order of 60% with ASM, 700% or more with BCEL,82 and 1100% or more with SERP (see the <tt>test/perf</tt> directory in the ASM83 distribution)!85 @since ASM 1.386 </body>87 </html>