proxool-cvs Mailing List for Proxool: Proxy JDBC Connection Pool (Page 7)
UNMAINTAINED!
Brought to you by:
billhorsman
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(12) |
Feb
(17) |
Mar
(20) |
Apr
(22) |
May
(4) |
Jun
(3) |
Jul
(11) |
Aug
(23) |
Sep
(60) |
Oct
(41) |
Nov
(15) |
Dec
(29) |
2004 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(5) |
Jun
(29) |
Jul
(6) |
Aug
(1) |
Sep
(2) |
Oct
|
Nov
|
Dec
|
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(8) |
Jun
|
Jul
(1) |
Aug
|
Sep
(8) |
Oct
(19) |
Nov
|
Dec
|
2006 |
Jan
(17) |
Feb
|
Mar
(5) |
Apr
(1) |
May
(2) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2007 |
Jan
(9) |
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
(4) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <bil...@us...> - 2003-12-12 19:20:46
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/cglib/reflect In directory sc8-pr-cvs1:/tmp/cvs-serv24125/src/java/org/logicalcobwebs/cglib/reflect Log Message: Directory /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/cglib/reflect added to the repository |
From: <bil...@us...> - 2003-12-12 19:19:31
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/cglib/proxy In directory sc8-pr-cvs1:/tmp/cvs-serv23762/src/java/org/logicalcobwebs/cglib/proxy Log Message: Directory /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/cglib/proxy added to the repository |
From: <bil...@us...> - 2003-12-12 19:17:52
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/cglib/core In directory sc8-pr-cvs1:/tmp/cvs-serv23373/src/java/org/logicalcobwebs/cglib/core Log Message: Directory /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/cglib/core added to the repository |
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/asm In directory sc8-pr-cvs1:/tmp/cvs-serv22981/src/java/org/logicalcobwebs/asm Added Files: Attribute.java ByteVector.java ClassAdapter.java ClassReader.java ClassVisitor.java ClassWriter.java CodeAdapter.java CodeVisitor.java CodeWriter.java Constants.java Edge.java Item.java Label.java Type.java package.html Log Message: Repackaged ASM project --- NEW FILE: Attribute.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm; /** * A non standard class, field, method or code attribute. */ public class Attribute { /** * The type of this attribute. */ public String type; /** * The byte array that contains the value of this attribute. <i>The content of * this array must not be modified, although the array itself can be changed * (i.e. attr.b[...] = ...; is forbidden, but attr.b = ...; is allowed)</i>. */ public byte[] b; /** * Index of the first byte of this attribute in {@link #b b}. */ public int off; /** * Length of this attributes, in bytes. */ public int len; /** * The next attribute in this attribute list. May be <tt>null</tt>. */ public Attribute next; /** * Constructs a new {@link Attribute}. * * @param type the type of the attribute. * @param b byte array that contains the value of the attribute. * @param off index of the first byte of the attribute in <tt>b</tt>. * @param len length of the attributes, in bytes. */ public Attribute ( final String type, final byte[] b, final int off, final int len) { this.type = type; this.b = b; this.off = off; this.len = len; } /** * Constructs a new empty attribute. * * @param type the type of the attribute. */ public Attribute (final String type) { this(type, null, 0, 0); } /** * Returns the length of the attribute list that begins with this attribute. * * @return the length of the attribute list that begins with this attribute. */ final int getCount () { int count = 0; Attribute attr = this; while (attr != null) { count += 1; attr = attr.next; } return count; } /** * Returns the size of all the attributes in this attribute list. * * @param cw the class writer to be used to convert the attributes into byte * arrays, with the {@link ClassWriter#writeAttribute writeAttribute} * method. * @return the size of all the attributes in this attribute list. This size * includes the size of the attribute headers. */ final int getSize (final ClassWriter cw) { int size = 0; Attribute attr = this; while (attr != null) { cw.newUTF8(attr.type); size += cw.writeAttribute(attr).length + 6; attr = attr.next; } return size; } /** * Writes all the attributes of this attribute list in the given byte vector. * * @param cw the class writer to be used to convert the attributes into byte * arrays, with the {@link ClassWriter#writeAttribute writeAttribute} * method. * @param out where the attributes must be written. */ final void put (final ClassWriter cw, final ByteVector out) { Attribute attr = this; while (attr != null) { byte[] b = cw.writeAttribute(attr); out.put2(cw.newUTF8(attr.type)).put4(b.length); out.putByteArray(b, 0, b.length); attr = attr.next; } } } --- NEW FILE: ByteVector.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm; /** * A dynamically extensible vector of bytes. This class is roughly equivalent to * a DataOutputStream on top of a ByteArrayOutputStream, but is more efficient. */ final class ByteVector { /** * The content of this vector. */ byte[] data; /** * Actual number of bytes in this vector. */ int length; /** * Constructs a new {@link ByteVector ByteVector} with a default initial size. */ public ByteVector () { data = new byte[64]; } /** * Constructs a new {@link ByteVector ByteVector} with the given initial size. * * @param initialSize the initial size of the byte vector to be constructed. */ public ByteVector (final int initialSize) { data = new byte[initialSize]; } /** * Puts a byte into this byte vector. The byte vector is automatically * enlarged if necessary. * * @param b a byte. * @return this byte vector. */ public ByteVector put1 (final int b) { int length = this.length; if (length + 1 > data.length) { enlarge(1); } data[length++] = (byte)b; this.length = length; return this; } /** * Puts two bytes into this byte vector. The byte vector is automatically * enlarged if necessary. * * @param b1 a byte. * @param b2 another byte. * @return this byte vector. */ public ByteVector put11 (final int b1, final int b2) { int length = this.length; if (length + 2 > data.length) { enlarge(2); } byte[] data = this.data; data[length++] = (byte)b1; data[length++] = (byte)b2; this.length = length; return this; } /** * Puts a short into this byte vector. The byte vector is automatically * enlarged if necessary. * * @param s a short. * @return this byte vector. */ public ByteVector put2 (final int s) { int length = this.length; if (length + 2 > data.length) { enlarge(2); } byte[] data = this.data; data[length++] = (byte)(s >>> 8); data[length++] = (byte)s; this.length = length; return this; } /** * Puts a byte and a short into this byte vector. The byte vector is * automatically enlarged if necessary. * * @param b a byte. * @param s a short. * @return this byte vector. */ public ByteVector put12 (final int b, final int s) { int length = this.length; if (length + 3 > data.length) { enlarge(3); } byte[] data = this.data; data[length++] = (byte)b; data[length++] = (byte)(s >>> 8); data[length++] = (byte)s; this.length = length; return this; } /** * Puts an int into this byte vector. The byte vector is automatically * enlarged if necessary. * * @param i an int. * @return this byte vector. */ public ByteVector put4 (final int i) { int length = this.length; if (length + 4 > data.length) { enlarge(4); } byte[] data = this.data; data[length++] = (byte)(i >>> 24); data[length++] = (byte)(i >>> 16); data[length++] = (byte)(i >>> 8); data[length++] = (byte)i; this.length = length; return this; } /** * Puts a long into this byte vector. The byte vector is automatically * enlarged if necessary. * * @param l a long. * @return this byte vector. */ public ByteVector put8 (final long l) { int length = this.length; if (length + 8 > data.length) { enlarge(8); } byte[] data = this.data; int i = (int)(l >>> 32); data[length++] = (byte)(i >>> 24); data[length++] = (byte)(i >>> 16); data[length++] = (byte)(i >>> 8); data[length++] = (byte)i; i = (int)l; data[length++] = (byte)(i >>> 24); data[length++] = (byte)(i >>> 16); data[length++] = (byte)(i >>> 8); data[length++] = (byte)i; this.length = length; return this; } /** * Puts a String in UTF format into this byte vector. The byte vector is * automatically enlarged if necessary. * * @param s a String. * @return this byte vector. */ public ByteVector putUTF (final String s) { int charLength = s.length(); int byteLength = 0; for (int i = 0; i < charLength; ++i) { char c = s.charAt(i); if (c >= '\001' && c <= '\177') { byteLength++; } else if (c > '\u07FF') { byteLength += 3; } else { byteLength += 2; } } if (byteLength > 65535) { throw new IllegalArgumentException(); } int length = this.length; if (length + 2 + byteLength > data.length) { enlarge(2 + byteLength); } byte[] data = this.data; data[length++] = (byte)(byteLength >>> 8); data[length++] = (byte)(byteLength); for (int i = 0; i < charLength; ++i) { char c = s.charAt(i); if (c >= '\001' && c <= '\177') { data[length++] = (byte)c; } else if (c > '\u07FF') { data[length++] = (byte)(0xE0 | c >> 12 & 0xF); data[length++] = (byte)(0x80 | c >> 6 & 0x3F); data[length++] = (byte)(0x80 | c & 0x3F); } else { data[length++] = (byte)(0xC0 | c >> 6 & 0x1F); data[length++] = (byte)(0x80 | c & 0x3F); } } this.length = length; return this; } /** * Puts an array of bytes into this byte vector. The byte vector is * automatically enlarged if necessary. * * @param b an array of bytes. May be <tt>null</tt> to put <tt>len</tt> null * bytes into this byte vector. * @param off index of the fist byte of b that must be copied. * @param len number of bytes of b that must be copied. * @return this byte vector. */ public ByteVector putByteArray ( final byte[] b, final int off, final int len) { if (length + len > data.length) { enlarge(len); } if (b != null) { System.arraycopy(b, off, data, length, len); } length += len; return this; } /** * Enlarge this byte vector so that it can receive n more bytes. * * @param size number of additional bytes that this byte vector should be * able to receive. */ private void enlarge (final int size) { int length1 = 2 * data.length; int length2 = length + size; byte[] newData = new byte[length1 > length2 ? length1 : length2]; System.arraycopy(data, 0, newData, 0, length); data = newData; } } --- NEW FILE: ClassAdapter.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm; /** * An empty {@link ClassVisitor ClassVisitor} that delegates to another {@link * ClassVisitor ClassVisitor}. This class can be used as a super class to * quickly implement usefull class adapter classes, just by overriding the * necessary methods. */ public class ClassAdapter implements ClassVisitor { /** * The {@link ClassVisitor ClassVisitor} to which this adapter delegates * calls. */ protected ClassVisitor cv; /** * Constructs a new {@link ClassAdapter ClassAdapter} object. * * @param cv the class visitor to which this adapter must delegate calls. */ public ClassAdapter (final ClassVisitor cv) { this.cv = cv; } public void visit ( final int access, final String name, final String superName, final String[] interfaces, final String sourceFile) { cv.visit(access, name, superName, interfaces, sourceFile); } public void visitInnerClass ( final String name, final String outerName, final String innerName, final int access) { cv.visitInnerClass(name, outerName, innerName, access); } public void visitField ( final int access, final String name, final String desc, final Object value, final Attribute attrs) { cv.visitField(access, name, desc, value, attrs); } public CodeVisitor visitMethod ( final int access, final String name, final String desc, final String[] exceptions, final Attribute attrs) { return new CodeAdapter(cv.visitMethod(access, name, desc, exceptions, attrs)); } public void visitAttribute (final Attribute attr) { cv.visitAttribute(attr); } public void visitEnd () { cv.visitEnd(); } } --- NEW FILE: ClassReader.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm; import java.io.InputStream; import java.io.IOException; /** * A Java class parser to make a {@link ClassVisitor ClassVisitor} visit an * existing class. This class parses a byte array conforming to the Java class * file format and calls the appropriate visit methods of a given class visitor * for each field, method and bytecode instruction encountered. */ public class ClassReader { /** * The class to be parsed. <i>The content of this array must not be * modified.</i> */ protected final byte[] b; /** * The start index of each constant pool item in {@link #b b}, plus one. The * one byte offset skips the constant pool item tag that indicates its type. */ private int[] items; /** * The String objects corresponding to the CONSTANT_Utf8 items. This cache * avoids multiple parsing of a given CONSTANT_Utf8 constant pool item, which * GREATLY improves performances (by a factor 2 to 3). This caching strategy * could be extended to all constant pool items, but its benefit would not be * so great for these items (because they are much less expensive to parse * than CONSTANT_Utf8 items). */ private String[] strings; /** * Maximum length of the strings contained in the constant pool of the class. */ private int maxStringLength; /** * Start index of the class header information (access, name...) in {@link #b * b}. */ private int header; // -------------------------------------------------------------------------- // Constructors // -------------------------------------------------------------------------- /** * Constructs a new {@link ClassReader ClassReader} object. * * @param b the bytecode of the class to be read. */ public ClassReader (final byte[] b) { this(b, 0, b.length); } /** * Constructs a new {@link ClassReader ClassReader} object. * * @param b the bytecode of the class to be read. * @param off the start offset of the class data. * @param len the length of the class data. */ public ClassReader (final byte[] b, final int off, final int len) { this.b = b; // parses the constant pool items = new int[readUnsignedShort(off + 8)]; strings = new String[items.length]; int max = 0; int index = off + 10; for (int i = 1; i < items.length; ++i) { items[i] = index + 1; int tag = b[index]; int size; switch (tag) { case ClassWriter.FIELD: case ClassWriter.METH: case ClassWriter.IMETH: case ClassWriter.INT: case ClassWriter.FLOAT: case ClassWriter.NAME_TYPE: size = 5; break; case ClassWriter.LONG: case ClassWriter.DOUBLE: size = 9; ++i; break; case ClassWriter.UTF8: size = 3 + readUnsignedShort(index + 1); max = (size > max ? size : max); break; //case ClassWriter.CLASS: //case ClassWriter.STR: default: size = 3; break; } index += size; } maxStringLength = max; // the class header information starts just after the constant pool header = index; } /** * Constructs a new {@link ClassReader ClassReader} object. * * @param is an input stream from which to read the class. * @throws IOException if a problem occurs during reading. */ public ClassReader (final InputStream is) throws IOException { this(readClass(is)); } /** * Constructs a new {@link ClassReader ClassReader} object. * * @param name the fully qualified name of the class to be read. * @throws IOException if an exception occurs during reading. */ public ClassReader (final String name) throws IOException { this((ClassReader.class.getClassLoader() == null ? ClassLoader.getSystemClassLoader() : ClassReader.class.getClassLoader()) .getSystemResourceAsStream(name.replace('.','/') + ".class")); } /** * Reads the bytecode of a class. * * @param is an input stream from which to read the class. * @return the bytecode read from the given input stream. * @throws IOException if a problem occurs during reading. */ private static byte[] readClass (final InputStream is) throws IOException { if (is == null) { throw new IOException("Class not found"); } byte[] b = new byte[is.available()]; int len = 0; while (true) { int n = is.read(b, len, b.length - len); if (n == -1) { if (len < b.length) { byte[] c = new byte[len]; System.arraycopy(b, 0, c, 0, len); b = c; } return b; } else { len += n; if (len == b.length) { byte[] c = new byte[b.length + 1000]; System.arraycopy(b, 0, c, 0, len); b = c; } } } } // -------------------------------------------------------------------------- // Public methods // -------------------------------------------------------------------------- /** * Makes the given visitor visit the Java class of this {@link ClassReader * ClassReader}. This class is the one specified in the constructor (see * {@link #ClassReader ClassReader}). * * @param classVisitor the visitor that must visit this class. * @param skipDebug <tt>true</tt> if the debug information of the class must * not be visited. In this case the {@link CodeVisitor#visitLocalVariable * visitLocalVariable} and {@link CodeVisitor#visitLineNumber * visitLineNumber} methods will not be called. */ public void accept ( final ClassVisitor classVisitor, final boolean skipDebug) { byte[] b = this.b; // the bytecode array char[] c = new char[maxStringLength]; // buffer used to read strings int i, j, k; // loop variables int u, v, w; // indexes in b Attribute attr; // visits the header u = header; int access = readUnsignedShort(u); String className = readClass(u + 2, c); v = items[readUnsignedShort(u + 4)]; String superClassName = v == 0 ? null : readUTF8(v, c); String[] implementedItfs = new String[readUnsignedShort(u + 6)]; String sourceFile = null; Attribute clattrs = null; w = 0; u += 8; for (i = 0; i < implementedItfs.length; ++i) { implementedItfs[i] = readClass(u, c); u += 2; } // skips fields and methods v = u; i = readUnsignedShort(v); v += 2; for ( ; i > 0; --i) { j = readUnsignedShort(v + 6); v += 8; for ( ; j > 0; --j) { v += 6 + readInt(v + 2); } } i = readUnsignedShort(v); v += 2; for ( ; i > 0; --i) { j = readUnsignedShort(v + 6); v += 8; for ( ; j > 0; --j) { v += 6 + readInt(v + 2); } } // reads the class's attributes i = readUnsignedShort(v); v += 2; for ( ; i > 0; --i) { String attrName = readUTF8(v, c); if (attrName.equals("SourceFile")) { sourceFile = readUTF8(v + 6, c); } else if (attrName.equals("Deprecated")) { access |= Constants.ACC_DEPRECATED; } else if (attrName.equals("InnerClasses")) { w = v + 6; } else { attr = readAttribute(attrName, v + 6, readInt(v + 2), c); attr.next = clattrs; clattrs = attr; } v += 6 + readInt(v + 2); } // calls the visit method classVisitor.visit( access, className, superClassName, implementedItfs, sourceFile); // visits the inner classes info if (w != 0) { i = readUnsignedShort(w); w += 2; for ( ; i > 0; --i) { classVisitor.visitInnerClass( readUnsignedShort(w) == 0 ? null : readClass(w, c), readUnsignedShort(w + 2) == 0 ? null : readClass(w + 2, c), readUnsignedShort(w + 4) == 0 ? null : readUTF8(w + 4, c), readUnsignedShort(w + 6)); w += 8; } } // visits the fields i = readUnsignedShort(u); u += 2; for ( ; i > 0; --i) { access = readUnsignedShort(u); String fieldName = readUTF8(u + 2, c); String fieldDesc = readUTF8(u + 4, c); Attribute fattrs = null; // visits the field's attributes and looks for a ConstantValue attribute int fieldValueItem = 0; j = readUnsignedShort(u + 6); u += 8; for ( ; j > 0; --j) { String attrName = readUTF8(u, c); if (attrName.equals("ConstantValue")) { fieldValueItem = readUnsignedShort(u + 6); } else if (attrName.equals("Synthetic")) { access |= Constants.ACC_SYNTHETIC; } else if (attrName.equals("Deprecated")) { access |= Constants.ACC_DEPRECATED; } else { attr = readAttribute(attrName, u + 6, readInt(u + 2), c); attr.next = fattrs; fattrs = attr; } u += 6 + readInt(u + 2); } // reads the field's value, if any Object value = (fieldValueItem == 0 ? null : readConst(fieldValueItem, c)); // visits the field classVisitor.visitField(access, fieldName, fieldDesc, value, fattrs); } // visits the methods i = readUnsignedShort(u); u += 2; for ( ; i > 0; --i) { access = readUnsignedShort(u); String methName = readUTF8(u + 2, c); String methDesc = readUTF8(u + 4, c); Attribute mattrs = null; v = 0; w = 0; // looks for Code and Exceptions attributes j = readUnsignedShort(u + 6); u += 8; for ( ; j > 0; --j) { String attrName = readUTF8(u, c); u += 2; int attrSize = readInt(u); u += 4; if (attrName.equals("Code")) { v = u; } else if (attrName.equals("Exceptions")) { w = u; } else if (attrName.equals("Synthetic")) { access |= Constants.ACC_SYNTHETIC; } else if (attrName.equals("Deprecated")) { access |= Constants.ACC_DEPRECATED; } else { attr = readAttribute(attrName, u, attrSize, c); attr.next = mattrs; mattrs = attr; } u += attrSize; } // reads declared exceptions String[] exceptions; if (w == 0) { exceptions = null; } else { exceptions = new String[readUnsignedShort(w)]; w += 2; for (j = 0; j < exceptions.length; ++j) { exceptions[j] = readClass(w, c); w += 2; } } // visits the method's code, if any CodeVisitor cv; cv = classVisitor.visitMethod( access, methName, methDesc, exceptions, mattrs); if (cv != null && v != 0) { int maxStack = readUnsignedShort(v); int maxLocals = readUnsignedShort(v + 2); int codeLength = readInt(v + 4); Attribute cattrs = null; v += 8; int codeStart = v; int codeEnd = v + codeLength; // 1st phase: finds the labels int label; Label[] labels = new Label[codeLength + 1]; while (v < codeEnd) { int opcode = b[v] & 0xFF; switch (ClassWriter.TYPE[opcode]) { case ClassWriter.NOARG_INSN: case ClassWriter.IMPLVAR_INSN: v += 1; break; case ClassWriter.LABEL_INSN: label = v - codeStart + readShort(v + 1); if (labels[label] == null) { labels[label] = new Label(); } v += 3; break; case ClassWriter.LABELW_INSN: label = v - codeStart + readInt(v + 1); if (labels[label] == null) { labels[label] = new Label(); } v += 5; break; case ClassWriter.WIDE_INSN: opcode = b[v + 1] & 0xFF; if (opcode == Constants.IINC) { v += 6; } else { v += 4; } break; case ClassWriter.TABL_INSN: // skips 0 to 3 padding bytes w = v - codeStart; v = v + 4 - (w & 3); // reads instruction label = w + readInt(v); v += 4; if (labels[label] == null) { labels[label] = new Label(); } j = readInt(v); v += 4; j = readInt(v) - j + 1; v += 4; for ( ; j > 0; --j) { label = w + readInt(v); v += 4; if (labels[label] == null) { labels[label] = new Label(); } } break; case ClassWriter.LOOK_INSN: // skips 0 to 3 padding bytes w = v - codeStart; v = v + 4 - (w & 3); // reads instruction label = w + readInt(v); v += 4; if (labels[label] == null) { labels[label] = new Label(); } j = readInt(v); v += 4; for ( ; j > 0; --j) { v += 4; // skips key label = w + readInt(v); v += 4; if (labels[label] == null) { labels[label] = new Label(); } } break; case ClassWriter.VAR_INSN: case ClassWriter.SBYTE_INSN: case ClassWriter.LDC_INSN: v += 2; break; case ClassWriter.SHORT_INSN: case ClassWriter.LDCW_INSN: case ClassWriter.FIELDORMETH_INSN: case ClassWriter.TYPE_INSN: case ClassWriter.IINC_INSN: v += 3; break; case ClassWriter.ITFMETH_INSN: v += 5; break; // case MANA_INSN: default: v += 4; break; } } // parses the try catch entries j = readUnsignedShort(v); v += 2; for ( ; j > 0; --j) { label = readUnsignedShort(v); if (labels[label] == null) { labels[label] = new Label(); } label = readUnsignedShort(v + 2); if (labels[label] == null) { labels[label] = new Label(); } label = readUnsignedShort(v + 4); if (labels[label] == null) { labels[label] = new Label(); } v += 8; } if (!skipDebug) { // parses the local variable and line number tables j = readUnsignedShort(v); v += 2; for ( ; j > 0; --j) { String attrName = readUTF8(v, c); if (attrName.equals("LocalVariableTable")) { k = readUnsignedShort(v + 6); w = v + 8; for ( ; k > 0; --k) { label = readUnsignedShort(w); if (labels[label] == null) { labels[label] = new Label(); } label += readUnsignedShort(w + 2); if (labels[label] == null) { labels[label] = new Label(); } w += 10; } } else if (attrName.equals("LineNumberTable")) { k = readUnsignedShort(v + 6); w = v + 8; for ( ; k > 0; --k) { label = readUnsignedShort(w); if (labels[label] == null) { labels[label] = new Label(); } w += 4; } } else { attr = readAttribute(attrName, v + 6, readInt(v + 2), c); attr.next = cattrs; cattrs = attr; } v += 6 + readInt(v + 2); } } // 2nd phase: visits each instruction v = codeStart; Label l; while (v < codeEnd) { w = v - codeStart; l = labels[w]; if (l != null) { cv.visitLabel(l); } int opcode = b[v] & 0xFF; switch (ClassWriter.TYPE[opcode]) { case ClassWriter.NOARG_INSN: cv.visitInsn(opcode); v += 1; break; case ClassWriter.IMPLVAR_INSN: if (opcode > Constants.ISTORE) { opcode -= 59; //ISTORE_0 cv.visitVarInsn(Constants.ISTORE + (opcode >> 2), opcode & 0x3); } else { opcode -= 26; //ILOAD_0 cv.visitVarInsn(Constants.ILOAD + (opcode >> 2), opcode & 0x3); } v += 1; break; case ClassWriter.LABEL_INSN: cv.visitJumpInsn(opcode, labels[w + readShort(v + 1)]); v += 3; break; case ClassWriter.LABELW_INSN: cv.visitJumpInsn(opcode, labels[w + readInt(v + 1)]); v += 5; break; case ClassWriter.WIDE_INSN: opcode = b[v + 1] & 0xFF; if (opcode == Constants.IINC) { cv.visitIincInsn(readUnsignedShort(v + 2), readShort(v + 4)); v += 6; } else { cv.visitVarInsn(opcode, readUnsignedShort(v + 2)); v += 4; } break; case ClassWriter.TABL_INSN: // skips 0 to 3 padding bytes v = v + 4 - (w & 3); // reads instruction label = w + readInt(v); v += 4; int min = readInt(v); v += 4; int max = readInt(v); v += 4; Label[] table = new Label[max - min + 1]; for (j = 0; j < table.length; ++j) { table[j] = labels[w + readInt(v)]; v += 4; } cv.visitTableSwitchInsn(min, max, labels[label], table); break; case ClassWriter.LOOK_INSN: // skips 0 to 3 padding bytes v = v + 4 - (w & 3); // reads instruction label = w + readInt(v); v += 4; j = readInt(v); v += 4; int[] keys = new int[j]; Label[] values = new Label[j]; for (j = 0; j < keys.length; ++j) { keys[j] = readInt(v); v += 4; values[j] = labels[w + readInt(v)]; v += 4; } cv.visitLookupSwitchInsn(labels[label], keys, values); break; case ClassWriter.VAR_INSN: cv.visitVarInsn(opcode, b[v + 1] & 0xFF); v += 2; break; case ClassWriter.SBYTE_INSN: cv.visitIntInsn(opcode, b[v + 1]); v += 2; break; case ClassWriter.SHORT_INSN: cv.visitIntInsn(opcode, readShort(v + 1)); v += 3; break; case ClassWriter.LDC_INSN: cv.visitLdcInsn(readConst(b[v + 1] & 0xFF, c)); v += 2; break; case ClassWriter.LDCW_INSN: cv.visitLdcInsn(readConst(readUnsignedShort(v + 1), c)); v += 3; break; case ClassWriter.FIELDORMETH_INSN: case ClassWriter.ITFMETH_INSN: int cpIndex = items[readUnsignedShort(v + 1)]; String iowner = readClass(cpIndex, c); cpIndex = items[readUnsignedShort(cpIndex + 2)]; String iname = readUTF8(cpIndex, c); String idesc = readUTF8(cpIndex + 2, c); if (opcode < Constants.INVOKEVIRTUAL) { cv.visitFieldInsn(opcode, iowner, iname, idesc); } else { cv.visitMethodInsn(opcode, iowner, iname, idesc); } if (opcode == Constants.INVOKEINTERFACE) { v += 5; } else { v += 3; } break; case ClassWriter.TYPE_INSN: cv.visitTypeInsn(opcode, readClass(v + 1, c)); v += 3; break; case ClassWriter.IINC_INSN: cv.visitIincInsn(b[v + 1] & 0xFF, b[v + 2]); v += 3; break; // case MANA_INSN: default: cv.visitMultiANewArrayInsn(readClass(v + 1, c), b[v + 3] & 0xFF); v += 4; break; } } l = labels[codeEnd - codeStart]; if (l != null) { cv.visitLabel(l); } // visits the try catch entries j = readUnsignedShort(v); v += 2; for ( ; j > 0; --j) { Label start = labels[readUnsignedShort(v)]; Label end = labels[readUnsignedShort(v + 2)]; Label handler = labels[readUnsignedShort(v + 4)]; int type = readUnsignedShort(v + 6); if (type == 0) { cv.visitTryCatchBlock(start, end, handler, null); } else { cv.visitTryCatchBlock(start, end, handler, readUTF8(items[type], c)); } v += 8; } if (!skipDebug) { // visits the local variable and line number tables j = readUnsignedShort(v); v += 2; for ( ; j > 0; --j) { String attrName = readUTF8(v, c); if (attrName.equals("LocalVariableTable")) { k = readUnsignedShort(v + 6); w = v + 8; for ( ; k > 0; --k) { label = readUnsignedShort(w); Label start = labels[label]; label += readUnsignedShort(w + 2); Label end = labels[label]; cv.visitLocalVariable( readUTF8(w + 4, c), readUTF8(w + 6, c), start, end, readUnsignedShort(w + 8)); w += 10; } } else if (attrName.equals("LineNumberTable")) { k = readUnsignedShort(v + 6); w = v + 8; for ( ; k > 0; --k) { cv.visitLineNumber( readUnsignedShort(w + 2), labels[readUnsignedShort(w)]); w += 4; } } v += 6 + readInt(v + 2); } } // visits the code attributes while (cattrs != null) { cv.visitAttribute(cattrs); cattrs = cattrs.next; } // visits the max stack and max locals values cv.visitMaxs(maxStack, maxLocals); } } // visits the class attributes while (clattrs != null) { classVisitor.visitAttribute(clattrs); clattrs = clattrs.next; } // visits the end of the class classVisitor.visitEnd(); } // -------------------------------------------------------------------------- // Utility methods: low level parsing // -------------------------------------------------------------------------- /** * Reads an unsigned short value in {@link #b b}. * * @param index the start index of the value to be read in {@link #b b}. * @return the read value. */ protected int readUnsignedShort (final int index) { byte[] b = this.b; return ((b[index] & 0xFF) << 8) | (b[index + 1] & 0xFF); } /** * Reads a signed short value in {@link #b b}. * * @param index the start index of the value to be read in {@link #b b}. * @return the read value. */ protected short readShort (final int index) { byte[] b = this.b; return (short)(((b[index] & 0xFF) << 8) | (b[index + 1] & 0xFF)); } /** * Reads a signed int value in {@link #b b}. * * @param index the start index of the value to be read in {@link #b b}. * @return the read value. */ protected int readInt (final int index) { byte[] b = this.b; return ((b[index] & 0xFF) << 24) | ((b[index + 1] & 0xFF) << 16) | ((b[index + 2] & 0xFF) << 8) | (b[index + 3] & 0xFF); } /** * Reads a signed long value in {@link #b b}. * * @param index the start index of the value to be read in {@link #b b}. * @return the read value. */ protected long readLong (final int index) { long l1 = readInt(index); long l0 = readInt(index + 4) & 0xFFFFFFFFL; return (l1 << 32) | l0; } /** * Reads an UTF8 constant pool item in {@link #b b}. * * @param index the start index of an unsigned short value in {@link #b b}, * whose value is the index of an UTF8 constant pool item. * @param buf buffer to be used to read the item. This buffer must be * sufficiently large. It is not automatically resized. * @return the String corresponding to the specified UTF8 item. */ protected String readUTF8 (int index, final char[] buf) { // consults cache int item = readUnsignedShort(index); String s = strings[item]; if (s != null) { return s; } // computes the start index of the CONSTANT_Utf8 item in b index = items[item]; // reads the length of the string (in bytes, not characters) int utfLen = readUnsignedShort(index); index += 2; // parses the string bytes int endIndex = index + utfLen; byte[] b = this.b; int strLen = 0; int c, d, e; while (index < endIndex) { c = b[index++] & 0xFF; switch (c >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: // 0xxxxxxx buf[strLen++] = (char)c; break; case 12: case 13: // 110x xxxx 10xx xxxx d = b[index++]; buf[strLen++] = (char)(((c & 0x1F) << 6) | (d & 0x3F)); break; default: // 1110 xxxx 10xx xxxx 10xx xxxx d = b[index++]; e = b[index++]; buf[strLen++] = (char)(((c & 0x0F) << 12) | ((d & 0x3F) << 6) | (e & 0x3F)); break; } } s = new String(buf, 0, strLen); strings[item] = s; return s; } /** * Reads a class constant pool item in {@link #b b}. * * @param index the start index of an unsigned short value in {@link #b b}, * whose value is the index of a class constant pool item. * @param buf buffer to be used to read the item. This buffer must be * sufficiently large. It is not automatically resized. * @return the String corresponding to the specified class item. */ protected String readClass (final int index, final char[] buf) { // computes the start index of the CONSTANT_Class item in b // and reads the CONSTANT_Utf8 item designated by // the first two bytes of this CONSTANT_Class item return readUTF8(items[readUnsignedShort(index)], buf); } /** * Reads a numeric or string constant pool item in {@link #b b}. * * @param item the index of a constant pool item. * @param buf buffer to be used to read the item. This buffer must be * sufficiently large. It is not automatically resized. * @return the {@link java.lang.Integer Integer}, {@link java.lang.Float * Float}, {@link java.lang.Long Long}, {@link java.lang.Double Double} * or {@link String String} corresponding to the given constant pool * item. */ protected Object readConst (final int item, final char[] buf) { int index = items[item]; switch (b[index - 1]) { case ClassWriter.INT: return new Integer(readInt(index)); case ClassWriter.FLOAT: return new Float(Float.intBitsToFloat(readInt(index))); case ClassWriter.LONG: return new Long(readLong(index)); case ClassWriter.DOUBLE: return new Double(Double.longBitsToDouble(readLong(index))); //case ClassWriter.STR: default: return readUTF8(index, buf); } } /** * Reads an attribute in {@link #b b}. The default implementation of this * method returns instances of the {@link Attribute} class for all attributes. * * @param type the type of the attribute. * @param off the first byte of the attribute's content in {@link #b b}. The * 6 attribute header bytes, containing the type and the length of the * attribute, are not taken into account here (they have already been * read). * @param len the length of the attribute's content. * @param buf buffer to be used to call {@link #readUTF8 readUTF8}, {@link * #readClass readClass} or {@link #readConst readConst}. * @return the attribute that has been read. */ protected Attribute readAttribute ( final String type, final int off, final int len, final char[] buf) { return new Attribute(type, b, off, len); } } --- NEW FILE: ClassVisitor.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm; /** * A visitor to visit a Java class. The methods of this interface must be called * in the following order: <tt>visit</tt> (<tt>visitField</tt> | * <tt>visitMethod</tt> | <tt>visitInnerClass</tt> | <tt>visitAttribute</tt>)* * <tt>visitEnd</tt>. */ public interface ClassVisitor { /** * Visits the header of the class. * * @param access the class's access flags (see {@link Constants}). This * parameter also indicates if the class is deprecated. * @param name the internal name of the class (see {@link Type#getInternalName * getInternalName}). * @param superName the internal of name of the super class (see {@link * Type#getInternalName getInternalName}). For interfaces, the super * class is {@link Object}. May be <tt>null</tt>, but only for the {@link * Object java.lang.Object} class. * @param interfaces the internal names of the class's interfaces (see {@link * Type#getInternalName getInternalName}). May be <tt>null</tt>. * @param sourceFile the name of the source file from which this class was * compiled. May be <tt>null</tt>. */ void visit ( int access, String name, String superName, String[] interfaces, String sourceFile); /** * Visits information about an inner class. This inner class is not * necessarily a member of the class being visited. * * @param name the internal name of an inner class (see {@link * Type#getInternalName getInternalName}). * @param outerName the internal name of the class to which the inner class * belongs (see {@link Type#getInternalName getInternalName}). May be * <tt>null</tt>. * @param innerName the (simple) name of the inner class inside its enclosing * class. May be <tt>null</tt> for anonymous inner classes. * @param access the access flags of the inner class as originally declared * in the enclosing class. */ void visitInnerClass ( String name, String outerName, String innerName, int access); /** * Visits a field of the class. * * @param access the field's access flags (see {@link Constants}). This * parameter also indicates if the field is synthetic and/or deprecated. * @param name the field's name. * @param desc the field's descriptor (see {@link Type Type}). * @param value the field's initial value. This parameter, which may be * <tt>null</tt> if the field does not have an initial value, must be an * {@link java.lang.Integer Integer}, a {@link java.lang.Float Float}, a * {@link java.lang.Long Long}, a {@link java.lang.Double Double} or a * {@link String String}. <i>This parameter is only used for static * fields</i>. Its value is ignored for non static fields, which must be * initialized through bytecode instructions in constructors or methods. * @param attrs the non standard method attributes, linked together by their * <tt>next</tt> field. May be <tt>null</tt>. */ void visitField ( int access, String name, String desc, Object value, Attribute attrs); /** * Visits a method of the class. This method <i>must</i> return a new * {@link CodeVisitor CodeVisitor} instance (or <tt>null</tt>) each time it * is called, i.e., it should not return a previously returned visitor. * * @param access the method's access flags (see {@link Constants}). This * parameter also indicates if the method is synthetic and/or deprecated. * @param name the method's name. * @param desc the method's descriptor (see {@link Type Type}). * @param exceptions the internal names of the method's exception * classes (see {@link Type#getInternalName getInternalName}). May be * <tt>null</tt>. * @param attrs the non standard method attributes, linked together by their * <tt>next</tt> field. May be <tt>null</tt>. * @return an object to visit the byte code of the method, or <tt>null</tt> if * this class visitor is not interested in visiting the code of this * method. */ CodeVisitor visitMethod ( int access, String name, String desc, String[] exceptions, Attribute attrs); /** * Visits a non standard attribute of the class. This method must visit only * the first attribute in the given attribute list. * * @param attr a non standard class attribute. Must not be <tt>null</tt>. */ void visitAttribute (Attribute attr); /** * Visits the end of the class. This method, which is the last one to be * called, is used to inform the visitor that all the fields and methods of * the class have been visited. */ void visitEnd (); } --- NEW FILE: ClassWriter.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE [...985 lines suppressed...] /** * Converts the content of the given attribute to a byte array. * * @param attr the attribute that must be converted to a byte array. * @return a byte array containing the content of the given attribute (and * this content only, i.e. the 6 attribute header bytes must not be * included in the returned array). */ protected byte[] writeAttribute (final Attribute attr) { if (attr.b == null) { throw new IllegalArgumentException( "Unsupported attribute type: " + attr.type); } else { byte[] b = new byte[attr.len]; System.arraycopy(attr.b, attr.off, b, 0, attr.len); return b; } } } --- NEW FILE: CodeAdapter.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm; /** * An empty {@link CodeVisitor CodeVisitor} that delegates to another {@link * CodeVisitor CodeVisitor}. This class can be used as a super class to quickly * implement usefull code adapter classes, just by overriding the necessary * methods. */ public class CodeAdapter implements CodeVisitor { /** * The {@link CodeVisitor CodeVisitor} to which this adapter delegates calls. */ protected CodeVisitor cv; /** * Constructs a new {@link CodeAdapter CodeAdapter} object. * * @param cv the code visitor to which this adapter must delegate calls. */ public CodeAdapter (final CodeVisitor cv) { this.cv = cv; } public void visitInsn (final int opcode) { cv.visitInsn(opcode); } public void visitIntInsn (final int opcode, final int operand) { cv.visitIntInsn(opcode, operand); } public void visitVarInsn (final int opcode, final int var) { cv.visitVarInsn(opcode, var); } public void visitTypeInsn (final int opcode, final String desc) { cv.visitTypeInsn(opcode, desc); } public void visitFieldInsn ( final int opcode, final String owner, final String name, final String desc) { cv.visitFieldInsn(opcode, owner, name, desc); } public void visitMethodInsn ( final int opcode, final String owner, final String name, final String desc) { cv.visitMethodInsn(opcode, owner, name, desc); } public void visitJumpInsn (final int opcode, final Label label) { cv.visitJumpInsn(opcode, label); } public void visitLabel (final Label label) { cv.visitLabel(label); } public void visitLdcInsn (final Object cst) { cv.visitLdcInsn(cst); } public void visitIincInsn (final int var, final int increment) { cv.visitIincInsn(var, increment); } public void visitTableSwitchInsn ( final int min, final int max, final Label dflt, final Label labels[]) { cv.visitTableSwitchInsn(min, max, dflt, labels); } public void visitLookupSwitchInsn ( final Label dflt, final int keys[], final Label labels[]) { cv.visitLookupSwitchInsn(dflt, keys, labels); } public void visitMultiANewArrayInsn (final String desc, final int dims) { cv.visitMultiANewArrayInsn(desc, dims); } public void visitTryCatchBlock ( final Label start, final Label end, final Label handler, final String type) { cv.visitTryCatchBlock(start, end, handler, type); } public void visitMaxs (final int maxStack, final int maxLocals) { cv.visitMaxs(maxStack, maxLocals); } public void visitLocalVariable ( final String name, final String desc, final Label start, final Label end, final int index) { cv.visitLocalVariable(name, desc, start, end, index); } public void visitLineNumber (final int line, final Label start) { cv.visitLineNumber(line, start); } public void visitAttribute (final Attribute attr) { cv.visitAttribute(attr); } } --- NEW FILE: CodeVisitor.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyri... [truncated message content] |
From: <bil...@us...> - 2003-12-12 19:16:12
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/asm/util In directory sc8-pr-cvs1:/tmp/cvs-serv22981/src/java/org/logicalcobwebs/asm/util Added Files: CheckClassAdapter.java CheckCodeAdapter.java DumpClassVisitor.java DumpCodeVisitor.java PrintClassVisitor.java PrintCodeVisitor.java TraceClassVisitor.java TraceCodeVisitor.java package.html Log Message: Repackaged ASM project --- NEW FILE: CheckClassAdapter.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.util; import org.logicalcobwebs.asm.ClassAdapter; import org.logicalcobwebs.asm.ClassVisitor; import org.logicalcobwebs.asm.CodeVisitor; import org.logicalcobwebs.asm.Constants; import org.logicalcobwebs.asm.Attribute; /** * A {@link ClassAdapter ClssAdapter} that checks that its methods are properly * used. More precisely this class adapter checks each method call individually, * based <i>only</i> on its arguments, but does <i>not</i> check the * <i>sequence</i> of method calls. For example, the invalid sequence * <tt>visitField(ACC_PUBLIC, "i", "I", null)</tt> <tt>visitField(ACC_PUBLIC, * "i", "D", null)</tt> will <i>not</i> be detected by this class adapter. */ public class CheckClassAdapter extends ClassAdapter { /** * <tt>true</tt> if the visit method has been called. */ private boolean start; /** * <tt>true</tt> if the visitEnd method has been called. */ private boolean end; /** * Constructs a new {@link CheckClassAdapter CheckClassAdapter} object. * * @param cv the class visitor to which this adapter must delegate calls. */ public CheckClassAdapter (final ClassVisitor cv) { super(cv); } public void visit ( final int access, final String name, final String superName, final String[] interfaces, final String sourceFile) { if (start) { throw new IllegalStateException("visit must be called only once"); } else { start = true; } checkState(); checkAccess(access, 1 + 2 + 4 + 16 + 512 + 1024 + 32 + 65536 + 131072); CheckCodeAdapter.checkInternalName(name, "class name"); if (name.equals("java/lang/Object")) { if (superName != null) { throw new IllegalArgumentException( "The super class name of the Object class must be 'null'"); } } else { CheckCodeAdapter.checkInternalName(superName, "super class name"); } if ((access & Constants.ACC_INTERFACE) != 0) { if (!superName.equals("java/lang/Object")) { throw new IllegalArgumentException( "The super class name of interfaces must be 'java/lang/Object'"); } } if (interfaces != null) { for (int i = 0; i < interfaces.length; ++i) { CheckCodeAdapter.checkInternalName( interfaces[i], "interface name at index " + i); } } cv.visit(access, name, superName, interfaces, sourceFile); } public void visitInnerClass ( final String name, final String outerName, final String innerName, final int access) { checkState(); CheckCodeAdapter.checkInternalName(name, "class name"); if (outerName != null) { CheckCodeAdapter.checkInternalName(outerName, "outer class name"); } if (innerName != null) { CheckCodeAdapter.checkIdentifier(innerName, "inner class name"); } checkAccess(access, 1 + 2 + 4 + 8 + 16 + 512 + 1024 + 32); cv.visitInnerClass(name, outerName, innerName, access); } public void visitField ( final int access, final String name, final String desc, final Object value, final Attribute attrs) { checkState(); checkAccess(access, 1 + 2 + 4 + 8 + 16 + 64 + 128 + 65536 + 131072); CheckCodeAdapter.checkIdentifier(name, "field name"); CheckCodeAdapter.checkDesc(desc, false); if (value != null) { CheckCodeAdapter.checkConstant(value); } cv.visitField(access, name, desc, value, attrs); } public CodeVisitor visitMethod ( final int access, final String name, final String desc, final String[] exceptions, final Attribute attrs) { checkState(); checkAccess( access, 1 + 2 + 4 + 8 + 16 + 32 + 256 + 1024 + 2048 + 65536 + 131072); CheckCodeAdapter.checkMethodIdentifier(name, "method name"); CheckCodeAdapter.checkMethodDesc(desc); if (exceptions != null) { for (int i = 0; i < exceptions.length; ++i) { CheckCodeAdapter.checkInternalName( exceptions[i], "exception name at index " + i); } } return new CheckCodeAdapter( cv.visitMethod(access, name, desc, exceptions, attrs)); } public void visitAttribute (final Attribute attr) { checkState(); if (attr == null) { throw new IllegalArgumentException( "Invalid attribute (must not be null)"); } } public void visitEnd () { checkState(); end = true; cv.visitEnd(); } // --------------------------------------------------------------------------- /** * Checks that the visit method has been called and that visitEnd has not been * called. */ private void checkState () { if (!start) { throw new IllegalStateException( "Cannot visit member before visit has been called."); } if (end) { throw new IllegalStateException( "Cannot visit member after visitEnd has been called."); } } /** * Checks that the given access flags do not contain invalid flags. This * method also checks that mutually incompatible flags are not set * simultaneously. * * @param access the access flags to be checked * @param possibleAccess the valid access flags. */ static void checkAccess (final int access, final int possibleAccess) { if ((access & ~possibleAccess) != 0) { throw new IllegalArgumentException("Invalid access flags: " + access); } int pub = ((access & Constants.ACC_PUBLIC) != 0 ? 1 : 0); int pri = ((access & Constants.ACC_PRIVATE) != 0 ? 1 : 0); int pro = ((access & Constants.ACC_PROTECTED) != 0 ? 1 : 0); if (pub + pri + pro > 1) { throw new IllegalArgumentException( "public private and protected are mutually exclusive: " + access); } int fin = ((access & Constants.ACC_FINAL) != 0 ? 1 : 0); int abs = ((access & Constants.ACC_ABSTRACT) != 0 ? 1 : 0); if (fin + abs > 1) { throw new IllegalArgumentException( "final and abstract are mutually exclusive: " + access); } } } --- NEW FILE: CheckCodeAdapter.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.util; import org.logicalcobwebs.asm.Label; import org.logicalcobwebs.asm.CodeAdapter; import org.logicalcobwebs.asm.CodeVisitor; import org.logicalcobwebs.asm.Constants; import org.logicalcobwebs.asm.Attribute; import java.util.HashMap; /** * A {@link CodeAdapter CodeAdapter} that checks that its methods are properly * used. More precisely this code adapter checks each instruction individually * (i.e., each visit method checks some preconditions based <i>only</i> on its * arguments - such as the fact that the given opcode is correct for a given * visit method), but does <i>not</i> check the <i>sequence</i> of instructions. * For example, in a method whose signature is <tt>void m ()</tt>, the invalid * instruction IRETURN, or the invalid sequence IADD L2I will <i>not</i> be * detected by this code adapter. */ public class CheckCodeAdapter extends CodeAdapter { /** * <tt>true</tt> if the visitMaxs method has been called. */ private boolean end; /** * The already visited labels. This map associate Integer values to Label * keys. */ private HashMap labels; /** * Code of the visit method to be used for each opcode. */ private final static int[] TYPE = new int[] { 0, //NOP 0, //ACONST_NULL 0, //ICONST_M1 0, //ICONST_0 0, //ICONST_1 0, //ICONST_2 0, //ICONST_3 0, //ICONST_4 0, //ICONST_5 0, //LCONST_0 0, //LCONST_1 0, //FCONST_0 0, //FCONST_1 0, //FCONST_2 0, //DCONST_0 0, //DCONST_1 1, //BIPUSH 1, //SIPUSH 7, //LDC -1, //LDC_W -1, //LDC2_W 2, //ILOAD 2, //LLOAD 2, //FLOAD 2, //DLOAD 2, //ALOAD -1, //ILOAD_0 -1, //ILOAD_1 -1, //ILOAD_2 -1, //ILOAD_3 -1, //LLOAD_0 -1, //LLOAD_1 -1, //LLOAD_2 -1, //LLOAD_3 -1, //FLOAD_0 -1, //FLOAD_1 -1, //FLOAD_2 -1, //FLOAD_3 -1, //DLOAD_0 -1, //DLOAD_1 -1, //DLOAD_2 -1, //DLOAD_3 -1, //ALOAD_0 -1, //ALOAD_1 -1, //ALOAD_2 -1, //ALOAD_3 0, //IALOAD 0, //LALOAD 0, //FALOAD 0, //DALOAD 0, //AALOAD 0, //BALOAD 0, //CALOAD 0, //SALOAD 2, //ISTORE 2, //LSTORE 2, //FSTORE 2, //DSTORE 2, //ASTORE -1, //ISTORE_0 -1, //ISTORE_1 -1, //ISTORE_2 -1, //ISTORE_3 -1, //LSTORE_0 -1, //LSTORE_1 -1, //LSTORE_2 -1, //LSTORE_3 -1, //FSTORE_0 -1, //FSTORE_1 -1, //FSTORE_2 -1, //FSTORE_3 -1, //DSTORE_0 -1, //DSTORE_1 -1, //DSTORE_2 -1, //DSTORE_3 -1, //ASTORE_0 -1, //ASTORE_1 -1, //ASTORE_2 -1, //ASTORE_3 0, //IASTORE 0, //LASTORE 0, //FASTORE 0, //DASTORE 0, //AASTORE 0, //BASTORE 0, //CASTORE 0, //SASTORE 0, //POP 0, //POP2 0, //DUP 0, //DUP_X1 0, //DUP_X2 0, //DUP2 0, //DUP2_X1 0, //DUP2_X2 0, //SWAP 0, //IADD 0, //LADD 0, //FADD 0, //DADD 0, //ISUB 0, //LSUB 0, //FSUB 0, //DSUB 0, //IMUL 0, //LMUL 0, //FMUL 0, //DMUL 0, //IDIV 0, //LDIV 0, //FDIV 0, //DDIV 0, //IREM 0, //LREM 0, //FREM 0, //DREM 0, //INEG 0, //LNEG 0, //FNEG 0, //DNEG 0, //ISHL 0, //LSHL 0, //ISHR 0, //LSHR 0, //IUSHR 0, //LUSHR 0, //IAND 0, //LAND 0, //IOR 0, //LOR 0, //IXOR 0, //LXOR 8, //IINC 0, //I2L 0, //I2F 0, //I2D 0, //L2I 0, //L2F 0, //L2D 0, //F2I 0, //F2L 0, //F2D 0, //D2I 0, //D2L 0, //D2F 0, //I2B 0, //I2C 0, //I2S 0, //LCMP 0, //FCMPL 0, //FCMPG 0, //DCMPL 0, //DCMPG 6, //IFEQ 6, //IFNE 6, //IFLT 6, //IFGE 6, //IFGT 6, //IFLE 6, //IF_ICMPEQ 6, //IF_ICMPNE 6, //IF_ICMPLT 6, //IF_ICMPGE 6, //IF_ICMPGT 6, //IF_ICMPLE 6, //IF_ACMPEQ 6, //IF_ACMPNE 6, //GOTO 6, //JSR 2, //RET 9, //TABLESWITCH 10, //LOOKUPSWITCH 0, //IRETURN 0, //LRETURN 0, //FRETURN 0, //DRETURN 0, //ARETURN 0, //RETURN 4, //GETSTATIC 4, //PUTSTATIC 4, //GETFIELD 4, //PUTFIELD 5, //INVOKEVIRTUAL 5, //INVOKESPECIAL 5, //INVOKESTATIC 5, //INVOKEINTERFACE -1, //UNUSED 3, //NEW 1, //NEWARRAY 3, //ANEWARRAY 0, //ARRAYLENGTH 0, //ATHROW 3, //CHECKCAST 3, //INSTANCEOF 0, //MONITORENTER 0, //MONITOREXIT -1, //WIDE 11, //MULTIANEWARRAY 6, //IFNULL 6, //IFNONNULL -1, //GOTO_W -1 //JSR_W }; /** * Constructs a new {@link CheckCodeAdapter CheckCodeAdapter} object. * * @param cv the code visitor to which this adapter must delegate calls. */ public CheckCodeAdapter (final CodeVisitor cv) { super(cv); this.labels = new HashMap(); } public void visitInsn (final int opcode) { checkEnd(); checkOpcode(opcode, 0); cv.visitInsn(opcode); } public void visitIntInsn (final int opcode, final int operand) { checkEnd(); checkOpcode(opcode, 1); switch (opcode) { case Constants.BIPUSH: checkSignedByte(operand, "Invalid operand"); break; case Constants.SIPUSH: checkSignedShort(operand, "Invalid operand"); break; //case Constants.NEWARRAY: default: if (operand < Constants.T_BOOLEAN || operand > Constants.T_LONG) { throw new IllegalArgumentException( "Invalid operand (must be an array type code T_...): " + operand); } } cv.visitIntInsn(opcode, operand); } public void visitVarInsn (final int opcode, final int var) { checkEnd(); checkOpcode(opcode, 2); checkUnsignedShort(var, "Invalid variable index"); cv.visitVarInsn(opcode, var); } public void visitTypeInsn (final int opcode, final String desc) { checkEnd(); checkOpcode(opcode, 3); if (desc != null && desc.length() > 0 && desc.charAt(0) == '[') { checkDesc(desc, false); } else { checkInternalName(desc, "type"); } if (opcode == Constants.NEW && desc.charAt(0) == '[') { throw new IllegalArgumentException( "NEW cannot be used to create arrays: " + desc); } cv.visitTypeInsn(opcode, desc); } public void visitFieldInsn ( final int opcode, final String owner, final String name, final String desc) { checkEnd(); checkOpcode(opcode, 4); checkInternalName(owner, "owner"); checkIdentifier(name, "name"); checkDesc(desc, false); cv.visitFieldInsn(opcode, owner, name, desc); } public void visitMethodInsn ( final int opcode, final String owner, final String name, final String desc) { checkEnd(); checkOpcode(opcode, 5); checkInternalName(owner, "owner"); checkMethodIdentifier(name, "name"); checkMethodDesc(desc); cv.visitMethodInsn(opcode, owner, name, desc); } public void visitJumpInsn (final int opcode, final Label label) { checkEnd(); checkOpcode(opcode, 6); checkLabel(label, false, "label"); cv.visitJumpInsn(opcode, label); } public void visitLabel (final Label label) { checkEnd(); checkLabel(label, false, "label"); if (labels.get(label) != null) { throw new IllegalArgumentException("Already visited label"); } else { labels.put(label, new Integer(labels.size())); } cv.visitLabel(label); } public void visitLdcInsn (final Object cst) { checkEnd(); checkConstant(cst); cv.visitLdcInsn(cst); } public void visitIincInsn (final int var, final int increment) { checkEnd(); checkUnsignedShort(var, "Invalid variable index"); checkSignedShort(increment, "Invalid increment"); cv.visitIincInsn(var, increment); } public void visitTableSwitchInsn ( final int min, final int max, final Label dflt, final Label labels[]) { checkEnd(); if (max < min) { throw new IllegalArgumentException( "Max = " + max + " must be greater than or equal to min = " + min); } checkLabel(dflt, false, "default label"); if (labels == null || labels.length != max - min + 1) { throw new IllegalArgumentException( "There must be max - min + 1 labels"); } for (int i = 0; i < labels.length; ++i) { checkLabel(labels[i], false, "label at index " + i); } cv.visitTableSwitchInsn(min, max, dflt, labels); } public void visitLookupSwitchInsn ( final Label dflt, final int keys[], final Label labels[]) { checkEnd(); checkLabel(dflt, false, "default label"); if (keys == null || labels == null || keys.length != labels.length) { throw new IllegalArgumentException( "There must be the same number of keys and labels"); } for (int i = 0; i < labels.length; ++i) { checkLabel(labels[i], false, "label at index " + i); } cv.visitLookupSwitchInsn(dflt, keys, labels); } public void visitMultiANewArrayInsn (final String desc, final int dims) { checkEnd(); checkDesc(desc, false); if (desc.charAt(0) != '[') { throw new IllegalArgumentException( "Invalid descriptor (must be an array type descriptor): " + desc); } if (dims < 1) { throw new IllegalArgumentException( "Invalid dimensions (must be greater than 0): " + dims); } if (dims > desc.lastIndexOf('[') + 1) { throw new IllegalArgumentException( "Invalid dimensions (must not be greater than dims(desc)): " + dims); } cv.visitMultiANewArrayInsn(desc, dims); } public void visitTryCatchBlock ( final Label start, final Label end, final Label handler, final String type) { checkLabel(start, true, "start label"); checkLabel(end, true, "end label"); checkLabel(handler, true, "handler label"); if (type != null) { checkInternalName(type, "type"); } int s = ((Integer)labels.get(start)).intValue(); int e = ((Integer)labels.get(end)).intValue(); if (e <= s) { throw new IllegalArgumentException( "Invalid start and end labels (end must be greater than start)"); } cv.visitTryCatchBlock(start, end, handler, type); } public void visitMaxs (final int maxStack, final int maxLocals) { checkEnd(); end = true; checkUnsignedShort(maxStack, "Invalid max stack"); checkUnsignedShort(maxLocals, "Invalid max locals"); cv.visitMaxs(maxStack, maxLocals); } public void visitLocalVariable ( final String name, final String desc, final Label start, final Label end, final int index) { checkIdentifier(name, "name"); checkDesc(desc, false); checkLabel(start, true, "start label"); checkLabel(end, true, "end label"); checkUnsignedShort(index, "Invalid variable index"); int s = ((Integer)labels.get(start)).intValue(); int e = ((Integer)labels.get(end)).intValue(); if (e <= s) { throw new IllegalArgumentException( "Invalid start and end labels (end must be greater than start)"); } cv.visitLocalVariable(name, desc, start, end, index); } public void visitLineNumber (final int line, final Label start) { checkUnsignedShort(line, "Invalid line number"); checkLabel(start, true, "start label"); cv.visitLineNumber(line, start); } public void visitAttribute (Attribute attr) { if (attr == null) { throw new IllegalArgumentException( "Invalid attribute (must not be null)"); } } // --------------------------------------------------------------------------- /** * Checks that the visitMaxs method has not been called. */ void checkEnd () { if (end) { throw new IllegalStateException( "Cannot visit instructions after visitMaxs has been called."); } } /** * Checks that the type of the given opcode is equal to the given type. * * @param opcode the opcode to be checked. * @param type the expected opcode type. */ static void checkOpcode (final int opcode, final int type) { if (opcode < 0 || opcode > 199 || TYPE[opcode] != type) { throw new IllegalArgumentException("Invalid opcode: " + opcode); } } /** * Checks that the given value is a signed byte. * * @param value the value to be checked. * @param msg an message to be used in case of error. */ static void checkSignedByte (final int value, final String msg) { if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) { throw new IllegalArgumentException( msg + " (must be a signed byte): " + value); } } /** * Checks that the given value is a signed short. * * @param value the value to be checked. * @param msg an message to be used in case of error. */ static void checkSignedShort (final int value, final String msg) { if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) { throw new IllegalArgumentException( msg + " (must be a signed short): " + value); } } /** * Checks that the given value is an unsigned short. * * @param value the value to be checked. * @param msg an message to be used in case of error. */ static void checkUnsignedShort (final int value, final String msg) { if (value < 0 || value > 65535) { throw new IllegalArgumentException( msg + " (must be an unsigned short): " + value); } } /** * Checks that the given value is an {@link java.lang.Integer Integer}, a * {@link java.lang.Float Float}, a {@link java.lang.Long Long}, a {@link * java.lang.Double Double} or a {@link String String}. * * @param cst the value to be checked. */ static void checkConstant (final Object cst) { if (!(cst instanceof Integer) && !(cst instanceof Float) && !(cst instanceof Long) && !(cst instanceof Double) && !(cst instanceof String)) { throw new IllegalArgumentException("Invalid constant: " + cst); } } /** * Checks that the given string is a valid Java identifier. * * @param name the string to be checked. * @param msg a message to be used in case of error. */ static void checkIdentifier (final String name, final String msg) { checkIdentifier(name, 0, -1, msg); } /** * Checks that the given substring is a valid Java identifier. * * @param name the string to be checked. * @param start index of the first character of the identifier (inclusive). * @param end index of the last character of the identifier (exclusive). -1 is * equivalent to <tt>name.length()</tt> if name is not <tt>null</tt>. * @param msg a message to be used in case of error. */ static void checkIdentifier ( final String name, final int start, final int end, final String msg) { if (name == null || (end == -1 ? name.length() <= start : end <= start)) { throw new IllegalArgumentException( "Invalid " + msg + " (must not be null or empty)"); } if (!Character.isJavaIdentifierStart(name.charAt(start))) { throw new IllegalArgumentException( "Invalid " + msg + " (must be a valid Java identifier): " + name); } int max = (end == -1 ? name.length() : end); for (int i = start + 1; i < max; ++i) { if (!Character.isJavaIdentifierPart(name.charAt(i))) { throw new IllegalArgumentException( "Invalid " + msg + " (must be a valid Java identifier): " + name); } } } /** * Checks that the given string is a valid Java identifier or is equal to * '<init>' or '<clinit>'. * * @param name the string to be checked. * @param msg a message to be used in case of error. */ static void checkMethodIdentifier (final String name, final String msg) { if (name == null || name.length() == 0) { throw new IllegalArgumentException( "Invalid " + msg + " (must not be null or empty)"); } if (name.equals("<init>") || name.equals("<clinit>")) { return; } if (!Character.isJavaIdentifierStart(name.charAt(0))) { throw new IllegalArgumentException( "Invalid " + msg + " (must be a '<init>', '<clinit>' or a valid Java identifier): " + name); } for (int i = 1; i < name.length(); ++i) { if (!Character.isJavaIdentifierPart(name.charAt(i))) { throw new IllegalArgumentException( "Invalid " + msg + " (must be '<init>' or '<clinit>' or a valid Java identifier): " + name); } } } /** * Checks that the given string is a valid internal class name. * * @param name the string to be checked. * @param msg a message to be used in case of error. */ static void checkInternalName (final String name, final String msg) { checkInternalName(name, 0, -1, msg); } /** * Checks that the given substring is a valid internal class name. * * @param name the string to be checked. * @param start index of the first character of the identifier (inclusive). * @param end index of the last character of the identifier (exclusive). -1 is * equivalent to <tt>name.length()</tt> if name is not <tt>null</tt>. * @param msg a message to be used in case of error. */ static void checkInternalName ( final String name, final int start, final int end, final String msg) { if (name == null || name.length() == 0) { throw new IllegalArgumentException( "Invalid " + msg + " (must not be null or empty)"); } int max = (end == -1 ? name.length() : end); try { int begin = start; int slash; do { slash = name.indexOf('/', begin + 1); if (slash == -1 || slash > max) { slash = max; } checkIdentifier(name, begin, slash, null); begin = slash + 1; } while (slash != max); } catch (IllegalArgumentException _) { throw new IllegalArgumentException( "Invalid " + msg + " (must be a fully qualified class name in internal form): " + name); } } /** * Checks that the given string is a valid type descriptor. * * @param desc the string to be checked. * @param canBeVoid <tt>true</tt> if <tt>V</tt> can be considered valid. */ static void checkDesc (final String desc, final boolean canBeVoid) { int end = checkDesc(desc, 0, canBeVoid); if (end != desc.length()) { throw new IllegalArgumentException("Invalid descriptor: " + desc); } } /** * Checks that a the given substring is a valid type descriptor. * * @param desc the string to be checked. * @param start index of the first character of the identifier (inclusive). * @param canBeVoid <tt>true</tt> if <tt>V</tt> can be considered valid. * @return the index of the last character of the type decriptor, plus one. */ static int checkDesc ( final String desc, final int start, final boolean canBeVoid) { if (desc == null || start >= desc.length()) { throw new IllegalArgumentException( "Invalid type descriptor (must not be null or empty)"); } int index; switch (desc.charAt(start)) { case 'V': if (canBeVoid) { return start + 1; } else { throw new IllegalArgumentException("Invalid descriptor: " + desc); } case 'Z': case 'C': case 'B': case 'S': case 'I': case 'F': case 'J': case 'D': return start + 1; case '[': index = start + 1; while (index < desc.length() && desc.charAt(index) == '[') { ++index; } if (index < desc.length()) { return checkDesc(desc, index, false); } else { throw new IllegalArgumentException("Invalid descriptor: " + desc); } case 'L': index = desc.indexOf(';', start); if (index == -1 || index - start < 2) { throw new IllegalArgumentException("Invalid descriptor: " + desc); } try { checkInternalName(desc, start + 1, index, null); } catch (IllegalArgumentException _) { throw new IllegalArgumentException("Invalid descriptor: " + desc); } return index + 1; default: throw new IllegalArgumentException("Invalid descriptor: " + desc); } } /** * Checks that the given string is a valid method descriptor. * * @param desc the string to be checked. */ static void checkMethodDesc (final String desc) { if (desc == null || desc.length() == 0) { throw new IllegalArgumentException( "Invalid method descriptor (must not be null or empty)"); } if (desc.charAt(0) != '(' || desc.length() < 3) { throw new IllegalArgumentException("Invalid descriptor: " + desc); } int start = 1; if (desc.charAt(start) != ')') { do { if (desc.charAt(start) == 'V') { throw new IllegalArgumentException("Invalid descriptor: " + desc); } start = checkDesc(desc, start, false); } while (start < desc.length() && desc.charAt(start) != ')'); } start = checkDesc(desc, start + 1, true); if (start != desc.length()) { throw new IllegalArgumentException("Invalid descriptor: " + desc); } } /** * Checks that the given label is not null. This method can also check that * the label has been visited. * * @param label the label to be checked. * @param checkVisited <tt>true</tt> to check that the label has been visited. * @param msg a message to be used in case of error. */ void checkLabel ( final Label label, final boolean checkVisited, final String msg) { if (label == null) { throw new IllegalArgumentException( "Invalid " + msg + " (must not be null)"); } if (checkVisited && labels.get(label) == null) { throw new IllegalArgumentException( "Invalid " + msg + " (must be visited first)"); } } } --- NEW FILE: DumpClassVisitor.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.util; import org.logicalcobwebs.asm.Constants; import org.logicalcobwebs.asm.ClassReader; import org.logicalcobwebs.asm.CodeVisitor; import org.logicalcobwebs.asm.Attribute; import java.io.PrintWriter; /** * A {@link PrintClassVisitor PrintClassVisitor} that prints the ASM code that * generates the classes it visits. This class visitor can be used to quickly * write ASM code to generate some given bytecode: * <ul> * <li>write the Java source code equivalent to the bytecode you want to * generate;</li> * <li>compile it with <tt>javac</tt>;</li> * <li>make a {@link DumpClassVisitor DumpClassVisitor} visit this compiled * class (see the {@link #main main} method);</li> * <li>edit the generated source code, if necessary.</li> * </ul> * The source code printed when visiting the <tt>Hello</tt> class is the * following: * <p> * <blockquote> * <pre> * import org.logicalcobwebs.asm.*; * import java.io.FileOutputStream; * * public class Dump implements Constants { * * public static void main (String[] args) throws Exception { * * ClassWriter cw = new ClassWriter(false); * CodeVisitor cv; * * cw.visit(ACC_PUBLIC + ACC_SUPER, "Hello", "java/lang/Object", null, "Hello.java"); * * { * cv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null); * cv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"); * cv.visitLdcInsn("hello"); * cv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V"); * cv.visitInsn(RETURN); * cv.visitMaxs(2, 1); * } * { * cv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null); * cv.visitVarInsn(ALOAD, 0); * cv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V"); * cv.visitInsn(RETURN); * cv.visitMaxs(1, 1); * } * cw.visitEnd(); * * FileOutputStream os = new FileOutputStream("Dumped.class"); * os.write(cw.toByteArray()); * os.close(); * } * } * </pre> * </blockquote> * where <tt>Hello</tt> is defined by: * <p> * <blockquote> * <pre> * public class Hello { * * public static void main (String[] args) { * System.out.println("hello"); * } * } * </pre> * </blockquote> */ public class DumpClassVisitor extends PrintClassVisitor { /** * Prints the ASM source code to generate the given class to the standard * output. * <p> * Usage: DumpClassVisitor <fully qualified class name> * * @param args the command line arguments. * * @throws Exception if the class cannot be found, or if an IO exception * occurs. */ public static void main (final String[] args) throws Exception { if (args.length == 0) { System.err.println("Prints the ASM code to generate the given class."); System.err.println("Usage: DumpClassVisitor <fully qualified class name>"); System.exit(-1); } ClassReader cr = new ClassReader(args[0]); cr.accept(new DumpClassVisitor(new PrintWriter(System.out)), true); } /** * Constructs a new {@link DumpClassVisitor DumpClassVisitor} object. * * @param pw the print writer to be used to print the class. */ public DumpClassVisitor (final PrintWriter pw) { super(pw); } public void visit ( final int access, final String name, final String superName, final String[] interfaces, final String sourceFile) { text.add("import org.logicalcobwebs.asm.*;\n"); text.add("import java.io.FileOutputStream;\n\n"); text.add("public class Dump implements Constants {\n\n"); text.add("public static void main (String[] args) throws Exception {\n\n"); text.add("ClassWriter cw = new ClassWriter(false);\n"); text.add("CodeVisitor cv;\n\n"); buf.setLength(0); buf.append("cw.visit("); appendAccess(access | 262144); buf.append(", "); appendConstant(buf, name); buf.append(", "); appendConstant(buf, superName); buf.append(", "); if (interfaces != null && interfaces.length > 0) { buf.append("new String[] {"); for (int i = 0; i < interfaces.length; ++i) { buf.append(i == 0 ? " " : ", "); appendConstant(buf, interfaces[i]); } buf.append(" }"); } else { buf.append("null"); } buf.append(", "); appendConstant(buf, sourceFile); buf.append(");\n\n"); text.add(buf.toString()); } public void visitInnerClass ( final String name, final String outerName, final String innerName, final int access) { buf.setLength(0); buf.append("cw.visitInnerClass("); appendConstant(buf, name); buf.append(", "); appendConstant(buf, outerName); buf.append(", "); appendConstant(buf, innerName); buf.append(", "); appendAccess(access); buf.append(");\n\n"); text.add(buf.toString()); } public void visitField ( final int access, final String name, final String desc, final Object value, final Attribute attrs) { buf.setLength(0); buf.append("cw.visitField("); appendAccess(access); buf.append(", "); appendConstant(buf, name); buf.append(", "); appendConstant(buf, desc); buf.append(", "); appendConstant(buf, value); buf.append(", null);\n\n"); if (attrs != null) { buf.append("// WARNING! skipped some non standard field attributes\n"); } text.add(buf.toString()); } public CodeVisitor visitMethod ( final int access, final String name, final String desc, final String[] exceptions, final Attribute attrs) { buf.setLength(0); buf.append("{\n").append("cv = cw.visitMethod("); appendAccess(access); buf.append(", "); appendConstant(buf, name); buf.append(", "); appendConstant(buf, desc); buf.append(", "); if (exceptions != null && exceptions.length > 0) { buf.append("new String[] {"); for (int i = 0; i < exceptions.length; ++i) { buf.append(i == 0 ? " " : ", "); appendConstant(buf, exceptions[i]); } buf.append(" }"); } else { buf.append("null"); } buf.append(", null);\n"); if (attrs != null) { buf.append("// WARNING! skipped some non standard method attributes\n"); } text.add(buf.toString()); PrintCodeVisitor pcv = new DumpCodeVisitor(); text.add(pcv.getText()); text.add("}\n"); return pcv; } public void visitAttribute (final Attribute attr) { buf.setLength(0); buf.append("// WARNING! skipped a non standard class attribute of type \""); buf.append(attr.type); buf.append("\"\n"); text.add(buf.toString()); } public void visitEnd () { text.add("cw.visitEnd();\n\n"); text.add("FileOutputStream os = new FileOutputStream(\"Dumped.class\");\n"); text.add("os.write(cw.toByteArray());\n"); text.add("os.close();\n"); text.add("}\n"); text.add("}\n"); super.visitEnd(); } /** * Appends a string representation of the given access modifiers to {@link * #buf buf}. * * @param access some access modifiers. */ void appendAccess (final int access) { boolean first = true; if ((access & Constants.ACC_PUBLIC) != 0) { buf.append("ACC_PUBLIC"); first = false; } if ((access & Constants.ACC_PRIVATE) != 0) { if (!first) { buf.append(" + "); } buf.append("ACC_PRIVATE"); first = false; } if ((access & Constants.ACC_PROTECTED) != 0) { if (!first) { buf.append(" + "); } buf.append("ACC_PROTECTED"); first = false; } if ((access & Constants.ACC_FINAL) != 0) { if (!first) { buf.append(" + "); } buf.append("ACC_FINAL"); first = false; } if ((access & Constants.ACC_STATIC) != 0) { if (!first) { buf.append(" + "); } buf.append("ACC_STATIC"); first = false; } if ((access & Constants.ACC_SYNCHRONIZED) != 0) { if (!first) { buf.append(" + "); } if ((access & 262144) != 0) { buf.append("ACC_SUPER"); } else { buf.append("ACC_SYNCHRONIZED"); } first = false; } if ((access & Constants.ACC_VOLATILE) != 0) { if (!first) { buf.append(" + "); } buf.append("ACC_VOLATILE"); first = false; } if ((access & Constants.ACC_TRANSIENT) != 0) { if (!first) { buf.append(" + "); } buf.append("ACC_TRANSIENT"); first = false; } if ((access & Constants.ACC_NATIVE) != 0) { if (!first) { buf.append(" + "); } buf.append("ACC_NATIVE"); first = false; } if ((access & Constants.ACC_ABSTRACT) != 0) { if (!first) { buf.append(" + "); } buf.append("ACC_ABSTRACT"); first = false; } if ((access & Constants.ACC_INTERFACE) != 0) { if (!first) { buf.append(" + "); } buf.append("ACC_INTERFACE"); first = false; } if ((access & Constants.ACC_STRICT) != 0) { if (!first) { buf.append(" + "); } buf.append("ACC_STRICT"); first = false; } if ((access & Constants.ACC_SYNTHETIC) != 0) { if (!first) { buf.append(" + "); } buf.append("ACC_SYNTHETIC"); first = false; } if ((access & Constants.ACC_DEPRECATED) != 0) { if (!first) { buf.append(" + "); } buf.append("ACC_DEPRECATED"); first = false; } if (first) { buf.append("0"); } } /** * Appends a string representation of the given constant to the given buffer. * * @param buf a string buffer. * @param cst an {@link java.lang.Integer Integer}, {@link java.lang.Float * Float}, {@link java.lang.Long Long}, {@link java.lang.Double Double} * or {@link String String} object. May be <tt>null</tt>. */ static void appendConstant (final StringBuffer buf, final Object cst) { if (cst == null) { buf.append("null"); } else if (cst instanceof String) { String s = (String)cst; buf.append("\""); for (int i = 0; i < s.length(); ++i) { char c = s.charAt(i); if (c == '\n') { buf.append("\\n"); } else if (c == '\\') { buf.append("\\\\"); } else if (c == '"') { buf.append("\\\""); } else { buf.append(c); } } buf.append("\""); } else if (cst instanceof Integer) { buf.append("new Integer(") .append(cst) .append(")"); } else if (cst instanceof Float) { buf.append("new Float(") .append(cst) .append("F)"); } else if (cst instanceof Long) { buf.append("new Long(") .append(cst) .append("L)"); } else if (cst instanceof Double) { buf.append("new Double(") .append(cst) .append(")"); } } } --- NEW FILE: DumpCodeVisitor.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.util; import org.logicalcobwebs.asm.Label; import org.logicalcobwebs.asm.Attribute; import java.util.HashMap; /** * A {@link PrintCodeVisitor PrintCodeVisitor} that prints the ASM code that * generates the code it visits. */ public class DumpCodeVisitor extends PrintCodeVisitor { /** * The label names. This map associate String values to Label keys. */ private final HashMap labelNames; /** * Constructs a new {@link DumpCodeVisitor DumpCodeVisitor} object. */ public DumpCodeVisitor () { this.labelNames = new HashMap(); } public void printInsn (final int opcode) { buf.append("cv.visitInsn("). append(OPCODES[opcode]). append(");\n"); } public void printIntInsn (final int opcode, final int operand) { buf.append("cv.visitIntInsn("). append(OPCODES[opcode]). append(", "). append(operand). append(");\n"); } public void printVarInsn (final int opcode, final int var) { buf.append("cv.visitVarInsn("). append(OPCODES[opcode]). append(", "). append(var). append(");\n"); } public void printTypeInsn (final int opcode, final String desc) { buf.append("cv.visitTypeInsn("). append(OPCODES[opcode]). append(", "); DumpClassVisitor.appendConstant(buf, desc); buf.append(");\n"); } public void printFieldInsn ( final int opcode, final String owner, final String name, final String desc) { buf.append("cv.visitFieldInsn(") .append(OPCODES[opcode]) .append(", "); DumpClassVisitor.appendConstant(buf, owner); buf.append(", "); DumpClassVisitor.appendConstant(buf, name); buf.append(", "); DumpClassVisitor.appendConstant(buf, desc); buf.append(");\n"); } public void printMethodInsn ( final int opcode, final String owner, final String name, final String desc) { buf.append("cv.visitMethodInsn(") .append(OPCODES[opcode]) .append(", "); DumpClassVisitor.appendConstant(buf, owner); buf.append(", "); DumpClassVisitor.appendConstant(buf, name); buf.append(", "); DumpClassVisitor.appendConstant(buf, desc); buf.append(");\n"); } public void printJumpInsn (final int opcode, final Label label) { declareLabel(label); buf.append("cv.visitJumpInsn(") .append(OPCODES[opcode]) .append(", "); appendLabel(label); buf.append(");\n"); } public void printLabel (final Label label) { declareLabel(label); buf.append("cv.visitLabel("); appendLabel(label); buf.append(");\n"); } public void printLdcInsn (final Object cst) { buf.append("cv.visitLdcInsn("); DumpClassVisitor.appendConstant(buf, cst); buf.append(");\n"); } public void printIincInsn (final int var, final int increment) { buf.append("cv.visitIincInsn(") .append(var) .append(", ") .append(increment) .append(");\n"); } public void printTableSwitchInsn ( final int min, final int max, final Label dflt, final Label labels[]) { for (int i = 0; i < labels.length; ++i) { declareLabel(labels[i]); } declareLabel(dflt); buf.append("cv.visitTableSwitchInsn(") .append(min) .append(", ") .append(max) .append(", "); appendLabel(dflt); buf.append(", new Label[] {"); for (int i = 0; i < labels.length; ++i) { buf.append(i == 0 ? " " : ", "); appendLabel(labels[i]); } buf.append(" });\n"); } public void printLookupSwitchInsn ( final Label dflt, final int keys[], final Label labels[]) { for (int i = 0; i < labels.length; ++i) { declareLabel(labels[i]); } declareLabel(dflt); buf.append("cv.visitLookupSwitchInsn("); appendLabel(dflt); buf.append(", new int[] {"); for (int i = 0; i < keys.length; ++i) { buf.append(i == 0 ? " " : ", ").append(keys[i]); } buf.append(" }, new Label[] {"); for (int i = 0; i < labels.length; ++i) { buf.append(i == 0 ? " " : ", "); appendLabel(labels[i]); } buf.append(" });\n"); } public void printMultiANewArrayInsn (final String desc, final int dims) { buf.append("cv.visitMultiANewArrayInsn("); DumpClassVisitor.appendConstant(buf, desc); buf.append(", ") .append(dims) .append(");\n"); } public void printTryCatchBlock ( final Label start, final Label end, final Label handler, final String type) { buf.append("cv.visitTryCatchBlock("); appendLabel(start); buf.append(", "); appendLabel(end); buf.append(", "); appendLabel(handler); buf.append(", "); DumpClassVisitor.appendConstant(buf, type); buf.append(");\n"); } public void printMaxs (final int maxStack, final int maxLocals) { buf.append("cv.visitMaxs(") .append(maxStack) .append(", ") .append(maxLocals) .append(");\n"); } public void printLocalVariable ( final String name, final String desc, final Label start, final Label end, final int index) { buf.append("cv.visitLocalVariable("); DumpClassVisitor.appendConstant(buf, name); buf.append(", "); DumpClassVisitor.appendConstant(buf, desc); buf.append(", "); appendLabel(start); buf.append(", "); appendLabel(end); buf.append(", ").append(index).append(");\n"); } public void printLineNumber (final int line, final Label start) { buf.append("cv.visitLineNumber(") .append(line) .append(", "); appendLabel(start); buf.append(");\n"); } public void printAttribute (final Attribute attr) { buf.append("// WARNING! skipped a non standard code attribute of type \""); buf.append(attr.type); buf.append("\"\n"); } /** * Appends a declaration of the given label to {@link #buf buf}. This * declaration is of the form "Label lXXX = new Label();". Does nothing * if the given label has already been declared. * * @param l a label. */ private void declareLabel (final Label l) { String name = (String)labelNames.get(l); if (name == null) { name = "l" + labelNames.size(); labelNames.put(l, name); buf.append("Label ") .append(name) .append(" = new Label();\n"); } } /** * Appends the name of the given label to {@link #buf buf}. The given label * <i>must</i> already have a name. One way to ensure this is to always call * {@link #declareLabel declared} before calling this method. * * @param l a label. */ private void appendLabel (final Label l) { buf.append((String)labelNames.get(l)); } } --- NEW FILE: PrintClassVisitor.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.util; import org.logicalcobwebs.asm.ClassVisitor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; /** * An abstract class visitor that prints the classes it visits. */ public abstract class PrintClassVisitor implements ClassVisitor { /** * The text to be printed. Since the code of methods is not necessarily * visited in sequential order, one method after the other, but can be * interlaced (some instructions from method one, then some instructions from * method two, then some instructions from method one again...), it is not * possible to print the visited instructions directly to a sequential * stream. A class is therefore printed in a two steps process: a string tree * is constructed during the visit, and printed to a sequential stream at the * end of the visit. This string tree is stored in this field, as a string * list that can contain other string lists, which can themselves contain * other string lists, and so on. */ protected final List text; /** * A buffer that can be used to create strings. */ protected final StringBuffer buf; /** * The print writer to be used to print the class. */ protected final PrintWriter pw; /** * Constructs a new {@link PrintClassVisitor PrintClassVisitor} object. * * @param pw the print writer to be used to print the class. */ public PrintClassVisitor (final PrintWriter pw) { this.text = new ArrayList(); this.buf = new StringBuffer(); this.pw = pw; } public void visitEnd () { printList(text); pw.flush(); } /** * Prints the given string tree to {@link pw pw}. * * @param l a string tree, i.e., a string list that can contain other string * lists, and so on recursively. */ private void printList (final List l) { for (int i = 0; i < l.size(); ++i) { Object o = l.get(i); if (o instanceof List) { printList((List)o); } else { pw.print(o.toString()); } } } } --- NEW FILE: PrintCodeVisitor.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.util; import org.logicalcobwebs.asm.CodeVisitor; import org.logicalcobwebs.asm.Label; import org.logicalcobwebs.asm.Attribute; import java.util.ArrayList; import java.util.List; /** * An abstract code visitor that prints the code it visits. Each * <tt>visit</tt><i>XXX</i> method clears the {@link #buf buf} buffer, calls the * corresponding <tt>print</tt><i>XXX</i> method, and then adds the buffer's * content to the {@link #text text} list. In order to provide a concrete * print code visitor, one must implement the <tt>print</tt><i>XXX</i> methods * in a sub class of this class. Each method should print the instructions it * visits in {@link #buf buf}. */ public abstract class PrintCodeVisitor implements CodeVisitor { /** * The text to be printed. See {@link PrintClassVisitor#text text}. */ protected final List text; /** * A buffer used to convert instructions to strings. */ protected final StringBuffer buf; /** * The names of the Java Virtual Machine opcodes. */ public final static String[] OPCODES = { "NOP", "ACONST_NULL", "ICONST_M1", "ICONST_0", "ICONST_1", "ICONST_2", "ICONST_3", "ICONST_4", "ICONST_5", "LCONST_0", "LCONST_1", "FCONST_0", "FCONST_1", "FCONST_2", "DCONST_0", "DCONST_1", "BIPUSH", "SIPUSH", "LDC", null, null, "ILOAD", "LLOAD", "FLOAD", "DLOAD", "ALOAD", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ... [truncated message content] |
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/asm/tree In directory sc8-pr-cvs1:/tmp/cvs-serv22981/src/java/org/logicalcobwebs/asm/tree Added Files: AbstractInsnNode.java ClassNode.java FieldInsnNode.java FieldNode.java IincInsnNode.java InnerClassNode.java InsnNode.java IntInsnNode.java JumpInsnNode.java LdcInsnNode.java LineNumberNode.java LocalVariableNode.java LookupSwitchInsnNode.java MethodInsnNode.java MethodNode.java MultiANewArrayInsnNode.java TableSwitchInsnNode.java TreeClassAdapter.java TreeCodeAdapter.java TryCatchBlockNode.java TypeInsnNode.java VarInsnNode.java package.html Log Message: Repackaged ASM project --- NEW FILE: AbstractInsnNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.CodeVisitor; /** * A node that represents a bytecode instruction. */ public abstract class AbstractInsnNode { /** * The opcode of this instruction. */ protected int opcode; /** * Constructs a new {@link AbstractInsnNode AbstractInsnNode} object. * * @param opcode the opcode of the instruction to be constructed. */ protected AbstractInsnNode (final int opcode) { this.opcode = opcode; } /** * Returns the opcode of this instruction. * * @return the opcode of this instruction. */ public int getOpcode () { return opcode; } /** * Makes the given code visitor visit this instruction. * * @param cv a code visitor. */ public abstract void accept (final CodeVisitor cv); } --- NEW FILE: ClassNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.ClassVisitor; import org.logicalcobwebs.asm.Attribute; import java.util.List; import java.util.ArrayList; import java.util.Arrays; /** * A node that represents a class. */ public class ClassNode { /** * The class's access flags (see {@link org.logicalcobwebs.asm.Constants}). This * field also indicates if the class is deprecated. */ public int access; /** * The internal name of the class (see {@link * org.logicalcobwebs.asm.Type#getInternalName getInternalName}). */ public String name; /** * The internal of name of the super class (see {@link * org.logicalcobwebs.asm.Type#getInternalName getInternalName}). For interfaces, * the super class is {@link Object}. May be <tt>null</tt>, but only for the * {@link Object java.lang.Object} class. */ public String superName; /** * The internal names of the class's interfaces (see {@link * org.logicalcobwebs.asm.Type#getInternalName getInternalName}). This list is a * list of {@link String} objects. */ public final List interfaces; /** * The name of the source file from which this class was compiled. May be * <tt>null</tt>. */ public String sourceFile; /** * Informations about the inner classes of this class. This list is a list of * {@link InnerClassNode InnerClassNode} objects. */ public final List innerClasses; /** * The fields of this class. This list is a list of {@link FieldNode * FieldNode} objects. */ public final List fields; /** * The methods of this class. This list is a list of {@link MethodNode * MethodNode} objects. */ public final List methods; /** * The non standard attributes of the class. */ public Attribute attrs; /** * Constructs a new {@link ClassNode ClassNode} object. * * @param access the class's access flags (see {@link * org.logicalcobwebs.asm.Constants}). This parameter also indicates if the * class is deprecated. * @param name the internal name of the class (see {@link * org.logicalcobwebs.asm.Type#getInternalName getInternalName}). * @param superName the internal of name of the super class (see {@link * org.logicalcobwebs.asm.Type#getInternalName getInternalName}). For * interfaces, the super class is {@link Object}. * @param interfaces the internal names of the class's interfaces (see {@link * org.logicalcobwebs.asm.Type#getInternalName getInternalName}). May be * <tt>null</tt>. * @param sourceFile the name of the source file from which this class was * compiled. May be <tt>null</tt>. */ public ClassNode ( final int access, final String name, final String superName, final String[] interfaces, final String sourceFile) { this.access = access; this.name = name; this.superName = superName; this.interfaces = new ArrayList(); this.sourceFile = sourceFile; this.innerClasses = new ArrayList(); this.fields = new ArrayList(); this.methods = new ArrayList(); if (interfaces != null) { this.interfaces.addAll(Arrays.asList(interfaces)); } } /** * Makes the given class visitor visit this class. * * @param cv a class visitor. */ public void accept (final ClassVisitor cv) { // visits header String[] interfaces = new String[this.interfaces.size()]; this.interfaces.toArray(interfaces); cv.visit(access, name, superName, interfaces, sourceFile); // visits inner classes int i; for (i = 0; i < innerClasses.size(); ++i) { ((InnerClassNode)innerClasses.get(i)).accept(cv); } // visits fields for (i = 0; i < fields.size(); ++i) { ((FieldNode)fields.get(i)).accept(cv); } // visits methods for (i = 0; i < methods.size(); ++i) { ((MethodNode)methods.get(i)).accept(cv); } // visits attributes Attribute attrs = this.attrs; while (attrs != null) { cv.visitAttribute(attrs); attrs = attrs.next; } // visits end cv.visitEnd(); } } --- NEW FILE: FieldInsnNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.CodeVisitor; /** * A node that represents a field instruction. A field instruction is an * instruction that loads or stores the value of a field of an object. */ public class FieldInsnNode extends AbstractInsnNode { /** * The internal name of the field's owner class (see {@link * org.logicalcobwebs.asm.Type#getInternalName getInternalName}). */ public String owner; /** * The field's name. */ public String name; /** * The field's descriptor (see {@link org.logicalcobwebs.asm.Type Type}). */ public String desc; /** * Constructs a new {@link FieldInsnNode FieldInsnNode} object. * * @param opcode the opcode of the type instruction to be constructed. This * opcode must be GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD. * @param owner the internal name of the field's owner class (see {@link * org.logicalcobwebs.asm.Type#getInternalName getInternalName}). * @param name the field's name. * @param desc the field's descriptor (see {@link org.logicalcobwebs.asm.Type * Type}). */ public FieldInsnNode ( final int opcode, final String owner, final String name, final String desc) { super(opcode); this.owner = owner; this.name = name; this.desc = desc; } /** * Sets the opcode of this instruction. * * @param opcode the new instruction opcode. This opcode must be GETSTATIC, * PUTSTATIC, GETFIELD or PUTFIELD. */ public void setOpcode (final int opcode) { this.opcode = opcode; } public void accept (final CodeVisitor cv) { cv.visitFieldInsn(opcode, owner, name, desc); } } --- NEW FILE: FieldNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.ClassVisitor; import org.logicalcobwebs.asm.Attribute; /** * A node that represents a field. */ public class FieldNode { /** * The field's access flags (see {@link org.logicalcobwebs.asm.Constants}). This * field also indicates if the field is synthetic and/or deprecated. */ public int access; /** * The field's name. */ public String name; /** * The field's descriptor (see {@link org.logicalcobwebs.asm.Type Type}). */ public String desc; /** * The field's initial value. This field, which may be <tt>null</tt> if the * field does not have an initial value, must be an {@link java.lang.Integer * Integer}, a {@link java.lang.Float Float}, a {@link java.lang.Long Long}, * a {@link java.lang.Double Double} or a {@link String String}. */ public Object value; /** * The non standard attributes of the field. */ public Attribute attrs; /** * Constructs a new {@link FieldNode FieldNode} object. * * @param access the field's access flags (see {@link * org.logicalcobwebs.asm.Constants}). This parameter also indicates if the * field is synthetic and/or deprecated. * @param name the field's name. * @param desc the field's descriptor (see {@link org.logicalcobwebs.asm.Type * Type}). * @param value the field's initial value. This parameter, which may be * <tt>null</tt> if the field does not have an initial value, must be an * {@link java.lang.Integer Integer}, a {@link java.lang.Float Float}, a * {@link java.lang.Long Long}, a {@link java.lang.Double Double} or a * {@link String String}. * @param attrs the non standard attributes of the field. */ public FieldNode ( final int access, final String name, final String desc, final Object value, final Attribute attrs) { this.access = access; this.name = name; this.desc = desc; this.value = value; this.attrs = attrs; } /** * Makes the given class visitor visit this field. * * @param cv a class visitor. */ public void accept (final ClassVisitor cv) { cv.visitField(access, name, desc, value, attrs); } } --- NEW FILE: IincInsnNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.CodeVisitor; import org.logicalcobwebs.asm.Constants; /** * A node that represents an IINC instruction. */ public class IincInsnNode extends AbstractInsnNode { /** * Index of the local variable to be incremented. */ public int var; /** * Amount to increment the local variable by. */ public int incr; /** * Constructs a new {@link IincInsnNode IincInsnNode} node. * * @param var index of the local variable to be incremented. * @param incr increment amount to increment the local variable by. */ public IincInsnNode (final int var, final int incr) { super(Constants.IINC); this.var = var; this.incr = incr; } public void accept (final CodeVisitor cv) { cv.visitIincInsn(var, incr); } } --- NEW FILE: InnerClassNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.ClassVisitor; /** * A node that represents an inner class. */ public class InnerClassNode { /** * The internal name of an inner class (see {@link * org.logicalcobwebs.asm.Type#getInternalName getInternalName}). */ public String name; /** * The internal name of the class to which the inner class belongs (see * {@link org.logicalcobwebs.asm.Type#getInternalName getInternalName}). May be * <tt>null</tt>. */ public String outerName; /** * The (simple) name of the inner class inside its enclosing class. May be * <tt>null</tt> for anonymous inner classes. */ public String innerName; /** * The access flags of the inner class as originally declared in the enclosing * class. */ public int access; /** * Constructs a new {@link InnerClassNode InnerClassNode} object. * * @param name the internal name of an inner class (see {@link * org.logicalcobwebs.asm.Type#getInternalName getInternalName}). * @param outerName the internal name of the class to which the inner class * belongs (see {@link org.logicalcobwebs.asm.Type#getInternalName * getInternalName}). May be <tt>null</tt>. * @param innerName the (simple) name of the inner class inside its enclosing * class. May be <tt>null</tt> for anonymous inner classes. * @param access the access flags of the inner class as originally declared * in the enclosing class. */ public InnerClassNode ( final String name, final String outerName, final String innerName, final int access) { this.name = name; this.outerName = outerName; this.innerName = innerName; this.access = access; } /** * Makes the given class visitor visit this inner class. * * @param cv a class visitor. */ public void accept (final ClassVisitor cv) { cv.visitInnerClass(name, outerName, innerName, access); } } --- NEW FILE: InsnNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.CodeVisitor; /** * A node that represents a zero operand instruction. */ public class InsnNode extends AbstractInsnNode { /** * Constructs a new {@link InsnNode InsnNode} object. * * @param opcode the opcode of the instruction to be constructed. This opcode * must be NOP, ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1, ICONST_2, * ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1, FCONST_0, FCONST_1, * FCONST_2, DCONST_0, DCONST_1, * * IALOAD, LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD, * IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE, * SASTORE, * * POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, SWAP, * * IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB, IMUL, LMUL, FMUL, * DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM, FREM, DREM, INEG, LNEG, * FNEG, DNEG, ISHL, LSHL, ISHR, LSHR, IUSHR, LUSHR, IAND, LAND, IOR, * LOR, IXOR, LXOR, * * I2L, I2F, I2D, L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C, * I2S, * * LCMP, FCMPL, FCMPG, DCMPL, DCMPG, * * IRETURN, LRETURN, FRETURN, DRETURN, ARETURN, RETURN, * * ARRAYLENGTH, * * ATHROW, * * MONITORENTER, or MONITOREXIT. */ public InsnNode (final int opcode) { super(opcode); } /** * Sets the opcode of this instruction. * * @param opcode the new instruction opcode. This opcode must be NOP, * ACONST_NULL, ICONST_M1, ICONST_0, ICONST_1, ICONST_2, * ICONST_3, ICONST_4, ICONST_5, LCONST_0, LCONST_1, FCONST_0, FCONST_1, * FCONST_2, DCONST_0, DCONST_1, * * IALOAD, LALOAD, FALOAD, DALOAD, AALOAD, BALOAD, CALOAD, SALOAD, * IASTORE, LASTORE, FASTORE, DASTORE, AASTORE, BASTORE, CASTORE, * SASTORE, * * POP, POP2, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, SWAP, * * IADD, LADD, FADD, DADD, ISUB, LSUB, FSUB, DSUB, IMUL, LMUL, FMUL, * DMUL, IDIV, LDIV, FDIV, DDIV, IREM, LREM, FREM, DREM, INEG, LNEG, * FNEG, DNEG, ISHL, LSHL, ISHR, LSHR, IUSHR, LUSHR, IAND, LAND, IOR, * LOR, IXOR, LXOR, * * I2L, I2F, I2D, L2I, L2F, L2D, F2I, F2L, F2D, D2I, D2L, D2F, I2B, I2C, * I2S, * * LCMP, FCMPL, FCMPG, DCMPL, DCMPG, * * IRETURN, LRETURN, FRETURN, DRETURN, ARETURN, RETURN, * * ARRAYLENGTH, * * ATHROW, * * MONITORENTER, or MONITOREXIT. */ public void setOpcode (final int opcode) { this.opcode = opcode; } /** * Makes the given code visitor visit this instruction. */ public void accept (final CodeVisitor cv) { cv.visitInsn(opcode); } } --- NEW FILE: IntInsnNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.CodeVisitor; /** * A node that represents an instruction with a single int operand. */ public class IntInsnNode extends AbstractInsnNode { /** * The operand of this instruction. */ public int operand; /** * Constructs a new {@link IntInsnNode IntInsnNode} object. * * @param opcode the opcode of the instruction to be constructed. This opcode * must be BIPUSH, SIPUSH or NEWARRAY. * @param operand the operand of the instruction to be constructed. */ public IntInsnNode (final int opcode, final int operand) { super(opcode); this.operand = operand; } /** * Sets the opcode of this instruction. * * @param opcode the new instruction opcode. This opcode must be BIPUSH, * SIPUSH or NEWARRAY. */ public void setOpcode (final int opcode) { this.opcode = opcode; } public void accept (final CodeVisitor cv) { cv.visitIntInsn(opcode, operand); } } --- NEW FILE: JumpInsnNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.Label; import org.logicalcobwebs.asm.CodeVisitor; /** * A node that represents a jump instruction. A jump instruction is an * instruction that may jump to another instruction. */ public class JumpInsnNode extends AbstractInsnNode { /** * The operand of this instruction. This operand is a label that designates * the instruction to which this instruction may jump. */ public Label label; /** * Constructs a new {@link JumpInsnNode JumpInsnNode} object. * * @param opcode the opcode of the type instruction to be constructed. This * opcode must be IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, * IF_ICMPNE, IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, * IF_ACMPNE, GOTO, JSR, IFNULL or IFNONNULL. * @param label the operand of the instruction to be constructed. This operand * is a label that designates the instruction to which the jump * instruction may jump. */ public JumpInsnNode (final int opcode, final Label label) { super(opcode); this.label = label; } /** * Sets the opcode of this instruction. * * @param opcode the new instruction opcode. This opcode must be * IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, * IF_ICMPLT, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE, * GOTO, JSR, IFNULL or IFNONNULL. */ public void setOpcode (final int opcode) { this.opcode = opcode; } public void accept (final CodeVisitor cv) { cv.visitJumpInsn(opcode, label); } } --- NEW FILE: LdcInsnNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.CodeVisitor; import org.logicalcobwebs.asm.Constants; /** * A node that represents an LDC instruction. */ public class LdcInsnNode extends AbstractInsnNode { /** * The constant to be loaded on the stack. This parameter must be a non null * {@link java.lang.Integer Integer}, a {@link java.lang.Float Float}, a * {@link java.lang.Long Long}, a {@link java.lang.Double Double} or a {@link * String String}. */ public Object cst; /** * Constructs a new {@link LdcInsnNode LdcInsnNode} object. * * @param cst the constant to be loaded on the stack. This parameter must be * a non null {@link java.lang.Integer Integer}, a {@link java.lang.Float * Float}, a {@link java.lang.Long Long}, a {@link java.lang.Double * Double} or a {@link String String}. */ public LdcInsnNode (final Object cst) { super(Constants.LDC); this.cst = cst; } public void accept (final CodeVisitor cv) { cv.visitLdcInsn(cst); } } --- NEW FILE: LineNumberNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.Label; import org.logicalcobwebs.asm.CodeVisitor; /** * A node that represents a line number declaration. */ public class LineNumberNode { /** * A line number. This number refers to the source file from which the class * was compiled. */ public int line; /** * The first instruction corresponding to this line number. */ public Label start; /** * Constructs a new {@link LineNumberNode LineNumberNode} object. * * @param line a line number. This number refers to the source file * from which the class was compiled. * @param start the first instruction corresponding to this line number. */ public LineNumberNode (final int line, final Label start) { this.line = line; this.start = start; } /** * Makes the given code visitor visit this line number declaration. * * @param cv a code visitor. */ public void accept (final CodeVisitor cv) { cv.visitLineNumber(line, start); } } --- NEW FILE: LocalVariableNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.CodeVisitor; import org.logicalcobwebs.asm.Label; /** * A node that represents a local variable declaration. */ public class LocalVariableNode { /** * The name of a local variable. */ public String name; /** * The type descriptor of this local variable. */ public String desc; /** * The first instruction corresponding to the scope of this local variable * (inclusive). */ public Label start; /** * The last instruction corresponding to the scope of this local variable * (exclusive). */ public Label end; /** * The local variable's index. */ public int index; /** * Constructs a new {@link LocalVariableNode LocalVariableNode} object. * * @param name the name of a local variable. * @param desc the type descriptor of this local variable. * @param start the first instruction corresponding to the scope of this * local variable (inclusive). * @param end the last instruction corresponding to the scope of this * local variable (exclusive). * @param index the local variable's index. */ public LocalVariableNode ( final String name, final String desc, final Label start, final Label end, final int index) { this.name = name; this.desc = desc; this.start = start; this.end = end; this.index = index; } /** * Makes the given code visitor visit this local variable declaration. * * @param cv a code visitor. */ public void accept (final CodeVisitor cv) { cv.visitLocalVariable(name, desc, start, end, index); } } --- NEW FILE: LookupSwitchInsnNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.Label; import org.logicalcobwebs.asm.Constants; import org.logicalcobwebs.asm.CodeVisitor; import java.util.List; import java.util.ArrayList; import java.util.Arrays; /** * A node that represents a LOOKUPSWITCH instruction. */ public class LookupSwitchInsnNode extends AbstractInsnNode { /** * Beginning of the default handler block. */ public Label dflt; /** * The values of the keys. This list is a list a {@link java.lang.Integer * Integer} objects. */ public final List keys; /** * Beginnings of the handler blocks. This list is a list of {@link Label * Label} objects. */ public final List labels; /** * Constructs a new {@link LookupSwitchInsnNode LookupSwitchInsnNode} object. * * @param dflt beginning of the default handler block. * @param keys the values of the keys. * @param labels beginnings of the handler blocks. <tt>labels[i]</tt> is the * beginning of the handler block for the <tt>keys[i]</tt> key. */ public LookupSwitchInsnNode ( final Label dflt, final int[] keys, final Label[] labels) { super(Constants.LOOKUPSWITCH); this.dflt = dflt; this.keys = new ArrayList(); this.labels = new ArrayList(); if (keys != null) { for (int i = 0; i < keys.length; ++i) { this.keys.add(new Integer(keys[i])); } } if (labels != null) { this.labels.addAll(Arrays.asList(labels)); } } public void accept (final CodeVisitor cv) { int[] keys = new int[this.keys.size()]; for (int i = 0; i < keys.length; ++i) { keys[i] = ((Integer)this.keys.get(i)).intValue(); } Label[] labels = new Label[this.labels.size()]; this.labels.toArray(labels); cv.visitLookupSwitchInsn(dflt, keys, labels); } } --- NEW FILE: MethodInsnNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.CodeVisitor; /** * A node that represents a method instruction. A method instruction is an * instruction that invokes a method. */ public class MethodInsnNode extends AbstractInsnNode { /** * The internal name of the method's owner class (see {@link * org.logicalcobwebs.asm.Type#getInternalName getInternalName}). */ public String owner; /** * The method's name. */ public String name; /** * The method's descriptor (see {@link org.logicalcobwebs.asm.Type Type}). */ public String desc; /** * Constructs a new {@link MethodInsnNode MethodInsnNode} object. * * @param opcode the opcode of the type instruction to be constructed. This * opcode must be INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or * INVOKEINTERFACE. * @param owner the internal name of the method's owner class (see {@link * org.logicalcobwebs.asm.Type#getInternalName getInternalName}). * @param name the method's name. * @param desc the method's descriptor (see {@link org.logicalcobwebs.asm.Type * Type}). */ public MethodInsnNode ( final int opcode, final String owner, final String name, final String desc) { super(opcode); this.owner = owner; this.name = name; this.desc = desc; } /** * Sets the opcode of this instruction. * * @param opcode the new instruction opcode. This opcode must be * INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE. */ public void setOpcode (final int opcode) { this.opcode = opcode; } public void accept (final CodeVisitor cv) { cv.visitMethodInsn(opcode, owner, name, desc); } } --- NEW FILE: MethodNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.ClassVisitor; import org.logicalcobwebs.asm.CodeVisitor; import org.logicalcobwebs.asm.Label; import org.logicalcobwebs.asm.Attribute; import java.util.List; import java.util.ArrayList; import java.util.Arrays; /** * A node that represents a method. */ public class MethodNode { /** * The method's access flags (see {@link org.logicalcobwebs.asm.Constants}). This * field also indicates if the method is synthetic and/or deprecated. */ public int access; /** * The method's name. */ public String name; /** * The method's descriptor (see {@link org.logicalcobwebs.asm.Type Type}). */ public String desc; /** * The internal names of the method's exception classes (see {@link * org.logicalcobwebs.asm.Type#getInternalName getInternalName}). This list is a * list of {@link String} objects. */ public final List exceptions; /** * The non standard attributes of the method. */ public Attribute attrs; /** * The instructions of this method. This list is a list of {@link * AbstractInsnNode AbstractInsnNode} and {@link Label Label} objects. */ public final List instructions; /** * The try catch blocks of this method. This list is a list of {@link * TryCatchBlockNode TryCatchBlockNode} objects. */ public final List tryCatchBlocks; /** * The maximum stack size of this method. */ public int maxStack; /** * The maximum number of local variables of this method. */ public int maxLocals; /** * The local variables of this method. This list is a list of {@link * LocalVariableNode LocalVariableNode} objects. */ public final List localVariables; /** * The line numbers of this method. This list is a list of {@link * LineNumberNode LineNumberNode} objects. */ public final List lineNumbers; /** * The non standard attributes of the method's code. */ public Attribute codeAttrs; /** * Constructs a new {@link MethodNode MethodNode} object. * * @param access the method's access flags (see {@link * org.logicalcobwebs.asm.Constants}). This parameter also indicates if the * method is synthetic and/or deprecated. * @param name the method's name. * @param desc the method's descriptor (see {@link org.logicalcobwebs.asm.Type * Type}). * @param exceptions the internal names of the method's exception * classes (see {@link org.logicalcobwebs.asm.Type#getInternalName * getInternalName}). May be <tt>null</tt>. * @param attrs the non standard attributes of the method. */ public MethodNode ( final int access, final String name, final String desc, final String[] exceptions, final Attribute attrs) { this.access = access; this.name = name; this.desc = desc; this.exceptions = new ArrayList(); this.instructions = new ArrayList(); this.tryCatchBlocks = new ArrayList(); this.localVariables = new ArrayList(); this.lineNumbers = new ArrayList(); if (exceptions != null) { this.exceptions.addAll(Arrays.asList(exceptions)); } this.attrs = attrs; } /** * Makes the given class visitor visit this method. * * @param cv a class visitor. */ public void accept (final ClassVisitor cv) { String[] exceptions = new String[this.exceptions.size()]; this.exceptions.toArray(exceptions); CodeVisitor mv = cv.visitMethod(access, name, desc, exceptions, attrs); if (mv != null && instructions.size() > 0) { int i; // visits instructions for (i = 0; i < instructions.size(); ++i) { Object insn = instructions.get(i); if (insn instanceof Label) { mv.visitLabel((Label)insn); } else { ((AbstractInsnNode)insn).accept(mv); } } // visits try catch blocks for (i = 0; i < tryCatchBlocks.size(); ++i) { ((TryCatchBlockNode)tryCatchBlocks.get(i)).accept(mv); } // visits maxs mv.visitMaxs(maxStack, maxLocals); // visits local variables for (i = 0; i < localVariables.size(); ++i) { ((LocalVariableNode)localVariables.get(i)).accept(mv); } // visits line numbers for (i = 0; i < lineNumbers.size(); ++i) { ((LineNumberNode)lineNumbers.get(i)).accept(mv); } // visits the code attributes Attribute attrs = codeAttrs; while (attrs != null) { mv.visitAttribute(attrs); attrs = attrs.next; } } } } --- NEW FILE: MultiANewArrayInsnNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * * Contact: Eri...@rd... * * Author: Eric Bruneton */ package org.logicalcobwebs.asm.tree; import org.logicalcobwebs.asm.Constants; import org.logicalcobwebs.asm.CodeVisitor; /** * A node that represents a MULTIANEWARRAY instruction. */ public class MultiANewArrayInsnNode extends AbstractInsnNode { /** * An array type descriptor (see {@link org.logicalcobwebs.asm.Type Type}). */ public String desc; /** * Number of dimensions of the array to allocate. */ public int dims; /** * Constructs a new {@link MultiANewArrayInsnNode MultiANewArrayInsnNode} * object. * * @param desc an array type descriptor (see {@link org.logicalcobwebs.asm.Type * Type}). * @param dims number of dimensions of the array to allocate. */ public MultiANewArrayInsnNode (final String desc, final int dims) { super(Constants.MULTIANEWARRAY); this.desc = desc; this.dims = dims; } public void accept (final CodeVisitor cv) { cv.visitMultiANewArrayInsn(desc, dims); } } --- NEW FILE: TableSwitchInsnNode.java --- /*** * ASM: a very small and fast Java bytecode manipulation framework * Copyright (c) 2000,2002,2003 INRIA, France Telecom * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ... [truncated message content] |
From: <bil...@us...> - 2003-12-12 19:06:17
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/asm/util In directory sc8-pr-cvs1:/tmp/cvs-serv20900/src/java/org/logicalcobwebs/asm/util Log Message: Directory /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/asm/util added to the repository |
From: <bil...@us...> - 2003-12-12 19:05:00
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/asm/tree In directory sc8-pr-cvs1:/tmp/cvs-serv20577/src/java/org/logicalcobwebs/asm/tree Log Message: Directory /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/asm/tree added to the repository |
From: <bil...@us...> - 2003-12-12 19:04:54
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/asm In directory sc8-pr-cvs1:/tmp/cvs-serv20544/src/java/org/logicalcobwebs/asm Log Message: Directory /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/asm added to the repository |
From: <bil...@us...> - 2003-12-10 20:14:44
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/cglib In directory sc8-pr-cvs1:/tmp/cvs-serv20199/src/java/org/logicalcobwebs/cglib Log Message: Directory /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/cglib added to the repository |
From: <bil...@us...> - 2003-12-09 18:54:59
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv25223/src/java/org/logicalcobwebs/proxool Modified Files: ConnectionPool.java Log Message: Make closure of statement during connection test more robust - credit to John Hume Index: ConnectionPool.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ConnectionPool.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** ConnectionPool.java 4 Nov 2003 13:52:01 -0000 1.72 --- ConnectionPool.java 9 Dec 2003 18:54:55 -0000 1.73 *************** *** 286,293 **** removeProxyConnection(proxyConnection, "it has problems: " + t, ConnectionPool.REQUEST_EXPIRY, true); } finally { ! try { ! s.close(); ! } catch (SQLException e) { ! // Ignore } } --- 286,296 ---- removeProxyConnection(proxyConnection, "it has problems: " + t, ConnectionPool.REQUEST_EXPIRY, true); } finally { ! if (s != null) { ! try { ! s.close(); ! } catch (Throwable t) { ! // Ignore ! success = false; ! } } } *************** *** 1090,1093 **** --- 1093,1099 ---- Revision history: $Log$ + Revision 1.73 2003/12/09 18:54:55 billhorsman + Make closure of statement during connection test more robust - credit to John Hume + Revision 1.72 2003/11/04 13:52:01 billhorsman Fixed warning message |
From: <bil...@us...> - 2003-12-09 18:52:23
|
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv24435/src/java-test/org/logicalcobwebs/proxool Modified Files: ProxyStatementTest.java Log Message: checkstyle Index: ProxyStatementTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/ProxyStatementTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ProxyStatementTest.java 5 Nov 2003 00:00:52 -0000 1.7 --- ProxyStatementTest.java 9 Dec 2003 18:52:19 -0000 1.8 *************** *** 11,15 **** import java.sql.Connection; import java.sql.DriverManager; - import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; --- 11,14 ---- *************** *** 88,91 **** --- 87,93 ---- Revision history: $Log$ + Revision 1.8 2003/12/09 18:52:19 billhorsman + checkstyle + Revision 1.7 2003/11/05 00:00:52 billhorsman Remove redundant test (already in FatalSqlExceptionTest) |
From: <be...@us...> - 2003-12-02 16:39:03
|
Update of /cvsroot/proxool/proxool-doc/src/docs In directory sc8-pr-cvs1:/tmp/cvs-serv20217/src/docs Modified Files: faq.xml home.xml layout.xml Log Message: To work with website, we must make all our documents <webpage>s instead of <article>s. These are referenced from layout.xml. The ant target to use is generate-website Index: faq.xml =================================================================== RCS file: /cvsroot/proxool/proxool-doc/src/docs/faq.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** faq.xml 27 Feb 2003 02:42:52 -0000 1.1 --- faq.xml 2 Dec 2003 16:38:59 -0000 1.2 *************** *** 2,15 **** PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> ! <article> ! <articleinfo> ! <title>Frequently Asked Questions</title> ! <abstract> ! <para> ! A collection of commonly asked questions about Proxool. ! </para> ! </abstract> ! </articleinfo> <qandaset defaultlabel='qanda'> --- 2,11 ---- PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> ! <webpage id="faq"> ! <head> ! <title>FAQ</title> ! <summary>Site Navigation Layout Setup</summary> ! </head> <qandaset defaultlabel='qanda'> *************** *** 145,147 **** </qandaset> ! </article> \ No newline at end of file --- 141,143 ---- </qandaset> ! </webpage> \ No newline at end of file Index: home.xml =================================================================== RCS file: /cvsroot/proxool/proxool-doc/src/docs/home.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** home.xml 12 Nov 2003 10:12:03 -0000 1.2 --- home.xml 2 Dec 2003 16:38:59 -0000 1.3 *************** *** 2,15 **** PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> ! <article id="home"> ! ! <articleinfo> ! <title>Proxool - a Java JDBC connection pool</title> ! <abstract> ! <para> ! The Proxool web site home page. ! </para> ! </abstract> ! </articleinfo> --- 2,10 ---- PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> ! <webpage id="home"> ! <head> ! <title>Site Layout</title> ! <summary>Site Navigation Layout Setup</summary> ! </head> *************** *** 102,108 **** </para> ! <index> ! <title>hello</title> ! </index> ! ! </article> \ No newline at end of file --- 97,99 ---- </para> ! </webpage> \ No newline at end of file Index: layout.xml =================================================================== RCS file: /cvsroot/proxool/proxool-doc/src/docs/layout.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** layout.xml 12 Nov 2003 10:12:03 -0000 1.1 --- layout.xml 2 Dec 2003 16:39:00 -0000 1.2 *************** *** 1,9 **** ! <?xml version="1.0"?> ! <!--<!DOCTYPE layout PUBLIC "-//Norman Walsh//DTD Website Layout V2.4.0//EN"--> ! <!-- "http://docbook.sourceforge.net/release/website/2.4.0/schema/dtd/layout.dtd">--> <layout> <toc page="home.xml" filename="index.html"> ! </toc> </layout> --- 1,11 ---- ! <!DOCTYPE layout PUBLIC "-//Norman Walsh//DTD Website Layout V2.4.0//EN" ! "http://docbook.sourceforge.net/release/website/2.4.0/schema/dtd/layout.dtd"> <layout> <toc page="home.xml" filename="index.html"> ! <tocentry page="faq.xml" filename="faq.html"/> ! <tocentry id="nwalsh.com" href="http://nwalsh.com/"> ! <title>nwalsh.com</title> ! </tocentry> </toc> </layout> |
From: <be...@us...> - 2003-12-02 16:39:03
|
Update of /cvsroot/proxool/proxool-doc In directory sc8-pr-cvs1:/tmp/cvs-serv20217 Modified Files: build.xml Log Message: To work with website, we must make all our documents <webpage>s instead of <article>s. These are referenced from layout.xml. The ant target to use is generate-website Index: build.xml =================================================================== RCS file: /cvsroot/proxool/proxool-doc/build.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** build.xml 12 Nov 2003 10:12:03 -0000 1.2 --- build.xml 2 Dec 2003 16:38:59 -0000 1.3 *************** *** 38,48 **** <!-- Unzip the Dobbook XSLT and DTD archives to the build director --> <unzip src="${lib.home}/docbook-xml-${docbook.dtd.version}.zip" ! dest="${build.home}/docbook-dtd-${docbook.dtd.version}"/> <unzip src="${lib.home}/docbook-xsl-${docbook.xsl.version}.zip" ! dest="${build.home}"/> <unzip src="${lib.home}/website-${website.version}.zip" ! dest="${build.home}"/> </target> --- 38,54 ---- <!-- Unzip the Dobbook XSLT and DTD archives to the build director --> <unzip src="${lib.home}/docbook-xml-${docbook.dtd.version}.zip" ! dest="${build.home}/docbook-dtd-${docbook.dtd.version}" ! overwrite="false" ! /> <unzip src="${lib.home}/docbook-xsl-${docbook.xsl.version}.zip" ! dest="${build.home}" ! overwrite="false" ! /> <unzip src="${lib.home}/website-${website.version}.zip" ! dest="${build.home}" ! overwrite="false" ! /> </target> *************** *** 86,91 **** <xslt basedir="${build.home}/website-xsl" ! style="${build.home}/website-${website.version}/xsl/tabular.xsl" ! excludes="autolayout.xml" destdir="${build.home}/website/html" extension=".html" --- 92,97 ---- <xslt basedir="${build.home}/website-xsl" ! style="${build.home}/website-${website.version}/xsl/chunk-tabular.xsl" ! includes="autolayout.xml" destdir="${build.home}/website/html" extension=".html" |
From: <ch...@us...> - 2003-11-16 18:20:11
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv4561 Modified Files: ShutdownHook.java Log Message: Started calling to Exception.getCause() via refletion to maintain compilability with < jdk 1.4 compilers. Index: ShutdownHook.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/ShutdownHook.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ShutdownHook.java 27 Oct 2003 12:32:06 -0000 1.9 --- ShutdownHook.java 16 Nov 2003 18:19:14 -0000 1.10 *************** *** 37,42 **** Runtime runtime = Runtime.getRuntime(); try { ! Method addShutdownHookMethod = Runtime.class.getMethod("removeShutdownHook", new Class[] {Thread.class}); ! addShutdownHookMethod.invoke(runtime, new Object[] {t}); if (LOG.isDebugEnabled()) { LOG.debug("Removed shutdownHook"); --- 37,42 ---- Runtime runtime = Runtime.getRuntime(); try { ! final Method removeShutdownHookMethod = Runtime.class.getMethod("removeShutdownHook", new Class[] {Thread.class}); ! removeShutdownHookMethod.invoke(runtime, new Object[] {t}); if (LOG.isDebugEnabled()) { LOG.debug("Removed shutdownHook"); *************** *** 49,57 **** LOG.error("Problem removing shutdownHook", e); } catch (InvocationTargetException e) { ! if (e.getCause() instanceof IllegalStateException) { ! // This is probably because a shutdown is in progress. We can ! // safely ignore that. ! } else { ! LOG.error("Problem removing shutdownHook", e); } } --- 49,64 ---- LOG.error("Problem removing shutdownHook", e); } catch (InvocationTargetException e) { ! final Object o; ! try { ! final Method getCauseMethod = Runtime.class.getMethod("getCause", null); ! o = getCauseMethod.invoke(e, null); ! if (o != null && o instanceof IllegalStateException) { ! // This is probably because a shutdown is in progress. We can ! // safely ignore that. ! } else { ! LOG.error("Problem removing shutdownHook", e); ! } ! } catch (Exception ex) { ! LOG.error("Problem calling \"get cause\" on IllegalStateException.", e); } } *************** *** 99,102 **** --- 106,112 ---- Revision history: $Log$ + Revision 1.10 2003/11/16 18:19:14 chr32 + Started calling to Exception.getCause() via refletion to maintain compilability with < jdk 1.4 compilers. + Revision 1.9 2003/10/27 12:32:06 billhorsman Fixed typos and silently ignore IllegalStateException during shutdownHook removal (it's probably because |
From: <be...@us...> - 2003-11-12 10:12:26
|
Update of /cvsroot/proxool/proxool-doc In directory sc8-pr-cvs1:/tmp/cvs-serv3621 Modified Files: build.xml Log Message: First cut of Website targets in build.xml, with necessary changes and a new layout file Index: build.xml =================================================================== RCS file: /cvsroot/proxool/proxool-doc/build.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** build.xml 27 Feb 2003 02:42:51 -0000 1.1 --- build.xml 12 Nov 2003 10:12:03 -0000 1.2 *************** *** 17,20 **** --- 17,21 ---- <property name="docbook.dtd.version" value="4.2"/> <property name="docbook.xsl.version" value="1.60.1"/> + <property name="website.version" value="2.5.0"/> <xmlcatalog id="docbook"> *************** *** 27,31 **** <!-- ======================== Target: Prepare ========================= --> ! <target name="prepare" description="Prepares the project build environment."> --- 28,34 ---- <!-- ======================== Target: Prepare ========================= --> ! <target name="prepare"/> ! ! <target name="sprepare" description="Prepares the project build environment."> *************** *** 39,42 **** --- 42,49 ---- <unzip src="${lib.home}/docbook-xsl-${docbook.xsl.version}.zip" dest="${build.home}"/> + + <unzip src="${lib.home}/website-${website.version}.zip" + dest="${build.home}"/> + </target> *************** *** 55,58 **** --- 62,96 ---- + </target> + + <target name="generate.website-autolayout" + description="Generates the autolayout file used in the Website generation" + > + <xslt basedir="${src.docs}" + in="${src.docs}/layout.xml" + out="${build.home}/website-xsl/autolayout.xml" + style="${build.home}/website-${website.version}/xsl/autolayout.xsl"> + <xmlcatalog refid="docbook"/> + </xslt> + <copy todir="${build.home}/website-xsl"> + <fileset dir="${src.docs}"> + <include name="**/*.xml"/> + </fileset> + </copy> + + </target> + + <target name="generate.website" depends="generate.website-autolayout" + description="Generates the HTML website using the Website Tabular style" + > + <xslt + basedir="${build.home}/website-xsl" + style="${build.home}/website-${website.version}/xsl/tabular.xsl" + excludes="autolayout.xml" + destdir="${build.home}/website/html" + extension=".html" + followsymlinks="false" + > + </xslt> </target> |
From: <be...@us...> - 2003-11-12 10:08:32
|
Update of /cvsroot/proxool/proxool-doc/lib In directory sc8-pr-cvs1:/tmp/cvs-serv2903 Added Files: website-2.5.0.zip Log Message: From docbook.sf.net --- NEW FILE: website-2.5.0.zip --- (This appears to be a binary file; contents omitted.) |
From: <bil...@us...> - 2003-11-05 11:22:50
|
Update of /cvsroot/proxool/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv23484 Modified Files: CHANGES.txt Log Message: no message Index: CHANGES.txt =================================================================== RCS file: /cvsroot/proxool/proxool/CHANGES.txt,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** CHANGES.txt 5 Nov 2003 00:19:48 -0000 1.30 --- CHANGES.txt 5 Nov 2003 11:22:41 -0000 1.31 *************** *** 6,10 **** $Author$ ! 0.8.2 - 4 November 2003 - Fixed bug where delegate properties weren't being passed onto the delegate driver. If you weren't --- 6,10 ---- $Author$ ! 0.8.2 - 5 November 2003 - Fixed bug where delegate properties weren't being passed onto the delegate driver. If you weren't |
From: <bil...@us...> - 2003-11-05 00:19:52
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv25518/src/java/org/logicalcobwebs/proxool Modified Files: Version.java Log Message: new revision Index: Version.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/Version.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Version.java 27 Oct 2003 13:13:58 -0000 1.16 --- Version.java 5 Nov 2003 00:19:48 -0000 1.17 *************** *** 40,44 **** private static final String BUILD_DATE = null; ! private static final String CVS = "0.8.1+"; public static String getVersion() { --- 40,44 ---- private static final String BUILD_DATE = null; ! private static final String CVS = "0.8.2+"; public static String getVersion() { *************** *** 77,80 **** --- 77,83 ---- Revision history: $Log$ + Revision 1.17 2003/11/05 00:19:48 billhorsman + new revision + Revision 1.16 2003/10/27 13:13:58 billhorsman new version |
From: <bil...@us...> - 2003-11-05 00:19:51
|
Update of /cvsroot/proxool/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv25518 Modified Files: CHANGES.txt build.xml Log Message: new revision Index: CHANGES.txt =================================================================== RCS file: /cvsroot/proxool/proxool/CHANGES.txt,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** CHANGES.txt 27 Oct 2003 13:13:58 -0000 1.29 --- CHANGES.txt 5 Nov 2003 00:19:48 -0000 1.30 *************** *** 6,10 **** $Author$ ! 0.8.1 - October 27, 2003 - NullPointerException that occured during SQL logging for certain methods --- 6,24 ---- $Author$ ! 0.8.2 - 4 November 2003 ! ! - Fixed bug where delegate properties weren't being passed onto the delegate driver. If you weren't ! passing any properties other than username and password to the delegate driver then this didn't ! cause a problem anyway. (Note that Proxool properties were being recognised correctly.) Added a ! new unit test specifically for this problem. ! ! - Throw a friendlier exception if you try and add a statistics listener to a pool with ! no statistics ! ! - Statistics now creates write locks less often. This was causing a problem during heavy loads ! even though the process of collecting statistics itself was very fast. If you had statistics ! turned off (the default) then this wasn't a problem anyway. ! ! 0.8.1 - 27 October 2003 - NullPointerException that occured during SQL logging for certain methods *************** *** 16,20 **** during removal of shutdownHook that occurs during JVM shut down. ! 0.8.0 - October 26, 2003 - We now use Cglib's proxy library. Together with dropping the use of Timer --- 30,34 ---- during removal of shutdownHook that occurs during JVM shut down. ! 0.8.0 - 26 October 2003 - We now use Cglib's proxy library. Together with dropping the use of Timer *************** *** 83,87 **** - Batched statements are now correctly reported with the trace feature. ! 0.7.2 - April 28, 2003 - Moved DataSourceTest into Sandbox so that the Ant test target --- 97,101 ---- - Batched statements are now correctly reported with the trace feature. ! 0.7.2 - 28 April 2003 - Moved DataSourceTest into Sandbox so that the Ant test target *************** *** 93,97 **** when there was no change, and didn't call it when there was. ! 0.7.1 - April 19, 2003 - Added a lot of concurrency code - mainly using concurrent package --- 107,111 ---- when there was no change, and didn't call it when there was. ! 0.7.1 - 19 April 2003 - Added a lot of concurrency code - mainly using concurrent package *************** *** 134,138 **** definition had changed. ! 0.7 - February 21, 2003 - We have dropped the dependency on commons-logging.jar --- 148,152 ---- definition had changed. ! 0.7 - 21 February 2003 - We have dropped the dependency on commons-logging.jar *************** *** 181,185 **** house-keeper-test-sql) rather than waiting for the next scheduled sweep. ! 0.6 (January 23, 2003) - ProxoolFacade API has changed slightly. Some of the methods no --- 195,199 ---- house-keeper-test-sql) rather than waiting for the next scheduled sweep. ! 0.6 - 23 January 2003 - ProxoolFacade API has changed slightly. Some of the methods no *************** *** 226,230 **** See ProxoolFacade#updateConnectionPool. ! 0.5 (December 3, 2002) - Fix finalisation of old instances. If you deploy to some environments in --- 240,244 ---- See ProxoolFacade#updateConnectionPool. ! 0.5 - 3 December 2002) - Fix finalisation of old instances. If you deploy to some environments in *************** *** 281,285 **** that encounter certain types of exception. ! 0.4 - September 19, 2002 - Rethink of how we organise our source code so that we can easily build --- 295,299 ---- that encounter certain types of exception. ! 0.4 - 19 September 2002 - Rethink of how we organise our source code so that we can easily build Index: build.xml =================================================================== RCS file: /cvsroot/proxool/proxool/build.xml,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** build.xml 27 Oct 2003 13:13:58 -0000 1.66 --- build.xml 5 Nov 2003 00:19:48 -0000 1.67 *************** *** 27,31 **** <!-- Currect release, e.g. 0.6 --> ! <property name="release" value="0.8.1"/> <!-- Currect release, e.g. 0.6 --> --- 27,31 ---- <!-- Currect release, e.g. 0.6 --> ! <property name="release" value="0.8.2"/> <!-- Currect release, e.g. 0.6 --> *************** *** 277,280 **** --- 277,281 ---- <jvmarg line="${jvmargs}"/> </java> + <echo message="Note! These unit tests have probably produced some worrying exceptions. As long as the tests passed then you can ignore these exceptions. They are part of the tests."/> </target> |
From: <bil...@us...> - 2003-11-05 00:00:57
|
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv22051/src/java-test/org/logicalcobwebs/proxool Modified Files: ProxyStatementTest.java Log Message: Remove redundant test (already in FatalSqlExceptionTest) Index: ProxyStatementTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/ProxyStatementTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ProxyStatementTest.java 27 Aug 2003 18:03:20 -0000 1.6 --- ProxyStatementTest.java 5 Nov 2003 00:00:52 -0000 1.7 *************** *** 82,115 **** } - public void testFatalSqlException() throws Exception { - - String testName = "fatalSqlException"; - String alias = testName; - - String url = TestHelper.buildProxoolUrl(alias, - TestConstants.HYPERSONIC_DRIVER, - TestConstants.HYPERSONIC_TEST_URL); - Properties info = new Properties(); - info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); - info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); - info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, "not found"); - ProxoolFacade.registerConnectionPool(url, info); - - Connection c = DriverManager.getConnection(url); - ; - Statement s = c.createStatement(); - try { - s.execute("drop table foo"); - } catch (SQLException e) { - // Expected exception (foo doesn't exist) - LOG.debug("Excepted exception", e); - } - - c.close(); - - assertEquals("availableConnectionCount", 0L, ProxoolFacade.getSnapshot(alias, false).getAvailableConnectionCount()); - - } - } --- 82,85 ---- *************** *** 118,121 **** --- 88,94 ---- Revision history: $Log$ + Revision 1.7 2003/11/05 00:00:52 billhorsman + Remove redundant test (already in FatalSqlExceptionTest) + Revision 1.6 2003/08/27 18:03:20 billhorsman added new getDelegateConnection() method |
From: <bil...@us...> - 2003-11-04 23:58:52
|
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv21683/src/java-test/org/logicalcobwebs/proxool Modified Files: FatalSqlExceptionTest.java Log Message: Made more robust (against existing database state) Index: FatalSqlExceptionTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/FatalSqlExceptionTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FatalSqlExceptionTest.java 29 Sep 2003 17:50:45 -0000 1.4 --- FatalSqlExceptionTest.java 4 Nov 2003 23:58:48 -0000 1.5 *************** *** 42,53 **** Properties info = new Properties(); info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, "Table not found"); info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ProxoolFacade.registerConnectionPool(url, info); ! Connection c = null; try { ! c = DriverManager.getConnection(url); ! Statement s = c.createStatement(); s.execute("drop table Z"); } catch (SQLException e) { --- 42,67 ---- Properties info = new Properties(); info.setProperty(ProxoolConstants.FATAL_SQL_EXCEPTION_PROPERTY, "Table not found"); + info.setProperty(ProxoolConstants.VERBOSE_PROPERTY, String.valueOf(Boolean.TRUE)); + info.setProperty(ProxoolConstants.TRACE_PROPERTY, String.valueOf(Boolean.TRUE)); info.setProperty(ProxoolConstants.USER_PROPERTY, TestConstants.HYPERSONIC_USER); info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); ProxoolFacade.registerConnectionPool(url, info); ! Connection c1 = null; try { ! c1 = DriverManager.getConnection(url); ! } finally { ! if (c1 != null) { ! c1.close(); ! } ! } ! ! Connection c2 = null; ! try { ! c2 = DriverManager.getConnection(url); ! assertTrue("Expected same connection back", c1.equals(c2)); ! Statement s = c2.createStatement(); ! // Doing it twice will guarantee a failure. Even if it exists ! s.execute("drop table Z"); s.execute("drop table Z"); } catch (SQLException e) { *************** *** 55,73 **** // Expected exception (foo doesn't exist) LOG.debug("Expected exception (safe to ignore)", e); } try { ! if (c != null) { ! c.close(); } - } catch (SQLException e) { - LOG.debug("Couldn't close connection", e); } - Thread.sleep(1000); - - // Proxool should automatically throw away that connection that caused a fatal sql exception - assertEquals("availableConnectionCount", 0L, ProxoolFacade.getSnapshot(alias, false).getAvailableConnectionCount()); - } --- 69,88 ---- // Expected exception (foo doesn't exist) LOG.debug("Expected exception (safe to ignore)", e); + } finally { + if (c2 != null) { + c2.close(); + } } + Connection c3 = null; try { ! c3 = DriverManager.getConnection(url); ! assertTrue("Expected a different connection", !c2.equals(c3)); ! } finally { ! if (c3 != null) { ! c3.close(); } } } *************** *** 206,209 **** --- 221,227 ---- Revision history: $Log$ + Revision 1.5 2003/11/04 23:58:48 billhorsman + Made more robust (against existing database state) + Revision 1.4 2003/09/29 17:50:45 billhorsman Tests for new wrapper. |
From: <bil...@us...> - 2003-11-04 13:54:06
|
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv1745/src/java-test/org/logicalcobwebs/proxool Modified Files: DependencyCheck.java PerformanceTest.java Log Message: checkstyle Index: DependencyCheck.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/DependencyCheck.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DependencyCheck.java 25 Oct 2003 18:38:17 -0000 1.1 --- DependencyCheck.java 4 Nov 2003 13:54:02 -0000 1.2 *************** *** 11,15 **** import java.sql.DriverManager; - import java.sql.SQLException; import java.util.Properties; --- 11,14 ---- *************** *** 66,69 **** --- 65,71 ---- Revision history: $Log$ + Revision 1.2 2003/11/04 13:54:02 billhorsman + checkstyle + Revision 1.1 2003/10/25 18:38:17 billhorsman Not a test, just a standalone class you can run to see what libraries you need to use Proxool. Index: PerformanceTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/proxool/PerformanceTest.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PerformanceTest.java 11 Mar 2003 14:58:32 -0000 1.16 --- PerformanceTest.java 4 Nov 2003 13:54:02 -0000 1.17 *************** *** 15,18 **** --- 15,19 ---- import java.sql.DriverManager; import java.sql.SQLException; + import java.sql.Statement; import java.util.Properties; import java.text.DecimalFormat; *************** *** 37,40 **** --- 38,42 ---- private static final int PERIOD = 5; private static final int COUNT = 6; + private long servedCount; public PerformanceTest(String s) { *************** *** 46,55 **** * @throws ProxoolException if anything goes wrong */ ! public void testPerformance() throws ProxoolException { waitingThead = Thread.currentThread(); String alias = "testPeformance"; ! int threadCount = 5; String url = TestHelper.buildProxoolUrl(alias, TestConstants.HYPERSONIC_DRIVER, --- 48,57 ---- * @throws ProxoolException if anything goes wrong */ ! public void testPerformance() throws ProxoolException, InterruptedException { waitingThead = Thread.currentThread(); String alias = "testPeformance"; ! int threadCount = 20; String url = TestHelper.buildProxoolUrl(alias, TestConstants.HYPERSONIC_DRIVER, *************** *** 59,66 **** --- 61,74 ---- info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); info.setProperty(ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY, String.valueOf(threadCount)); + info.setProperty(ProxoolConstants.VERBOSE_PROPERTY, String.valueOf(Boolean.TRUE)); + info.setProperty(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY, String.valueOf(threadCount)); + /* info.setProperty(ProxoolConstants.STATISTICS_PROPERTY, String.valueOf(PERIOD) + "s"); info.setProperty(ProxoolConstants.STATISTICS_LOG_LEVEL_PROPERTY, ProxoolConstants.STATISTICS_LOG_LEVEL_INFO); + */ ProxoolFacade.registerConnectionPool(url, info); + /* ProxoolFacade.addStatisticsListener(alias, this); + */ doWait(); *************** *** 81,86 **** } ! LOG.info("Served " + statistics.getServedCount() ! + " at " + millisecondsFormat.format((double) (1000 * PERIOD * COUNT) / (double) statistics.getServedCount()) + " ms per connection"); } --- 89,112 ---- } ! for (int i = 0; i < 5; i++) { ! int activeConnectionCount = ProxoolFacade.getSnapshot(alias).getActiveConnectionCount(); ! if (activeConnectionCount > 0) { ! LOG.info("Waiting for 10 seconds for connections to become inactive (" + activeConnectionCount + ")"); ! Thread.sleep(10000); ! } else { ! break; ! } ! } ! ! final SnapshotIF snapshot = ProxoolFacade.getSnapshot(alias, true); ! LOG.info("Active count: " + snapshot.getActiveConnectionCount()); ! LOG.info("Available count: " + snapshot.getAvailableConnectionCount()); ! ConnectionInfoIF[] cis = snapshot.getConnectionInfos(); ! LOG.info("Found " + cis.length + " connetions with a detailed snapshot" + ""); ! for (int i = 0; i < cis.length; i++) { ! ConnectionInfoIF ci = cis[i]; ! LOG.info("#" + ci.getId() + ": " + ci.getStatus() + ", lap=" + (ci.getTimeLastStopActive() - ci.getTimeLastStartActive())); ! } ! LOG.info("Served a total of " + ProxoolFacade.getSnapshot(alias).getServedCount()); } *************** *** 97,100 **** --- 123,127 ---- public void statistics(String alias, StatisticsIF statistics) { + this.servedCount += statistics.getServedCount(); this.statistics = statistics; synchronized (waitingThead) { *************** *** 116,119 **** --- 143,147 ---- info.setProperty(ProxoolConstants.PASSWORD_PROPERTY, TestConstants.HYPERSONIC_PASSWORD); info.setProperty(ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY, String.valueOf(threadCount)); + info.setProperty(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY, String.valueOf(threadCount)); info.setProperty(ProxoolConstants.STATISTICS_PROPERTY, String.valueOf(PERIOD) + "s"); info.setProperty(ProxoolConstants.STATISTICS_LOG_LEVEL_PROPERTY, ProxoolConstants.STATISTICS_LOG_LEVEL_INFO); *************** *** 220,230 **** } - private void checkForDisparity(int count1, int count2, String description) { - if (count1 != count2) { - LOG.error(description + " disparity: " + count1 + " != " + count2); - disparityNoticed = true; - } - } - private int getCount(ConnectionInfoIF[] connectionInfos, int status) { int count = 0; --- 248,251 ---- *************** *** 266,274 **** try { Connection connection = null; try { connection = DriverManager.getConnection(TestHelper.buildProxoolUrl(alias)); ! connection.createStatement(); Thread.yield(); } finally { if (connection != null) { connection.close(); --- 287,299 ---- try { Connection connection = null; + Statement s = null; try { connection = DriverManager.getConnection(TestHelper.buildProxoolUrl(alias)); ! s = connection.createStatement(); Thread.yield(); } finally { + if (s != null) { + s.close(); + } if (connection != null) { connection.close(); *************** *** 302,305 **** --- 327,333 ---- Revision history: $Log$ + Revision 1.17 2003/11/04 13:54:02 billhorsman + checkstyle + Revision 1.16 2003/03/11 14:58:32 billhorsman put PerformanceTest back in the global test |
From: <bil...@us...> - 2003-11-04 13:54:05
|
Update of /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/logging In directory sc8-pr-cvs1:/tmp/cvs-serv1745/src/java-test/org/logicalcobwebs/logging Modified Files: Jdk14LoggerTest.java Log Message: checkstyle Index: Jdk14LoggerTest.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java-test/org/logicalcobwebs/logging/Jdk14LoggerTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Jdk14LoggerTest.java 26 Oct 2003 16:11:35 -0000 1.2 --- Jdk14LoggerTest.java 4 Nov 2003 13:54:02 -0000 1.3 *************** *** 7,11 **** import org.logicalcobwebs.proxool.AbstractProxoolTest; - import org.logicalcobwebs.proxool.ConnectionPoolTest; /** --- 7,10 ---- |
From: <bil...@us...> - 2003-11-04 13:54:05
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool In directory sc8-pr-cvs1:/tmp/cvs-serv1745/src/java/org/logicalcobwebs/proxool Modified Files: AbstractProxyStatement.java Log Message: checkstyle Index: AbstractProxyStatement.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/AbstractProxyStatement.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** AbstractProxyStatement.java 27 Oct 2003 12:21:59 -0000 1.16 --- AbstractProxyStatement.java 4 Nov 2003 13:54:02 -0000 1.17 *************** *** 173,177 **** // Log if configured to if (connectionPool.getLog().isDebugEnabled() && connectionPool.getDefinition().isTrace()) { ! connectionPool.getLog().debug(sqlLog.toString() + " (" + (System.currentTimeMillis() - startTime) + " milliseconds" + (exception != null ? ", threw a " + exception.getClass().getName() + ": " + exception.getMessage() + ")" : ")")); } // Send to any listener --- 173,178 ---- // Log if configured to if (connectionPool.getLog().isDebugEnabled() && connectionPool.getDefinition().isTrace()) { ! connectionPool.getLog().debug(sqlLog.toString() + " (" + (System.currentTimeMillis() - startTime) + " milliseconds" ! + (exception != null ? ", threw a " + exception.getClass().getName() + ": " + exception.getMessage() + ")" : ")")); } // Send to any listener *************** *** 240,243 **** --- 241,247 ---- Revision history: $Log$ + Revision 1.17 2003/11/04 13:54:02 billhorsman + checkstyle + Revision 1.16 2003/10/27 12:21:59 billhorsman Optimisation to avoid preparing sql log if tracing is off. |