*/
public interface Constants {
- /** Major version number of class files for Java 1.1.
- * @see #MINOR_1_1
- * */
- public final static short MAJOR_1_1 = 45;
-
- /** Minor version number of class files for Java 1.1.
- * @see #MAJOR_1_1
- * */
- public final static short MINOR_1_1 = 3;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/** Maximum value for an unsigned short.
*/
public final static int MAX_SHORT = 65535; // 2^16 - 1
*/
public final static int MAX_BYTE = 255; // 2^8 - 1
-
-
-
-
-
-
- /** One of the access flags for fields, methods, or classes.
- * @see #ACC_PUBLIC
- */
- public final static short ACC_STATIC = 0x0008;
-
/** One of the access flags for fields, methods, or classes.
* @see #ACC_PUBLIC
*/
public final static short ACC_FINAL = 0x0010;
-
-
-
-
-
-
-
-
-
-
-
-
- /** One of the access flags for fields, methods, or classes.
- * @see #ACC_PUBLIC
- */
- public final static short ACC_NATIVE = 0x0100;
-
/** One of the access flags for fields, methods, or classes.
* @see #ACC_PUBLIC
*/
*/
public final static short ACC_ABSTRACT = 0x0400;
-
-
-
-
-
-
/** One of the access flags for fields, methods, or classes.
* @see #ACC_PUBLIC
*/
"CONSTANT_Class", "CONSTANT_String", "CONSTANT_Fieldref",
"CONSTANT_Methodref", "CONSTANT_InterfaceMethodref",
"CONSTANT_NameAndType" };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short BIPUSH = 16;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short SIPUSH = 17;
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short LDC = 18;
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short ILOAD_0 = 26;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short ILOAD_1 = 27;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short ILOAD_2 = 28;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short ILOAD_3 = 29;
+
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short LLOAD_0 = 30;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LLOAD_1 = 31;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LLOAD_2 = 32;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LLOAD_3 = 33;
+
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short FLOAD_0 = 34;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FLOAD_1 = 35;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FLOAD_2 = 36;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FLOAD_3 = 37;
+
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short DLOAD_0 = 38;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DLOAD_1 = 39;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DLOAD_2 = 40;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DLOAD_3 = 41;
+
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short ALOAD_0 = 42;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short ALOAD_1 = 43;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short ALOAD_2 = 44;
+
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short ALOAD_3 = 45;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short IALOAD = 46;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LALOAD = 47;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FALOAD = 48;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DALOAD = 49;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short AALOAD = 50;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short BALOAD = 51;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short CALOAD = 52;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short SALOAD = 53;
+
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short ISTORE = 54;
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short ISTORE_0 = 59;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short ISTORE_1 = 60;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short ISTORE_2 = 61;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short ISTORE_3 = 62;
+
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short LSTORE_0 = 63;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LSTORE_1 = 64;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LSTORE_2 = 65;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LSTORE_3 = 66;
+
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short FSTORE_0 = 67;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FSTORE_1 = 68;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FSTORE_2 = 69;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FSTORE_3 = 70;
+
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short DSTORE_0 = 71;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DSTORE_1 = 72;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DSTORE_2 = 73;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DSTORE_3 = 74;
+
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short ASTORE_0 = 75;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short ASTORE_1 = 76;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short ASTORE_2 = 77;
+
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short ASTORE_3 = 78;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short IASTORE = 79;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LASTORE = 80;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FASTORE = 81;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DASTORE = 82;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short AASTORE = 83;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short BASTORE = 84;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short CASTORE = 85;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short SASTORE = 86;
-
-
-
-
-
-
-
-
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short IADD = 96;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LADD = 97;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FADD = 98;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DADD = 99;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short ISUB = 100;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LSUB = 101;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FSUB = 102;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DSUB = 103;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short IMUL = 104;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LMUL = 105;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FMUL = 106;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DMUL = 107;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short IDIV = 108;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LDIV = 109;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FDIV = 110;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DDIV = 111;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short IREM = 112;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LREM = 113;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FREM = 114;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DREM = 115;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short INEG = 116;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LNEG = 117;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FNEG = 118;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DNEG = 119;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short ISHL = 120;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LSHL = 121;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short ISHR = 122;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LSHR = 123;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short IUSHR = 124;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LUSHR = 125;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short IAND = 126;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LAND = 127;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short IOR = 128;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LOR = 129;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short IXOR = 130;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LXOR = 131;
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short IINC = 132;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short I2L = 133;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short I2F = 134;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short I2D = 135;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short L2I = 136;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short L2F = 137;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short L2D = 138;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short F2I = 139;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short F2L = 140;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short F2D = 141;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short D2I = 142;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short D2L = 143;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short D2F = 144;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short I2B = 145;
-
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short I2C = 146;
-
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short I2S = 147;
-
-
-
-
-
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short LOOKUPSWITCH = 171;
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short IRETURN = 172;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short LRETURN = 173;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short FRETURN = 174;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short DRETURN = 175;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short ARETURN = 176;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
- public static final short RETURN = 177;
- /** Java VM opcode.
- * @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short GETSTATIC = 178;
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short ANEWARRAY = 189;
-
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short CHECKCAST = 192;
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short INSTANCEOF = 193;
-
/** Java VM opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions2.doc.html">Opcode definitions in The Java Virtual Machine Specification</a> */
public static final short WIDE = 196;
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions.doc.html#60105">Reserved opcodes in the Java Virtual Machine Specification</a> */
public static final short BREAKPOINT = 202;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/** JVM internal opcode.
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions.doc.html#60105">Reserved opcodes in the Java Virtual Machine Specification</a> */
public static final short IMPDEP1 = 254;
* @see <a href="http://java.sun.com/docs/books/jvms/second_edition/html/Instructions.doc.html#60105">Reserved opcodes in the Java Virtual Machine Specification</a> */
public static final short IMPDEP2 = 255;
-
-
-
/** Illegal opcode. */
public static final short UNDEFINED = -1;
/** Illegal opcode. */
"void", "array", "object", "unknown", "address"
};
-
-
/** The signature characters corresponding to primitive types,
* e.g., SHORT_TYPE_NAMES[T_INT] = "I"
*/
/** Constants used in the StackMap attribute.
*/
public static final byte ITEM_Bogus = 0;
-
-
-
-
-
-
public static final byte ITEM_Object = 7;
public static final byte ITEM_NewObject = 8;
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel;
-
-import org.apache.tomcat.util.bcel.classfile.JavaClass;
-import org.apache.tomcat.util.bcel.util.SyntheticRepository;
-
-/**
- * The repository maintains informations about class interdependencies, e.g.,
- * whether a class is a sub-class of another. Delegates actual class loading
- * to SyntheticRepository with current class path by default.
- *
- * @see org.apache.tomcat.util.bcel.util.Repository
- * @see org.apache.tomcat.util.bcel.util.SyntheticRepository
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public abstract class Repository {
-
- private static org.apache.tomcat.util.bcel.util.Repository _repository = SyntheticRepository.getInstance();
-
-
-
-
-
-
-
-
- /** Lookup class somewhere found on your CLASSPATH, or whereever the
- * repository instance looks for it.
- *
- * @return class object for given fully qualified class name
- * @throws ClassNotFoundException if the class could not be found or
- * parsed correctly
- */
- public static JavaClass lookupClass( String class_name ) throws ClassNotFoundException {
- return _repository.loadClass(class_name);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /**
- * Equivalent to runtime "instanceof" operator.
- * @return true, if clazz is an instance of super_class
- * @throws ClassNotFoundException if any superclasses or superinterfaces
- * of clazz can't be found
- */
- public static boolean instanceOf( JavaClass clazz, JavaClass super_class )
- throws ClassNotFoundException {
- return clazz.instanceOf(super_class);
- }
-
-
-
-
-
-
-
-
-
-
-
- /**
- * @return true, if clazz is an implementation of interface inter
- * @throws ClassNotFoundException if any superclasses or superinterfaces
- * of clazz can't be found
- */
- public static boolean implementationOf( JavaClass clazz, JavaClass inter )
- throws ClassNotFoundException {
- return clazz.implementationOf(inter);
- }
-
-
-
-
-
-
-
-
-
-}
}
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v
- * Visitor object
- */
- public void accept(Visitor v)
- {
- // v.visitAnnotationDefault(this);
- }
-
- /**
* @param defaultValue
* the default value of this methodinfo's annotation
*/
* @author <A HREF="mailto:dbrosius@mebigfatguy.com">D. Brosius</A>
* @since 5.3
*/
-public class AnnotationEntry implements Node, Constants, Serializable {
+public class AnnotationEntry implements Constants, Serializable {
private int type_index;
private int num_element_value_pairs;
private int annotation_table_length;
private AnnotationEntry[] annotation_table; // Table of annotations
- private boolean isRuntimeVisible;
/**
AnnotationEntry[] annotation_table, ConstantPool constant_pool , boolean isRuntimeVisible) {
super(annotation_type, name_index, length, constant_pool);
setAnnotationTable(annotation_table);
- this.isRuntimeVisible = isRuntimeVisible;
- }
-
-
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitAnnotation(this);
}
* @see Deprecated
* @see Signature
*/
-public abstract class Attribute implements Cloneable, Node, Serializable
+public abstract class Attribute implements Cloneable, Serializable
{
protected int name_index; // Points to attribute name in constant pool
}
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v
- * Visitor object
- */
- public abstract void accept(Visitor v);
-
- /**
* Dump attribute to file stream in binary format.
*
* @param file
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitCode(this);
- }
-
-
- /**
* Dump code attribute to file stream in binary format.
*
* @param file Output file stream
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
* @see Code
*/
-public final class CodeException implements Cloneable, Constants, Node, Serializable {
+public final class CodeException implements Cloneable, Constants, Serializable {
private int start_pc; // Range in the code the exception handler is
private int end_pc; // active. start_pc is inclusive, end_pc exclusive
* @version $Id$
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
*/
-public abstract class Constant implements Cloneable, Node, Serializable {
+public abstract class Constant implements Cloneable, Serializable {
private static BCELComparator _cmp = new BCELComparator() {
}
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public abstract void accept( Visitor v );
-
-
public abstract void dump( DataOutputStream file ) throws IOException;
}
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitConstantClass(this);
- }
-
-
/**
* Dump constant class to file stream in binary format.
*
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitConstantDouble(this);
- }
-
-
- /**
* Dump constant double to file stream in binary format.
*
* @param file Output file stream
}
- /**
- * @param class_index Reference to the class containing the Field
- * @param name_and_type_index and the Field signature
- */
- public ConstantFieldref(int class_index, int name_and_type_index) {
- super(Constants.CONSTANT_Fieldref, class_index, name_and_type_index);
- }
-
-
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of Fields,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitConstantFieldref(this);
- }
+
}
this(file.readFloat());
}
-
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitConstantFloat(this);
- }
-
-
+
/**
* Dump constant float to file stream in binary format.
*
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitConstantInteger(this);
- }
-
-
- /**
* Dump constant integer to file stream in binary format.
*
* @param file Output file stream
}
- /**
- * @param class_index Reference to the class containing the method
- * @param name_and_type_index and the method signature
- */
- public ConstantInterfaceMethodref(int class_index, int name_and_type_index) {
- super(Constants.CONSTANT_InterfaceMethodref, class_index, name_and_type_index);
- }
-
-
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitConstantInterfaceMethodref(this);
- }
+
}
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitConstantLong(this);
- }
-
-
- /**
* Dump constant long to file stream in binary format.
*
* @param file Output file stream
}
- /**
- * @param class_index Reference to the class containing the method
- * @param name_and_type_index and the method signature
- */
- public ConstantMethodref(int class_index, int name_and_type_index) {
- super(Constants.CONSTANT_Methodref, class_index, name_and_type_index);
- }
-
-
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitConstantMethodref(this);
- }
+
}
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitConstantNameAndType(this);
- }
-
-
- /**
* Dump name and signature index to file stream in binary format.
*
* @param file Output file stream
* @see org.apache.tomcat.util.bcel.generic.ConstantPoolGen
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
*/
-public class ConstantPool implements Cloneable, Node, Serializable {
+public class ConstantPool implements Cloneable, Serializable {
private int constant_pool_count;
private Constant[] constant_pool;
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitConstantString(this);
- }
-
-
- /**
* Dump constant field reference to file stream in binary format.
*
* @param file Output file stream
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitConstantUtf8(this);
- }
-
-
- /**
* Dump String in Utf8 format to file stream.
*
* @param file Output file stream
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitConstantValue(this);
- }
-
-
- /**
* Dump constant value attribute to file stream on binary format.
*
* @param file Output file stream
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitDeprecated(this);
- }
-
-
- /**
* Dump source file attribute to file stream in binary format.
*
* @param file Output file stream
methodIndex = methodIdx;
}
- public void accept(Visitor v) {
- v.visitEnclosingMethod(this);
- }
-
public Attribute copy(ConstantPool constant_pool) {
throw new RuntimeException("Not implemented yet!");
// is this next line sufficient?
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitExceptionTable(this);
- }
-
-
- /**
* Dump exceptions attribute to file stream in binary format.
*
* @param file Output file stream
* @version $Id$
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
*/
-public abstract class FieldOrMethod extends AccessFlags implements Cloneable, Node {
+public abstract class FieldOrMethod extends AccessFlags implements Cloneable {
protected int name_index; // Points to field name in constant pool
protected int signature_index; // Points to encoded signature
protected ConstantPool constant_pool;
- private String signatureAttributeString = null;
- private boolean searchedForSignatureAttribute = false;
-
-
- // Annotations are collected from certain attributes, don't do it more than necessary!
- private boolean annotationsOutOfDate = true;
-
FieldOrMethod() {
}
-
-
-
/**
* Construct object from file stream.
* @param file Input stream
}
-
-
-
-
-
-
/**
* @param attributes Collection of object attributes.
*/
attributes_count = (attributes == null) ? 0 : attributes.length;
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/**
* @return Name of object, i.e., method name or field name
*/
c = (ConstantUtf8) constant_pool.getConstant(signature_index, Constants.CONSTANT_Utf8);
return c.getBytes();
}
-
-
-
-
-
-
-
-
-
}
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
* @see InnerClasses
*/
-public final class InnerClass implements Cloneable, Node, Serializable {
+public final class InnerClass implements Cloneable, Serializable {
private int inner_class_index;
private int outer_class_index;
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitInnerClasses(this);
- }
-
-
- /**
* Dump source file attribute to file stream in binary format.
*
* @param file Output file stream
* @see org.apache.tomcat.util.bcel.generic.ClassGen
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
*/
-public class JavaClass extends AccessFlags implements Cloneable, Node, Comparable {
+public class JavaClass extends AccessFlags implements Cloneable, Comparable {
private String file_name;
- private String package_name;
private String source_file_name = "<Unknown>";
- private int class_name_index;
- private int superclass_name_index;
private String class_name;
private String superclass_name;
private int major, minor; // Compiler version
private Method[] methods; // methods defined in the class
private Attribute[] attributes; // attributes defined in the class
private AnnotationEntry[] annotations; // annotations defined on the class
- private byte source = HEAP; // Generated in memory
- private boolean isAnonymous = false;
- private boolean isNested = false;
- private boolean computedNestedTypeStatus = false;
- public static final byte HEAP = 1;
+
public static final byte FILE = 2;
public static final byte ZIP = 3;
if (methods == null) {
methods = new Method[0];
}
- this.class_name_index = class_name_index;
- this.superclass_name_index = superclass_name_index;
this.file_name = file_name;
this.major = major;
this.minor = minor;
this.methods = methods;
this.attributes = attributes;
annotationsOutOfDate = true;
- this.source = source;
// Get source file name if available
for (int i = 0; i < attributes.length; i++) {
if (attributes[i] instanceof SourceFile) {
*/
class_name = constant_pool.getConstantString(class_name_index, Constants.CONSTANT_Class);
class_name = Utility.compactClassName(class_name, false);
- int index = class_name.lastIndexOf('.');
- if (index < 0) {
- package_name = "";
- } else {
- package_name = class_name.substring(0, index);
- }
if (superclass_name_index > 0) {
// May be zero -> class is java.lang.Object
superclass_name = constant_pool.getConstantString(superclass_name_index,
}
- /** Equivalent to runtime "instanceof" operator.
- *
- * @return true if this JavaClass is derived from the super class
- * @throws ClassNotFoundException if superclasses or superinterfaces
- * of this object can't be found
- */
- public final boolean instanceOf( JavaClass super_class ) throws ClassNotFoundException {
- if (this.equals(super_class)) {
- return true;
- }
- JavaClass[] super_classes = getSuperClasses();
- for (int i = 0; i < super_classes.length; i++) {
- if (super_classes[i].equals(super_class)) {
- return true;
- }
- }
- if (super_class.isInterface()) {
- return implementationOf(super_class);
- }
- return false;
- }
+
/**
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
* @see LineNumberTable
*/
-public final class LineNumber implements Cloneable, Node, Serializable {
+public final class LineNumber implements Cloneable, Serializable {
private int start_pc; // Program Counter (PC) corresponds to line
private int line_number; // number in source file
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitLineNumberTable(this);
- }
-
-
- /**
* Dump line number table attribute to file stream in binary format.
*
* @param file Output file stream
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
* @see LocalVariableTable
*/
-public final class LocalVariable implements Constants, Cloneable, Node, Serializable {
+public final class LocalVariable implements Constants, Cloneable, Serializable {
private int start_pc; // Range in which the variable is valid
private int length;
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitLocalVariableTable(this);
- }
-
-
- /**
* Dump local variable table attribute to file stream in binary format.
*
* @param file Output file stream
local_variable_type_table[i] = new LocalVariable(dis, cpool);
}
- public void accept(Visitor v) {
- v.visitLocalVariableTypeTable(this);
- }
-
public final void dump(DataOutputStream file) throws IOException
{
super.dump(file);
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.classfile;
-
-/**
- * Denote class to have an accept method();
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public interface Node {
-
-
-}
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- System.err.println("Visiting non-standard PMGClass object");
- }
-
-
- /**
* Dump source file attribute to file stream in binary format.
*
* @param file Output file stream
* @author <A HREF="mailto:dbrosius@qis.net">D. Brosius</A>
* @since 5.3
*/
-public class ParameterAnnotationEntry implements Node, Constants {
+public class ParameterAnnotationEntry implements Constants {
private int annotation_table_length;
private AnnotationEntry[] annotation_table;
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- // v.visitParameterAnnotation(this);
- }
-
-
- /**
* @param parameter_annotation_table the entries to set in this parameter annotation
*/
public final void setParameterAnnotationTable(
*/
package org.apache.tomcat.util.bcel.classfile;
-import java.io.ByteArrayInputStream;
import java.io.DataInput;
import java.io.DataOutputStream;
import java.io.IOException;
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- //System.err.println("Visiting non-standard Signature object");
- v.visitSignature(this);
- }
-
-
- /**
* Dump source file attribute to file stream in binary format.
*
* @param file Output file stream
}
/**
- * Extends ByteArrayInputStream to make 'unreading' chars possible.
- */
- private static final class MyByteArrayInputStream extends ByteArrayInputStream {
-
- MyByteArrayInputStream(String data) {
- super(data.getBytes());
- }
- }
-
-
- /**
* @return String representation
*/
public final String toString() {
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitSourceFile(this);
- }
-
-
- /**
* Dump source file attribute to file stream in binary format.
*
* @param file Output file stream
* @see StackMapEntry
* @see StackMapType
*/
-public final class StackMap extends Attribute implements Node {
+public final class StackMap extends Attribute {
private int map_length;
private StackMapEntry[] map; // Table of stack map entries
c.constant_pool = _constant_pool;
return c;
}
-
-
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitStackMap(this);
- }
-
-
-
}
private StackMapType[] types_of_locals;
private int number_of_stack_items;
private StackMapType[] types_of_stack_items;
- private ConstantPool constant_pool;
/**
this.types_of_locals = types_of_locals;
this.number_of_stack_items = number_of_stack_items;
this.types_of_stack_items = types_of_stack_items;
- this.constant_pool = constant_pool;
}
* @see StackMapEntry
* @see StackMapType
*/
-public final class StackMapTable extends Attribute implements Node {
+public final class StackMapTable extends Attribute {
private int map_length;
private StackMapTableEntry[] map; // Table of stack map entries
c.constant_pool = _constant_pool;
return c;
}
-
-
- /**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitStackMapTable(this);
- }
-
-
-
}
private StackMapType[] types_of_locals;
private int number_of_stack_items;
private StackMapType[] types_of_stack_items;
- private ConstantPool constant_pool;
/**
this.types_of_locals = types_of_locals;
this.number_of_stack_items = number_of_stack_items;
this.types_of_stack_items = types_of_stack_items;
- this.constant_pool = constant_pool;
}
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitSynthetic(this);
- }
-
-
- /**
* Dump source file attribute to file stream in binary format.
*
* @param file Output file stream
/**
- * Called by objects that are traversing the nodes of the tree implicitely
- * defined by the contents of a Java class. I.e., the hierarchy of methods,
- * fields, attributes, etc. spawns a tree of objects.
- *
- * @param v Visitor object
- */
- public void accept( Visitor v ) {
- v.visitUnknown(this);
- }
-
-
- /**
* Dump unknown bytes to file stream.
*
* @param file Output file stream
*/
package org.apache.tomcat.util.bcel.classfile;
-import java.io.FilterReader;
-import java.io.FilterWriter;
import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
import org.apache.tomcat.util.bcel.Constants;
import org.apache.tomcat.util.bcel.util.ByteSequence;
private static final int FREE_CHARS = 48;
static int[] CHAR_MAP = new int[FREE_CHARS];
static int[] MAP_CHAR = new int[256]; // Reverse map
- private static final char ESCAPE_CHAR = '$';
static {
int j = 0;
for (int i = 'A'; i <= 'Z'; i++) {
MAP_CHAR['_'] = j;
}
- /** Decode characters into bytes.
- * Used by <a href="Utility.html#decode(java.lang.String, boolean)">decode()</a>
- */
- private static class JavaReader extends FilterReader {
-
- public JavaReader(Reader in) {
- super(in);
- }
-
-
- public int read() throws IOException {
- int b = in.read();
- if (b != ESCAPE_CHAR) {
- return b;
- }
- int i = in.read();
- if (i < 0) {
- return -1;
- }
- if (((i >= '0') && (i <= '9')) || ((i >= 'a') && (i <= 'f'))) { // Normal escape
- int j = in.read();
- if (j < 0) {
- return -1;
- }
- char[] tmp = {
- (char) i, (char) j
- };
- int s = Integer.parseInt(new String(tmp), 16);
- return s;
- }
- return MAP_CHAR[i];
- }
-
-
- public int read( char[] cbuf, int off, int len ) throws IOException {
- for (int i = 0; i < len; i++) {
- cbuf[off + i] = (char) read();
- }
- return len;
- }
- }
-
- /** Encode bytes into valid java identifier characters.
- * Used by <a href="Utility.html#encode(byte[], boolean)">encode()</a>
- */
- private static class JavaWriter extends FilterWriter {
-
- public JavaWriter(Writer out) {
- super(out);
- }
-
-
- public void write( int b ) throws IOException {
- if (isJavaIdentifierPart((char) b) && (b != ESCAPE_CHAR)) {
- out.write(b);
- } else {
- out.write(ESCAPE_CHAR); // Escape character
- // Special escape
- if (b >= 0 && b < FREE_CHARS) {
- out.write(CHAR_MAP[b]);
- } else { // Normal escape
- char[] tmp = Integer.toHexString(b).toCharArray();
- if (tmp.length == 1) {
- out.write('0');
- out.write(tmp[0]);
- } else {
- out.write(tmp[0]);
- out.write(tmp[1]);
- }
- }
- }
- }
-
-
- public void write( char[] cbuf, int off, int len ) throws IOException {
- for (int i = 0; i < len; i++) {
- write(cbuf[off + i]);
- }
- }
-
-
- public void write( String str, int off, int len ) throws IOException {
- write(str.toCharArray(), off, len);
- }
- }
-
-
/**
* Escape all occurences of newline chars '\n', quotes \", etc.
*/
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.classfile;
-
-/**
- * Interface to make use of the Visitor pattern programming style. I.e. a class
- * that implements this interface can traverse the contents of a Java class just
- * by calling the `accept' method which all classes have.
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public interface Visitor
-{
- public void visitCode(Code obj);
-
-
-
- public void visitConstantClass(ConstantClass obj);
-
- public void visitConstantDouble(ConstantDouble obj);
-
- public void visitConstantFieldref(ConstantFieldref obj);
-
- public void visitConstantFloat(ConstantFloat obj);
-
- public void visitConstantInteger(ConstantInteger obj);
-
- public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj);
-
- public void visitConstantLong(ConstantLong obj);
-
- public void visitConstantMethodref(ConstantMethodref obj);
-
- public void visitConstantNameAndType(ConstantNameAndType obj);
-
-
-
- public void visitConstantString(ConstantString obj);
-
- public void visitConstantUtf8(ConstantUtf8 obj);
-
- public void visitConstantValue(ConstantValue obj);
-
- public void visitDeprecated(Deprecated obj);
-
- public void visitExceptionTable(ExceptionTable obj);
-
-
-
-
-
- public void visitInnerClasses(InnerClasses obj);
-
-
-
-
-
- public void visitLineNumberTable(LineNumberTable obj);
-
-
-
- public void visitLocalVariableTable(LocalVariableTable obj);
-
-
-
- public void visitSignature(Signature obj);
-
- public void visitSourceFile(SourceFile obj);
-
- public void visitSynthetic(Synthetic obj);
-
- public void visitUnknown(Unknown obj);
-
- public void visitStackMap(StackMap obj);
-
-
-
- public void visitStackMapTable(StackMapTable obj);
-
-
-
- public void visitAnnotation(Annotations obj);
-
-
-
-
-
-
-
- public void visitLocalVariableTypeTable(LocalVariableTypeTable obj);
-
- public void visitEnclosingMethod(EnclosingMethod obj);
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * ALOAD - Load reference from local variable
- * <PRE>Stack: ... -> ..., objectref</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class ALOAD extends LoadInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- ALOAD() {
- super(org.apache.tomcat.util.bcel.Constants.ALOAD, org.apache.tomcat.util.bcel.Constants.ALOAD_0);
- }
-
-
- /** Load reference from local variable
- * @param n index of local variable
- */
- public ALOAD(int n) {
- super(org.apache.tomcat.util.bcel.Constants.ALOAD, org.apache.tomcat.util.bcel.Constants.ALOAD_0, n);
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * ANEWARRAY - Create new array of references
- * <PRE>Stack: ..., count -> ..., arrayref</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class ANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction,
- ExceptionThrower, StackConsumer, StackProducer {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- ANEWARRAY() {
- }
-
-
-
-
-
-
-
-
-
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * ASTORE - Store reference into local variable
- * <PRE>Stack ..., objectref -> ... </PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class ASTORE extends StoreInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- ASTORE() {
- super(org.apache.tomcat.util.bcel.Constants.ASTORE, org.apache.tomcat.util.bcel.Constants.ASTORE_0);
- }
-
-
- /** Store reference into local variable
- * @param n index of local variable
- */
- public ASTORE(int n) {
- super(org.apache.tomcat.util.bcel.Constants.ASTORE, org.apache.tomcat.util.bcel.Constants.ASTORE_0, n);
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import org.apache.tomcat.util.bcel.util.ByteSequence;
-
-/**
- * BIPUSH - Push byte on stack
- *
- * <PRE>Stack: ... -> ..., value</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class BIPUSH extends Instruction implements ConstantPushInstruction {
-
- private byte b;
-
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- BIPUSH() {
- }
-
-
-
-
-
- /**
- * Dump instruction as byte code to stream out.
- */
- public void dump( DataOutputStream out ) throws IOException {
- super.dump(out);
- out.writeByte(b);
- }
-
-
- /**
- * @return mnemonic for instruction
- */
- public String toString( boolean verbose ) {
- return super.toString(verbose) + " " + b;
- }
-
-
- /**
- * Read needed data (e.g. index) from file.
- */
- protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
- length = 2;
- b = bytes.readByte();
- }
-
-
- public Number getValue() {
- return new Integer(b);
- }
-
-
- /** @return Type.BYTE
- */
- public Type getType( ConstantPoolGen cp ) {
- return Type.BYTE;
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * BREAKPOINT, JVM dependent, ignored by default
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class BREAKPOINT extends Instruction {
-
- public BREAKPOINT() {
- super(org.apache.tomcat.util.bcel.Constants.BREAKPOINT, (short) 1);
- }
-}
private static BranchHandle bh_list = null; // List of reusable handles
- static final BranchHandle getBranchHandle( BranchInstruction i ) {
- if (bh_list == null) {
- return new BranchHandle(i);
- }
- BranchHandle bh = bh_list;
- bh_list = (BranchHandle) bh.next;
- bh.setInstruction(i);
- return bh;
- }
+
/** Handle adds itself to the list of resuable handles.
}
- /**
- * @return target offset in byte code
- */
- public final int getIndex() {
- return index;
- }
+
/**
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * CHECKCAST - Check whether object is of given type
- * <PRE>Stack: ..., objectref -> ..., objectref</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class CHECKCAST extends CPInstruction implements LoadClass, ExceptionThrower, StackProducer,
- StackConsumer {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- CHECKCAST() {
- }
-
-
-
-
-
-
-
-
-
-}
}
- /**
- * @param index to constant pool
- */
- protected CPInstruction(short opcode, int index) {
- super(opcode, (short) 3);
- setIndex(index);
- }
+
/**
*/
package org.apache.tomcat.util.bcel.generic;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tomcat.util.bcel.Constants;
import org.apache.tomcat.util.bcel.classfile.AccessFlags;
import org.apache.tomcat.util.bcel.classfile.JavaClass;
import org.apache.tomcat.util.bcel.util.BCELComparator;
/* Corresponds to the fields found in a JavaClass object.
*/
- private String class_name, super_class_name, file_name;
- private int class_name_index = -1, superclass_name_index = -1;
- private int major = Constants.MAJOR_1_1, minor = Constants.MINOR_1_1;
- private ConstantPoolGen cp; // Template for building up constant pool
- // ArrayLists instead of arrays to gather fields, methods, etc.
- private List field_vec = new ArrayList();
- private List method_vec = new ArrayList();
- private List attribute_vec = new ArrayList();
- private List interface_vec = new ArrayList();
- private List annotation_vec = new ArrayList();
+ private String class_name;
private static BCELComparator _cmp = new BCELComparator() {
return THIS.getClassName().hashCode();
}
};
-
-
-
-
-
-
-
-
public String getClassName() {
return class_name;
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- private ArrayList observers;
-
-
-
-
-
-
-
-
-
-
-
public Object clone() {
try {
return super.clone();
}
}
-
-
-
-
-
-
/**
* Return value as defined by given BCELComparator strategy.
* By default two ClassGen objects are said to be equal when
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import org.apache.tomcat.util.bcel.classfile.CodeException;
-
-/**
- * This class represents an exception handler, i.e., specifies the region where
- * a handler is active and an instruction where the actual handling is done.
- * pool as parameters. Opposed to the JVM specification the end of the handled
- * region is set to be inclusive, i.e. all instructions between start and end
- * are protected including the start and end instructions (handles) themselves.
- * The end of the region is automatically mapped to be exclusive when calling
- * getCodeException(), i.e., there is no difference semantically.
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- * @see MethodGen
- * @see CodeException
- * @see InstructionHandle
- */
-public final class CodeExceptionGen implements InstructionTargeter, Cloneable, java.io.Serializable {
-
- private InstructionHandle start_pc;
- private InstructionHandle end_pc;
- private InstructionHandle handler_pc;
-
-
- /**
- * Add an exception handler, i.e., specify region where a handler is active and an
- * instruction where the actual handling is done.
- *
- * @param start_pc Start of handled region (inclusive)
- * @param end_pc End of handled region (inclusive)
- * @param handler_pc Where handling is done
- * @param catch_type which exception is handled, null for ANY
- */
- public CodeExceptionGen(InstructionHandle start_pc, InstructionHandle end_pc,
- InstructionHandle handler_pc, ObjectType catch_type) {
- setStartPC(start_pc);
- setEndPC(end_pc);
- setHandlerPC(handler_pc);
- }
-
-
-
-
-
- /* Set start of handler
- * @param start_pc Start of handled region (inclusive)
- */
- public void setStartPC( InstructionHandle start_pc ) {
- BranchInstruction.notifyTarget(this.start_pc, start_pc, this);
- this.start_pc = start_pc;
- }
-
-
- /* Set end of handler
- * @param end_pc End of handled region (inclusive)
- */
- public void setEndPC( InstructionHandle end_pc ) {
- BranchInstruction.notifyTarget(this.end_pc, end_pc, this);
- this.end_pc = end_pc;
- }
-
-
- /* Set handler code
- * @param handler_pc Start of handler
- */
- public void setHandlerPC( InstructionHandle handler_pc ) {
- BranchInstruction.notifyTarget(this.handler_pc, handler_pc, this);
- this.handler_pc = handler_pc;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public String toString() {
- return "CodeExceptionGen(" + start_pc + ", " + end_pc + ", " + handler_pc + ")";
- }
-
-
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- System.err.println(e);
- return null;
- }
- }
-}
import java.util.HashMap;
import java.util.Map;
import org.apache.tomcat.util.bcel.classfile.Constant;
-import org.apache.tomcat.util.bcel.classfile.ConstantClass;
import org.apache.tomcat.util.bcel.classfile.ConstantDouble;
-import org.apache.tomcat.util.bcel.classfile.ConstantFieldref;
import org.apache.tomcat.util.bcel.classfile.ConstantFloat;
import org.apache.tomcat.util.bcel.classfile.ConstantInteger;
-import org.apache.tomcat.util.bcel.classfile.ConstantInterfaceMethodref;
import org.apache.tomcat.util.bcel.classfile.ConstantLong;
-import org.apache.tomcat.util.bcel.classfile.ConstantMethodref;
-import org.apache.tomcat.util.bcel.classfile.ConstantNameAndType;
import org.apache.tomcat.util.bcel.classfile.ConstantPool;
-import org.apache.tomcat.util.bcel.classfile.ConstantString;
import org.apache.tomcat.util.bcel.classfile.ConstantUtf8;
/**
protected int size;
protected Constant[] constants;
protected int index = 1; // First entry (0) used by JVM
- private static final String METHODREF_DELIM = ":";
- private static final String IMETHODREF_DELIM = "#";
- private static final String FIELDREF_DELIM = "&";
private static final String NAT_DELIM = "%";
private static class Index implements java.io.Serializable {
}
}
- private Map string_table = new HashMap();
-
-
- /**
- * Look for ConstantString in ConstantPool containing String `str'.
- *
- * @param str String to search for
- * @return index on success, -1 otherwise
- */
- public int lookupString( String str ) {
- Index index = (Index) string_table.get(str);
- return (index != null) ? index.index : -1;
- }
-
-
- /**
- * Add a new String constant to the ConstantPool, if it is not already in there.
- *
- * @param str String to add
- * @return index of entry
- */
- public int addString( String str ) {
- int ret;
- if ((ret = lookupString(str)) != -1) {
- return ret; // Already in CP
- }
- int utf8 = addUtf8(str);
- adjustSize();
- ConstantString s = new ConstantString(utf8);
- ret = index;
- constants[index++] = s;
- if (!string_table.containsKey(str)) {
- string_table.put(str, new Index(ret));
- }
- return ret;
- }
-
private Map class_table = new HashMap();
}
- private int addClass_( String clazz ) {
- int ret;
- if ((ret = lookupClass(clazz)) != -1) {
- return ret; // Already in CP
- }
- adjustSize();
- ConstantClass c = new ConstantClass(addUtf8(clazz));
- ret = index;
- constants[index++] = c;
- if (!class_table.containsKey(clazz)) {
- class_table.put(clazz, new Index(ret));
- }
- return ret;
- }
-
-
- /**
- * Add a new Class reference to the ConstantPool, if it is not already in there.
- *
- * @param str Class to add
- * @return index of entry
- */
- public int addClass( String str ) {
- return addClass_(str.replace('.', '/'));
- }
-
-
- /**
- * Add a new Class reference to the ConstantPool for a given type.
- *
- * @param type Class to add
- * @return index of entry
- */
- public int addClass( ObjectType type ) {
- return addClass(type.getClassName());
- }
-
-
-
-
-
/**
* Look for ConstantInteger in ConstantPool.
*
return (_index != null) ? _index.index : -1;
}
-
- /**
- * Add a new NameAndType constant to the ConstantPool if it is not already
- * in there.
- *
- * @param name Name string to add
- * @param signature signature string to add
- * @return index of entry
- */
- public int addNameAndType( String name, String signature ) {
- int ret;
- int name_index, signature_index;
- if ((ret = lookupNameAndType(name, signature)) != -1) {
- return ret; // Already in CP
- }
- adjustSize();
- name_index = addUtf8(name);
- signature_index = addUtf8(signature);
- ret = index;
- constants[index++] = new ConstantNameAndType(name_index, signature_index);
- String key = name + NAT_DELIM + signature;
- if (!n_a_t_table.containsKey(key)) {
- n_a_t_table.put(key, new Index(ret));
- }
- return ret;
- }
-
- private Map cp_table = new HashMap();
-
-
- /**
- * Look for ConstantMethodref in ConstantPool.
- *
- * @param class_name Where to find method
- * @param method_name Guess what
- * @param signature return and argument types
- * @return index on success, -1 otherwise
- */
- public int lookupMethodref( String class_name, String method_name, String signature ) {
- Index index = (Index) cp_table.get(class_name + METHODREF_DELIM + method_name
- + METHODREF_DELIM + signature);
- return (index != null) ? index.index : -1;
- }
-
-
-
-
-
- /**
- * Add a new Methodref constant to the ConstantPool, if it is not already
- * in there.
- *
- * @param class_name class name string to add
- * @param method_name method name string to add
- * @param signature method signature string to add
- * @return index of entry
- */
- public int addMethodref( String class_name, String method_name, String signature ) {
- int ret, class_index, name_and_type_index;
- if ((ret = lookupMethodref(class_name, method_name, signature)) != -1) {
- return ret; // Already in CP
- }
- adjustSize();
- name_and_type_index = addNameAndType(method_name, signature);
- class_index = addClass(class_name);
- ret = index;
- constants[index++] = new ConstantMethodref(class_index, name_and_type_index);
- String key = class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature;
- if (!cp_table.containsKey(key)) {
- cp_table.put(key, new Index(ret));
- }
- return ret;
- }
-
-
-
-
-
- /**
- * Look for ConstantInterfaceMethodref in ConstantPool.
- *
- * @param class_name Where to find method
- * @param method_name Guess what
- * @param signature return and argument types
- * @return index on success, -1 otherwise
- */
- public int lookupInterfaceMethodref( String class_name, String method_name, String signature ) {
- Index index = (Index) cp_table.get(class_name + IMETHODREF_DELIM + method_name
- + IMETHODREF_DELIM + signature);
- return (index != null) ? index.index : -1;
- }
-
-
-
-
-
- /**
- * Add a new InterfaceMethodref constant to the ConstantPool, if it is not already
- * in there.
- *
- * @param class_name class name string to add
- * @param method_name method name string to add
- * @param signature signature string to add
- * @return index of entry
- */
- public int addInterfaceMethodref( String class_name, String method_name, String signature ) {
- int ret, class_index, name_and_type_index;
- if ((ret = lookupInterfaceMethodref(class_name, method_name, signature)) != -1) {
- return ret; // Already in CP
- }
- adjustSize();
- class_index = addClass(class_name);
- name_and_type_index = addNameAndType(method_name, signature);
- ret = index;
- constants[index++] = new ConstantInterfaceMethodref(class_index, name_and_type_index);
- String key = class_name + IMETHODREF_DELIM + method_name + IMETHODREF_DELIM + signature;
- if (!cp_table.containsKey(key)) {
- cp_table.put(key, new Index(ret));
- }
- return ret;
- }
-
-
-
-
- /**
- * Look for ConstantFieldref in ConstantPool.
- *
- * @param class_name Where to find method
- * @param field_name Guess what
- * @param signature return and argument types
- * @return index on success, -1 otherwise
- */
- public int lookupFieldref( String class_name, String field_name, String signature ) {
- Index index = (Index) cp_table.get(class_name + FIELDREF_DELIM + field_name
- + FIELDREF_DELIM + signature);
- return (index != null) ? index.index : -1;
- }
-
-
- /**
- * Add a new Fieldref constant to the ConstantPool, if it is not already
- * in there.
- *
- * @param class_name class name string to add
- * @param field_name field name string to add
- * @param signature signature string to add
- * @return index of entry
- */
- public int addFieldref( String class_name, String field_name, String signature ) {
- int ret;
- int class_index, name_and_type_index;
- if ((ret = lookupFieldref(class_name, field_name, signature)) != -1) {
- return ret; // Already in CP
- }
- adjustSize();
- class_index = addClass(class_name);
- name_and_type_index = addNameAndType(field_name, signature);
- ret = index;
- constants[index++] = new ConstantFieldref(class_index, name_and_type_index);
- String key = class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature;
- if (!cp_table.containsKey(key)) {
- cp_table.put(key, new Index(ret));
- }
- return ret;
- }
-
-
/**
* @param i index in constant pool
* @return constant pool entry at index i
}
-
-
-
/**
* @return intermediate constant pool
*/
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * DLOAD - Load double from local variable
- * <PRE>Stack ... -> ..., result.word1, result.word2</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class DLOAD extends LoadInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- DLOAD() {
- super(org.apache.tomcat.util.bcel.Constants.DLOAD, org.apache.tomcat.util.bcel.Constants.DLOAD_0);
- }
-
-
- /** Load double from local variable
- * @param n index of local variable
- */
- public DLOAD(int n) {
- super(org.apache.tomcat.util.bcel.Constants.DLOAD, org.apache.tomcat.util.bcel.Constants.DLOAD_0, n);
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * DSTORE - Store double into local variable
- * <pre>Stack: ..., value.word1, value.word2 -> ... </PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class DSTORE extends StoreInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- DSTORE() {
- super(org.apache.tomcat.util.bcel.Constants.DSTORE, org.apache.tomcat.util.bcel.Constants.DSTORE_0);
- }
-
-
- /** Store double into local variable
- * @param n index of local variable
- */
- public DSTORE(int n) {
- super(org.apache.tomcat.util.bcel.Constants.DSTORE, org.apache.tomcat.util.bcel.Constants.DSTORE_0, n);
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * FLOAD - Load float from local variable
- * <PRE>Stack ... -> ..., result</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class FLOAD extends LoadInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- FLOAD() {
- super(org.apache.tomcat.util.bcel.Constants.FLOAD, org.apache.tomcat.util.bcel.Constants.FLOAD_0);
- }
-
-
- /** Load float from local variable
- * @param n index of local variable
- */
- public FLOAD(int n) {
- super(org.apache.tomcat.util.bcel.Constants.FLOAD, org.apache.tomcat.util.bcel.Constants.FLOAD_0, n);
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * FSTORE - Store float into local variable
- * <PRE>Stack: ..., value -> ... </PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class FSTORE extends StoreInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- FSTORE() {
- super(org.apache.tomcat.util.bcel.Constants.FSTORE, org.apache.tomcat.util.bcel.Constants.FSTORE_0);
- }
-
-
- /** Store float into local variable
- * @param n index of local variable
- */
- public FSTORE(int n) {
- super(org.apache.tomcat.util.bcel.Constants.FSTORE, org.apache.tomcat.util.bcel.Constants.FSTORE_0, n);
- }
-}
*/
package org.apache.tomcat.util.bcel.generic;
-import java.util.List;
import org.apache.tomcat.util.bcel.classfile.Field;
import org.apache.tomcat.util.bcel.classfile.Utility;
import org.apache.tomcat.util.bcel.util.BCELComparator;
return type.getSignature();
}
- private List observers;
-
-
-
-
-
-
-
-
-
-
-
public String getInitValue() {
if (value != null) {
return value.toString();
import java.util.ArrayList;
import java.util.List;
-import org.apache.tomcat.util.bcel.Constants;
import org.apache.tomcat.util.bcel.classfile.AccessFlags;
import org.apache.tomcat.util.bcel.classfile.Attribute;
protected Type type;
protected ConstantPoolGen cp;
private List attribute_vec = new ArrayList();
- protected ArrayList annotation_vec= new ArrayList();
+
protected FieldGenOrMethodGen() {
}
- public void setType( Type type ) {
- if (type.getType() == Constants.T_ADDRESS) {
- throw new IllegalArgumentException("Type can not be " + type);
- }
- this.type = type;
- }
+
}
- public void setName( String name ) {
- this.name = name;
- }
+
- public void setConstantPool( ConstantPoolGen cp ) {
- this.cp = cp;
- }
+
- /**
- * Add an attribute to this method. Currently, the JVM knows about
- * the `Code', `ConstantValue', `Synthetic' and `Exceptions'
- * attributes. Other attributes will be ignored by the JVM but do no
- * harm.
- *
- * @param a attribute to be added
- */
- public void addAttribute( Attribute a ) {
- attribute_vec.add(a);
- }
+
- /** @return name of the referenced class/interface
- * @deprecated If the instruction references an array class,
- * this method will return "java.lang.Object".
- * For code generated by Java 1.5, this answer is
- * sometimes wrong (e.g., if the "clone()" method is
- * called on an array). A better idea is to use
- * the getReferenceType() method, which correctly distinguishes
- * between class types and array types.
- */
- public String getClassName( ConstantPoolGen cpg ) {
- ConstantPool cp = cpg.getConstantPool();
- ConstantCP cmr = (ConstantCP) cp.getConstant(index);
- String className = cp.getConstantString(cmr.getClassIndex(),
- org.apache.tomcat.util.bcel.Constants.CONSTANT_Class);
- if (className.startsWith("[")) {
- // Turn array classes into java.lang.Object.
- return "java.lang.Object";
- }
- return className.replace('/', '.');
- }
+
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * GETFIELD - Fetch field from object
- * <PRE>Stack: ..., objectref -> ..., value</PRE>
- * OR
- * <PRE>Stack: ..., objectref -> ..., value.word1, value.word2</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class GETFIELD extends FieldInstruction implements ExceptionThrower, StackConsumer,
- StackProducer {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- GETFIELD() {
- }
-
-
-
-
-
- public int produceStack( ConstantPoolGen cpg ) {
- return getFieldSize(cpg);
- }
-
-
-
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * GETSTATIC - Fetch static field from class
- * <PRE>Stack: ..., -> ..., value</PRE>
- * OR
- * <PRE>Stack: ..., -> ..., value.word1, value.word2</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class GETSTATIC extends FieldInstruction implements PushInstruction, ExceptionThrower {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- GETSTATIC() {
- }
-
-
-
-
-
- public int produceStack( ConstantPoolGen cpg ) {
- return getFieldSize(cpg);
- }
-
-
-
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-/**
- * GOTO - Branch always (to relative offset, not absolute address)
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class GOTO extends GotoInstruction implements VariableLengthInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- GOTO() {
- }
-
-
-
-
-
- /**
- * Dump instruction as byte code to stream out.
- * @param out Output stream
- */
- public void dump( DataOutputStream out ) throws IOException {
- index = getTargetOffset();
- if (opcode == org.apache.tomcat.util.bcel.Constants.GOTO) {
- super.dump(out);
- } else { // GOTO_W
- index = getTargetOffset();
- out.writeByte(opcode);
- out.writeInt(index);
- }
- }
-
-
- /** Called in pass 2 of InstructionList.setPositions() in order to update
- * the branch target, that may shift due to variable length instructions.
- */
- protected int updatePosition( int offset, int max_offset ) {
- int i = getTargetOffset(); // Depending on old position value
- position += offset; // Position may be shifted by preceding expansions
- if (Math.abs(i) >= (32767 - max_offset)) { // to large for short (estimate)
- opcode = org.apache.tomcat.util.bcel.Constants.GOTO_W;
- length = 5;
- return 2; // 5 - 3
- }
- return 0;
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import org.apache.tomcat.util.bcel.util.ByteSequence;
-
-/**
- * GOTO_W - Branch always (to relative offset, not absolute address)
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class GOTO_W extends GotoInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- GOTO_W() {
- }
-
-
-
-
-
- /**
- * Dump instruction as byte code to stream out.
- * @param out Output stream
- */
- public void dump( DataOutputStream out ) throws IOException {
- index = getTargetOffset();
- out.writeByte(opcode);
- out.writeInt(index);
- }
-
-
- /**
- * Read needed data (e.g. index) from file.
- */
- protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
- index = bytes.readInt();
- length = 5;
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import org.apache.tomcat.util.bcel.util.ByteSequence;
-
-/**
- * IINC - Increment local variable by constant
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class IINC extends LocalVariableInstruction {
-
- private boolean wide;
- private int c;
-
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- IINC() {
- }
-
-
-
-
-
- /**
- * Dump instruction as byte code to stream out.
- * @param out Output stream
- */
- public void dump( DataOutputStream out ) throws IOException {
- if (wide) {
- out.writeByte(org.apache.tomcat.util.bcel.Constants.WIDE);
- }
- out.writeByte(opcode);
- if (wide) {
- out.writeShort(n);
- out.writeShort(c);
- } else {
- out.writeByte(n);
- out.writeByte(c);
- }
- }
-
-
- private final void setWide() {
- wide = (n > org.apache.tomcat.util.bcel.Constants.MAX_BYTE) || (Math.abs(c) > Byte.MAX_VALUE);
- if (wide) {
- length = 6; // wide byte included
- } else {
- length = 3;
- }
- }
-
-
- /**
- * Read needed data (e.g. index) from file.
- */
- protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
- this.wide = wide;
- if (wide) {
- length = 6;
- n = bytes.readUnsignedShort();
- c = bytes.readShort();
- } else {
- length = 3;
- n = bytes.readUnsignedByte();
- c = bytes.readByte();
- }
- }
-
-
- /**
- * @return mnemonic for instruction
- */
- public String toString( boolean verbose ) {
- return super.toString(verbose) + " " + c;
- }
-
-
- /**
- * Set index of local variable.
- */
- public final void setIndex( int n ) {
- if (n < 0) {
- throw new ClassGenException("Negative index value: " + n);
- }
- this.n = n;
- setWide();
- }
-
-
-
-
-
-
-
-
- /** @return int type
- */
- public Type getType( ConstantPoolGen cp ) {
- return Type.INT;
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * ILOAD - Load int from local variable onto stack
- * <PRE>Stack: ... -> ..., result</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class ILOAD extends LoadInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- ILOAD() {
- super(org.apache.tomcat.util.bcel.Constants.ILOAD, org.apache.tomcat.util.bcel.Constants.ILOAD_0);
- }
-
-
- /** Load int from local variable
- * @param n index of local variable
- */
- public ILOAD(int n) {
- super(org.apache.tomcat.util.bcel.Constants.ILOAD, org.apache.tomcat.util.bcel.Constants.ILOAD_0, n);
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * IMPDEP1 - Implementation dependent
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class IMPDEP1 extends Instruction {
-
- public IMPDEP1() {
- super(org.apache.tomcat.util.bcel.Constants.IMPDEP1, (short) 1);
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * IMPDEP2 - Implementation dependent
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class IMPDEP2 extends Instruction {
-
- public IMPDEP2() {
- super(org.apache.tomcat.util.bcel.Constants.IMPDEP2, (short) 1);
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * INSTANCEOF - Determine if object is of given type
- * <PRE>Stack: ..., objectref -> ..., result</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class INSTANCEOF extends CPInstruction implements LoadClass, ExceptionThrower,
- StackProducer, StackConsumer {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- INSTANCEOF() {
- }
-
-
-
-
-
-
-
-
-
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import org.apache.tomcat.util.bcel.classfile.ConstantPool;
-import org.apache.tomcat.util.bcel.util.ByteSequence;
-
-/**
- * INVOKEINTERFACE - Invoke interface method
- * <PRE>Stack: ..., objectref, [arg1, [arg2 ...]] -> ...</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public final class INVOKEINTERFACE extends InvokeInstruction {
-
- private int nargs; // Number of arguments on stack (number of stack slots), called "count" in vmspec2
-
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- INVOKEINTERFACE() {
- }
-
-
-
-
-
- /**
- * Dump instruction as byte code to stream out.
- * @param out Output stream
- */
- public void dump( DataOutputStream out ) throws IOException {
- out.writeByte(opcode);
- out.writeShort(index);
- out.writeByte(nargs);
- out.writeByte(0);
- }
-
-
-
-
-
- /**
- * Read needed data (i.e., index) from file.
- */
- protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
- super.initFromFile(bytes, wide);
- length = 5;
- nargs = bytes.readUnsignedByte();
- bytes.readByte(); // Skip 0 byte
- }
-
-
- /**
- * @return mnemonic for instruction with symbolic references resolved
- */
- public String toString( ConstantPool cp ) {
- return super.toString(cp) + " " + nargs;
- }
-
-
- public int consumeStack( ConstantPoolGen cpg ) { // nargs is given in byte-code
- return nargs; // nargs includes this reference
- }
-
-
-
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * INVOKESPECIAL - Invoke instance method; special handling for superclass, private
- * and instance initialization method invocations
- *
- * <PRE>Stack: ..., objectref, [arg1, [arg2 ...]] -> ...</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class INVOKESPECIAL extends InvokeInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- INVOKESPECIAL() {
- }
-
-
-
-
-
-
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * INVOKESTATIC - Invoke a class (static) method
- *
- * <PRE>Stack: ..., [arg1, [arg2 ...]] -> ...</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class INVOKESTATIC extends InvokeInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- INVOKESTATIC() {
- }
-
-
-
-
-
-
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * INVOKEVIRTUAL - Invoke instance method; dispatch based on class
- *
- * <PRE>Stack: ..., objectref, [arg1, [arg2 ...]] -> ...</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class INVOKEVIRTUAL extends InvokeInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- INVOKEVIRTUAL() {
- }
-
-
-
-
-
-
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * ISTORE - Store int from stack into local variable
- * <PRE>Stack: ..., value -> ... </PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class ISTORE extends StoreInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- ISTORE() {
- super(org.apache.tomcat.util.bcel.Constants.ISTORE, org.apache.tomcat.util.bcel.Constants.ISTORE_0);
- }
-
-
- /** Store int into local variable
- * @param n index of local variable
- */
- public ISTORE(int n) {
- super(org.apache.tomcat.util.bcel.Constants.ISTORE, org.apache.tomcat.util.bcel.Constants.ISTORE_0, n);
- }
-}
}
- /**
- * Read an instruction from (byte code) input stream and return the
- * appropiate object.
- *
- * @param bytes input stream bytes
- * @return instruction object being read
- */
- public static final Instruction readInstruction( ByteSequence bytes ) throws IOException {
- boolean wide = false;
- short opcode = (short) bytes.readUnsignedByte();
- Instruction obj = null;
- if (opcode == Constants.WIDE) { // Read next opcode after wide byte
- wide = true;
- opcode = (short) bytes.readUnsignedByte();
- }
- if (InstructionConstants.INSTRUCTIONS[opcode] != null) {
- return InstructionConstants.INSTRUCTIONS[opcode]; // Used predefined immutable object, if available
- }
-
- switch (opcode) {
- case Constants.BIPUSH:
- obj = new BIPUSH();
- break;
- case Constants.SIPUSH:
- obj = new SIPUSH();
- break;
- case Constants.LDC:
- obj = new LDC();
- break;
- case Constants.LDC_W:
- obj = new LDC_W();
- break;
- case Constants.LDC2_W:
- obj = new LDC2_W();
- break;
- case Constants.ILOAD:
- obj = new ILOAD();
- break;
- case Constants.LLOAD:
- obj = new LLOAD();
- break;
- case Constants.FLOAD:
- obj = new FLOAD();
- break;
- case Constants.DLOAD:
- obj = new DLOAD();
- break;
- case Constants.ALOAD:
- obj = new ALOAD();
- break;
- case Constants.ILOAD_0:
- obj = new ILOAD(0);
- break;
- case Constants.ILOAD_1:
- obj = new ILOAD(1);
- break;
- case Constants.ILOAD_2:
- obj = new ILOAD(2);
- break;
- case Constants.ILOAD_3:
- obj = new ILOAD(3);
- break;
- case Constants.LLOAD_0:
- obj = new LLOAD(0);
- break;
- case Constants.LLOAD_1:
- obj = new LLOAD(1);
- break;
- case Constants.LLOAD_2:
- obj = new LLOAD(2);
- break;
- case Constants.LLOAD_3:
- obj = new LLOAD(3);
- break;
- case Constants.FLOAD_0:
- obj = new FLOAD(0);
- break;
- case Constants.FLOAD_1:
- obj = new FLOAD(1);
- break;
- case Constants.FLOAD_2:
- obj = new FLOAD(2);
- break;
- case Constants.FLOAD_3:
- obj = new FLOAD(3);
- break;
- case Constants.DLOAD_0:
- obj = new DLOAD(0);
- break;
- case Constants.DLOAD_1:
- obj = new DLOAD(1);
- break;
- case Constants.DLOAD_2:
- obj = new DLOAD(2);
- break;
- case Constants.DLOAD_3:
- obj = new DLOAD(3);
- break;
- case Constants.ALOAD_0:
- obj = new ALOAD(0);
- break;
- case Constants.ALOAD_1:
- obj = new ALOAD(1);
- break;
- case Constants.ALOAD_2:
- obj = new ALOAD(2);
- break;
- case Constants.ALOAD_3:
- obj = new ALOAD(3);
- break;
- case Constants.ISTORE:
- obj = new ISTORE();
- break;
- case Constants.LSTORE:
- obj = new LSTORE();
- break;
- case Constants.FSTORE:
- obj = new FSTORE();
- break;
- case Constants.DSTORE:
- obj = new DSTORE();
- break;
- case Constants.ASTORE:
- obj = new ASTORE();
- break;
- case Constants.ISTORE_0:
- obj = new ISTORE(0);
- break;
- case Constants.ISTORE_1:
- obj = new ISTORE(1);
- break;
- case Constants.ISTORE_2:
- obj = new ISTORE(2);
- break;
- case Constants.ISTORE_3:
- obj = new ISTORE(3);
- break;
- case Constants.LSTORE_0:
- obj = new LSTORE(0);
- break;
- case Constants.LSTORE_1:
- obj = new LSTORE(1);
- break;
- case Constants.LSTORE_2:
- obj = new LSTORE(2);
- break;
- case Constants.LSTORE_3:
- obj = new LSTORE(3);
- break;
- case Constants.FSTORE_0:
- obj = new FSTORE(0);
- break;
- case Constants.FSTORE_1:
- obj = new FSTORE(1);
- break;
- case Constants.FSTORE_2:
- obj = new FSTORE(2);
- break;
- case Constants.FSTORE_3:
- obj = new FSTORE(3);
- break;
- case Constants.DSTORE_0:
- obj = new DSTORE(0);
- break;
- case Constants.DSTORE_1:
- obj = new DSTORE(1);
- break;
- case Constants.DSTORE_2:
- obj = new DSTORE(2);
- break;
- case Constants.DSTORE_3:
- obj = new DSTORE(3);
- break;
- case Constants.ASTORE_0:
- obj = new ASTORE(0);
- break;
- case Constants.ASTORE_1:
- obj = new ASTORE(1);
- break;
- case Constants.ASTORE_2:
- obj = new ASTORE(2);
- break;
- case Constants.ASTORE_3:
- obj = new ASTORE(3);
- break;
- case Constants.IINC:
- obj = new IINC();
- break;
- case Constants.IFEQ:
- obj = new IFEQ();
- break;
- case Constants.IFNE:
- obj = new IFNE();
- break;
- case Constants.IFLT:
- obj = new IFLT();
- break;
- case Constants.IFGE:
- obj = new IFGE();
- break;
- case Constants.IFGT:
- obj = new IFGT();
- break;
- case Constants.IFLE:
- obj = new IFLE();
- break;
- case Constants.IF_ICMPEQ:
- obj = new IF_ICMPEQ();
- break;
- case Constants.IF_ICMPNE:
- obj = new IF_ICMPNE();
- break;
- case Constants.IF_ICMPLT:
- obj = new IF_ICMPLT();
- break;
- case Constants.IF_ICMPGE:
- obj = new IF_ICMPGE();
- break;
- case Constants.IF_ICMPGT:
- obj = new IF_ICMPGT();
- break;
- case Constants.IF_ICMPLE:
- obj = new IF_ICMPLE();
- break;
- case Constants.IF_ACMPEQ:
- obj = new IF_ACMPEQ();
- break;
- case Constants.IF_ACMPNE:
- obj = new IF_ACMPNE();
- break;
- case Constants.GOTO:
- obj = new GOTO();
- break;
- case Constants.JSR:
- obj = new JSR();
- break;
- case Constants.RET:
- obj = new RET();
- break;
- case Constants.TABLESWITCH:
- obj = new TABLESWITCH();
- break;
- case Constants.LOOKUPSWITCH:
- obj = new LOOKUPSWITCH();
- break;
- case Constants.GETSTATIC:
- obj = new GETSTATIC();
- break;
- case Constants.PUTSTATIC:
- obj = new PUTSTATIC();
- break;
- case Constants.GETFIELD:
- obj = new GETFIELD();
- break;
- case Constants.PUTFIELD:
- obj = new PUTFIELD();
- break;
- case Constants.INVOKEVIRTUAL:
- obj = new INVOKEVIRTUAL();
- break;
- case Constants.INVOKESPECIAL:
- obj = new INVOKESPECIAL();
- break;
- case Constants.INVOKESTATIC:
- obj = new INVOKESTATIC();
- break;
- case Constants.INVOKEINTERFACE:
- obj = new INVOKEINTERFACE();
- break;
- case Constants.NEW:
- obj = new NEW();
- break;
- case Constants.NEWARRAY:
- obj = new NEWARRAY();
- break;
- case Constants.ANEWARRAY:
- obj = new ANEWARRAY();
- break;
- case Constants.CHECKCAST:
- obj = new CHECKCAST();
- break;
- case Constants.INSTANCEOF:
- obj = new INSTANCEOF();
- break;
- case Constants.MULTIANEWARRAY:
- obj = new MULTIANEWARRAY();
- break;
- case Constants.IFNULL:
- obj = new IFNULL();
- break;
- case Constants.IFNONNULL:
- obj = new IFNONNULL();
- break;
- case Constants.GOTO_W:
- obj = new GOTO_W();
- break;
- case Constants.JSR_W:
- obj = new JSR_W();
- break;
- case Constants.BREAKPOINT:
- obj = new BREAKPOINT();
- break;
- case Constants.IMPDEP1:
- obj = new IMPDEP1();
- break;
- case Constants.IMPDEP2:
- obj = new IMPDEP2();
- break;
- default:
- throw new ClassGenException("Illegal opcode detected: " + opcode);
-
- }
-
- if (wide
- && !((obj instanceof LocalVariableInstruction) || (obj instanceof IINC) || (obj instanceof RET))) {
- throw new ClassGenException("Illegal opcode after wide: " + opcode);
- }
- obj.setOpcode(opcode);
- obj.initFromFile(bytes, wide); // Do further initializations, if any
- return obj;
- }
+
/**
* This method also gives right results for instructions whose
}
- /**
- * Needed in readInstruction.
- */
- private void setOpcode( short opcode ) {
- this.opcode = opcode;
- }
-
-
/** Some instructions may be reused, so don't do anything by default.
*/
void dispose() {
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * This interface contains shareable instruction objects.
- *
- * In order to save memory you can use some instructions multiply,
- * since they have an immutable state and are directly derived from
- * Instruction. I.e. they have no instance fields that could be
- * changed. Since some of these instructions like ICONST_0 occur
- * very frequently this can save a lot of time and space. This
- * feature is an adaptation of the FlyWeight design pattern, we
- * just use an array instead of a factory.
- *
- * The Instructions can also accessed directly under their names, so
- * it's possible to write il.append(Instruction.ICONST_0);
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public interface InstructionConstants {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /** Get object via its opcode, for immutable instructions like
- * branch instructions entries are set to null.
- */
- public static final Instruction[] INSTRUCTIONS = new Instruction[256];
-
-
-
-}
package org.apache.tomcat.util.bcel.generic;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import org.apache.tomcat.util.bcel.classfile.Utility;
Instruction instruction;
protected int i_position = -1; // byte code offset of instruction
private Set targeters;
- private Map attributes;
public final InstructionHandle getNext() {
private static InstructionHandle ih_list = null; // List of reusable handles
- /** Factory method.
- */
- static final InstructionHandle getInstructionHandle( Instruction i ) {
- if (ih_list == null) {
- return new InstructionHandle(i);
- } else {
- InstructionHandle ih = ih_list;
- ih_list = ih.next;
- ih.setInstruction(i);
- return ih;
- }
- }
+
/**
package org.apache.tomcat.util.bcel.generic;
import java.io.Serializable;
-import java.util.List;
-import org.apache.tomcat.util.bcel.Constants;
/**
* This class is a container for a list of <a
public class InstructionList implements Serializable {
private InstructionHandle start = null, end = null;
- private int length = 0; // number of elements in list
- private int[] byte_positions; // byte code offsets corresponding to instructions
-
/**
* Create (empty) instruction list.
public InstructionList() {
}
-
-
-
-
-
-
-
-
-
-
- /**
- * Test for empty list.
- */
- public boolean isEmpty() {
- return start == null;
- } // && end == null
-
-
- /**
- * Find the target instruction (handle) that corresponds to the given target
- * position (byte code offset).
- *
- * @param ihs array of instruction handles, i.e. il.getInstructionHandles()
- * @param pos array of positions corresponding to ihs, i.e. il.getInstructionPositions()
- * @param count length of arrays
- * @param target target position to search for
- * @return target position's instruction handle if available
- */
- public static InstructionHandle findHandle( InstructionHandle[] ihs, int[] pos, int count,
- int target ) {
- int l = 0, r = count - 1;
- /* Do a binary search since the pos array is orderd.
- */
- do {
- int i = (l + r) / 2;
- int j = pos[i];
- if (j == target) {
- return ihs[i];
- } else if (target < j) {
- r = i - 1;
- } else {
- l = i + 1;
- }
- } while (l <= r);
- return null;
- }
-
-
-
-
-
-
-
-
- /**
- * Append another list after instruction (handle) ih contained in this list.
- * Consumes argument list, i.e., it becomes empty.
- *
- * @param ih where to append the instruction list
- * @param il Instruction list to append to this one
- * @return instruction handle pointing to the <B>first</B> appended instruction
- */
- public InstructionHandle append( InstructionHandle ih, InstructionList il ) {
- if (il == null) {
- throw new ClassGenException("Appending null InstructionList");
- }
- if (il.isEmpty()) {
- return ih;
- }
- InstructionHandle next = ih.next, ret = il.start;
- ih.next = il.start;
- il.start.prev = ih;
- il.end.next = next;
- if (next != null) {
- next.prev = il.end;
- } else {
- end = il.end; // Update end ...
- }
- length += il.length; // Update length
- il.clear();
- return ret;
- }
-
-
-
-
-
-
-
- /**
- * Append an instruction to the end of this list.
- *
- * @param ih instruction to append
- */
- private void append( InstructionHandle ih ) {
- if (isEmpty()) {
- start = end = ih;
- ih.next = ih.prev = null;
- } else {
- end.next = ih;
- ih.prev = end;
- ih.next = null;
- end = ih;
- }
- length++; // Update length
- }
-
-
- /**
- * Append an instruction to the end of this list.
- *
- * @param i instruction to append
- * @return instruction handle of the appended instruction
- */
- public InstructionHandle append( Instruction i ) {
- InstructionHandle ih = InstructionHandle.getInstructionHandle(i);
- append(ih);
- return ih;
- }
-
-
- /**
- * Append a branch instruction to the end of this list.
- *
- * @param i branch instruction to append
- * @return branch instruction handle of the appended instruction
- */
- public BranchHandle append( BranchInstruction i ) {
- BranchHandle ih = BranchHandle.getBranchHandle(i);
- append(ih);
- return ih;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
}
- public void setPositions() {
- setPositions(false);
- }
-
-
- /**
- * Give all instructions their position number (offset in byte stream), i.e.,
- * make the list ready to be dumped.
- *
- * @param check Perform sanity checks, e.g. if all targeted instructions really belong
- * to this list
- */
- public void setPositions( boolean check ) {
- int max_additional_bytes = 0, additional_bytes = 0;
- int index = 0, count = 0;
- int[] pos = new int[length];
- /* Pass 0: Sanity checks
- */
- if (check) {
- for (InstructionHandle ih = start; ih != null; ih = ih.next) {
- Instruction i = ih.instruction;
- if (i instanceof BranchInstruction) { // target instruction within list?
- Instruction inst = ((BranchInstruction) i).getTarget().instruction;
- if (!contains(inst)) {
- throw new ClassGenException("Branch target of "
- + Constants.OPCODE_NAMES[i.opcode] + ":" + inst
- + " not in instruction list");
- }
- if (i instanceof Select) {
- InstructionHandle[] targets = ((Select) i).getTargets();
- for (int j = 0; j < targets.length; j++) {
- inst = targets[j].instruction;
- if (!contains(inst)) {
- throw new ClassGenException("Branch target of "
- + Constants.OPCODE_NAMES[i.opcode] + ":" + inst
- + " not in instruction list");
- }
- }
- }
- if (!(ih instanceof BranchHandle)) {
- throw new ClassGenException("Branch instruction "
- + Constants.OPCODE_NAMES[i.opcode] + ":" + inst
- + " not contained in BranchHandle.");
- }
- }
- }
- }
- /* Pass 1: Set position numbers and sum up the maximum number of bytes an
- * instruction may be shifted.
- */
- for (InstructionHandle ih = start; ih != null; ih = ih.next) {
- Instruction i = ih.instruction;
- ih.setPosition(index);
- pos[count++] = index;
- /* Get an estimate about how many additional bytes may be added, because
- * BranchInstructions may have variable length depending on the target
- * offset (short vs. int) or alignment issues (TABLESWITCH and
- * LOOKUPSWITCH).
- */
- switch (i.getOpcode()) {
- case Constants.JSR:
- case Constants.GOTO:
- max_additional_bytes += 2;
- break;
- case Constants.TABLESWITCH:
- case Constants.LOOKUPSWITCH:
- max_additional_bytes += 3;
- break;
- }
- index += i.getLength();
- }
- /* Pass 2: Expand the variable-length (Branch)Instructions depending on
- * the target offset (short or int) and ensure that branch targets are
- * within this list.
- */
- for (InstructionHandle ih = start; ih != null; ih = ih.next) {
- additional_bytes += ih.updatePosition(additional_bytes, max_additional_bytes);
- }
- /* Pass 3: Update position numbers (which may have changed due to the
- * preceding expansions), like pass 1.
- */
- index = count = 0;
- for (InstructionHandle ih = start; ih != null; ih = ih.next) {
- Instruction i = ih.instruction;
- ih.setPosition(index);
- pos[count++] = index;
- index += i.getLength();
- }
- byte_positions = new int[count]; // Trim to proper size
- System.arraycopy(pos, 0, byte_positions, 0, count);
- }
-
-
-
-
-
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- private void clear() {
- start = end = null;
- length = 0;
- }
-
-
-
-
-
/**
* @return start of list
*/
public InstructionHandle getEnd() {
return end;
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- private List observers;
-
-
-
-
-
-
-
-
-
}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-/**
- * JSR - Jump to subroutine
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class JSR extends JsrInstruction implements VariableLengthInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- JSR() {
- }
-
-
-
-
-
- /**
- * Dump instruction as byte code to stream out.
- * @param out Output stream
- */
- public void dump( DataOutputStream out ) throws IOException {
- index = getTargetOffset();
- if (opcode == org.apache.tomcat.util.bcel.Constants.JSR) {
- super.dump(out);
- } else { // JSR_W
- index = getTargetOffset();
- out.writeByte(opcode);
- out.writeInt(index);
- }
- }
-
-
- protected int updatePosition( int offset, int max_offset ) {
- int i = getTargetOffset(); // Depending on old position value
- position += offset; // Position may be shifted by preceding expansions
- if (Math.abs(i) >= (32767 - max_offset)) { // to large for short (estimate)
- opcode = org.apache.tomcat.util.bcel.Constants.JSR_W;
- length = 5;
- return 2; // 5 - 3
- }
- return 0;
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import org.apache.tomcat.util.bcel.util.ByteSequence;
-
-/**
- * JSR_W - Jump to subroutine
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class JSR_W extends JsrInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- JSR_W() {
- }
-
-
-
-
-
- /**
- * Dump instruction as byte code to stream out.
- * @param out Output stream
- */
- public void dump( DataOutputStream out ) throws IOException {
- index = getTargetOffset();
- out.writeByte(opcode);
- out.writeInt(index);
- }
-
-
- /**
- * Read needed data (e.g. index) from file.
- */
- protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
- index = bytes.readInt();
- length = 5;
- }
-}
}
- /** @return return address type
- */
- public Type getType( ConstantPoolGen cp ) {
- return new ReturnaddressType(physicalSuccessor());
- }
+
- /**
- * Returns an InstructionHandle to the physical successor
- * of this JsrInstruction. <B>For this method to work,
- * this JsrInstruction object must not be shared between
- * multiple InstructionHandle objects!</B>
- * Formally, there must not be InstructionHandle objects
- * i, j where i != j and i.getInstruction() == this ==
- * j.getInstruction().
- * @return an InstructionHandle to the "next" instruction that
- * will be executed when RETurned from a subroutine.
- */
- public InstructionHandle physicalSuccessor() {
- InstructionHandle ih = this.target;
- // Rewind!
- while (ih.getPrev() != null) {
- ih = ih.getPrev();
- }
- // Find the handle for "this" JsrInstruction object.
- while (ih.getInstruction() != this) {
- ih = ih.getNext();
- }
- InstructionHandle toThis = ih;
- while (ih != null) {
- ih = ih.getNext();
- if ((ih != null) && (ih.getInstruction() == this)) {
- throw new RuntimeException("physicalSuccessor() called on a shared JsrInstruction.");
- }
- }
- // Return the physical successor
- return toThis.getNext();
- }
+
}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * LDC2_W - Push long or double from constant pool
- *
- * <PRE>Stack: ... -> ..., item.word1, item.word2</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class LDC2_W extends CPInstruction implements PushInstruction, TypedInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- LDC2_W() {
- }
-
-
-
-
-
- public Type getType( ConstantPoolGen cpg ) {
- switch (cpg.getConstantPool().getConstant(index).getTag()) {
- case org.apache.tomcat.util.bcel.Constants.CONSTANT_Long:
- return Type.LONG;
- case org.apache.tomcat.util.bcel.Constants.CONSTANT_Double:
- return Type.DOUBLE;
- default: // Never reached
- throw new RuntimeException("Unknown constant type " + opcode);
- }
- }
-
-
-
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import java.io.IOException;
-import org.apache.tomcat.util.bcel.util.ByteSequence;
-
-/**
- * LDC_W - Push item from constant pool (wide index)
- *
- * <PRE>Stack: ... -> ..., item.word1, item.word2</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class LDC_W extends LDC {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- LDC_W() {
- }
-
-
-
-
-
- /**
- * Read needed data (i.e., index) from file.
- */
- protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
- setIndex(bytes.readUnsignedShort());
- // Override just in case it has been changed
- opcode = org.apache.tomcat.util.bcel.Constants.LDC_W;
- length = 3;
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * LLOAD - Load long from local variable
- *<PRE>Stack ... -> ..., result.word1, result.word2</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class LLOAD extends LoadInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- LLOAD() {
- super(org.apache.tomcat.util.bcel.Constants.LLOAD, org.apache.tomcat.util.bcel.Constants.LLOAD_0);
- }
-
-
- public LLOAD(int n) {
- super(org.apache.tomcat.util.bcel.Constants.LLOAD, org.apache.tomcat.util.bcel.Constants.LLOAD_0, n);
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import org.apache.tomcat.util.bcel.util.ByteSequence;
-
-/**
- * LOOKUPSWITCH - Switch with unordered set of values
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- * @see SWITCH
- */
-public class LOOKUPSWITCH extends Select {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- LOOKUPSWITCH() {
- }
-
-
-
-
-
- /**
- * Dump instruction as byte code to stream out.
- * @param out Output stream
- */
- public void dump( DataOutputStream out ) throws IOException {
- super.dump(out);
- out.writeInt(match_length); // npairs
- for (int i = 0; i < match_length; i++) {
- out.writeInt(match[i]); // match-offset pairs
- out.writeInt(indices[i] = getTargetOffset(targets[i]));
- }
- }
-
-
- /**
- * Read needed data (e.g. index) from file.
- */
- protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
- super.initFromFile(bytes, wide); // reads padding
- match_length = bytes.readInt();
- fixed_length = (short) (9 + match_length * 8);
- length = (short) (fixed_length + padding);
- match = new int[match_length];
- indices = new int[match_length];
- targets = new InstructionHandle[match_length];
- for (int i = 0; i < match_length; i++) {
- match[i] = bytes.readInt();
- indices[i] = bytes.readInt();
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * LSTORE - Store long into local variable
- * <PRE>Stack: ..., value.word1, value.word2 -> ... </PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class LSTORE extends StoreInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- LSTORE() {
- super(org.apache.tomcat.util.bcel.Constants.LSTORE, org.apache.tomcat.util.bcel.Constants.LSTORE_0);
- }
-
-
- public LSTORE(int n) {
- super(org.apache.tomcat.util.bcel.Constants.LSTORE, org.apache.tomcat.util.bcel.Constants.LSTORE_0, n);
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import org.apache.tomcat.util.bcel.classfile.LineNumber;
-
-/**
- * This class represents a line number within a method, i.e., give an instruction
- * a line number corresponding to the source code line.
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- * @see LineNumber
- * @see MethodGen
- */
-public class LineNumberGen implements InstructionTargeter, Cloneable, java.io.Serializable {
-
- private InstructionHandle ih;
- private int src_line;
-
-
- /**
- * Create a line number.
- *
- * @param ih instruction handle to reference
- */
- public LineNumberGen(InstructionHandle ih, int src_line) {
- setInstruction(ih);
- setSourceLine(src_line);
- }
-
-
-
-
-
-
-
-
- /**
- * Get LineNumber attribute .
- *
- * This relies on that the instruction list has already been dumped to byte code or
- * or that the `setPositions' methods has been called for the instruction list.
- */
- public LineNumber getLineNumber() {
- return new LineNumber(ih.getPosition(), src_line);
- }
-
-
- public void setInstruction( InstructionHandle ih ) {
- BranchInstruction.notifyTarget(this.ih, ih, this);
- this.ih = ih;
- }
-
-
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- System.err.println(e);
- return null;
- }
- }
-
-
-
-
-
- public void setSourceLine( int src_line ) {
- this.src_line = src_line;
- }
-
-
-
-}
}
- public void setName( String name ) {
- this.name = name;
- }
+
public String getName() {
}
- public void setType( Type type ) {
- this.type = type;
- }
+
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import org.apache.tomcat.util.bcel.classfile.ConstantPool;
-import org.apache.tomcat.util.bcel.util.ByteSequence;
-
-/**
- * MULTIANEWARRAY - Create new mutidimensional array of references
- * <PRE>Stack: ..., count1, [count2, ...] -> ..., arrayref</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class MULTIANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction,
- ExceptionThrower {
-
- private short dimensions;
-
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- MULTIANEWARRAY() {
- }
-
-
-
-
-
- /**
- * Dump instruction as byte code to stream out.
- * @param out Output stream
- */
- public void dump( DataOutputStream out ) throws IOException {
- out.writeByte(opcode);
- out.writeShort(index);
- out.writeByte(dimensions);
- }
-
-
- /**
- * Read needed data (i.e., no. dimension) from file.
- */
- protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
- super.initFromFile(bytes, wide);
- dimensions = bytes.readByte();
- length = 4;
- }
-
-
-
-
-
- /**
- * @return mnemonic for instruction
- */
- public String toString( boolean verbose ) {
- return super.toString(verbose) + " " + index + " " + dimensions;
- }
-
-
- /**
- * @return mnemonic for instruction with symbolic references resolved
- */
- public String toString( ConstantPool cp ) {
- return super.toString(cp) + " " + dimensions;
- }
-
-
- /**
- * Also works for instructions whose stack effect depends on the
- * constant pool entry they reference.
- * @return Number of words consumed from stack by this instruction
- */
- public int consumeStack( ConstantPoolGen cpg ) {
- return dimensions;
- }
-
-
-
-
-
-
-}
*/
public class MethodGen extends FieldGenOrMethodGen {
- private String class_name;
private Type[] arg_types;
- private String[] arg_names;
- private int max_locals;
- private int max_stack;
private InstructionList il;
- private boolean strip_attributes;
private List variable_vec = new ArrayList();
- private List line_number_vec = new ArrayList();
- private List exception_vec = new ArrayList();
private List throws_vec = new ArrayList();
- private List code_attrs_vec = new ArrayList();
-
- private List[] param_annotations; // Array of lists containing AnnotationGen objects
- private boolean hasParameterAnnotations = false;
- private boolean haveUnpackedParameterAnnotations = false;
private static BCELComparator _cmp = new BCELComparator() {
};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/**
* Sort local variables by index
*/
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
public String getSignature() {
return Type.getMethodSignature(type, arg_types);
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- private List observers;
-
-
-
-
-
-
-
-
-
-
-
/**
* Return string representation close to declaration format,
* `public static void main(String[]) throws IOException', e.g.
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * NEW - Create new object
- * <PRE>Stack: ... -> ..., objectref</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class NEW extends CPInstruction implements LoadClass, AllocationInstruction,
- ExceptionThrower, StackProducer {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- NEW() {
- }
-
-
-
-
-
-
-
-
-
-}
- public void setName( String name );
+
- public void setType( Type type );
+
}
}
- /** @return name of referenced class
- */
- public String getClassName() {
- return class_name;
- }
+
/** @return a hash code value for the object.
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * PUTFIELD - Put field in object
- * <PRE>Stack: ..., objectref, value -> ...</PRE>
- * OR
- * <PRE>Stack: ..., objectref, value.word1, value.word2 -> ...</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class PUTFIELD extends FieldInstruction implements PopInstruction, ExceptionThrower {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- PUTFIELD() {
- }
-
-
-
-
-
- public int consumeStack( ConstantPoolGen cpg ) {
- return getFieldSize(cpg) + 1;
- }
-
-
-
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-/**
- * PUTSTATIC - Put static field in class
- * <PRE>Stack: ..., value -> ...</PRE>
- * OR
- * <PRE>Stack: ..., value.word1, value.word2 -> ...</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class PUTSTATIC extends FieldInstruction implements ExceptionThrower, PopInstruction {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- PUTSTATIC() {
- }
-
-
-
-
-
- public int consumeStack( ConstantPoolGen cpg ) {
- return getFieldSize(cpg);
- }
-
-
-
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import org.apache.tomcat.util.bcel.util.ByteSequence;
-
-/**
- * RET - Return from subroutine
- *
- * <PRE>Stack: ... -> ...</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class RET extends Instruction implements IndexedInstruction, TypedInstruction {
-
- private boolean wide;
- private int index; // index to local variable containg the return address
-
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- RET() {
- }
-
-
-
-
-
- /**
- * Dump instruction as byte code to stream out.
- * @param out Output stream
- */
- public void dump( DataOutputStream out ) throws IOException {
- if (wide) {
- out.writeByte(org.apache.tomcat.util.bcel.Constants.WIDE);
- }
- out.writeByte(opcode);
- if (wide) {
- out.writeShort(index);
- } else {
- out.writeByte(index);
- }
- }
-
-
- private final void setWide() {
- wide = index > org.apache.tomcat.util.bcel.Constants.MAX_BYTE;
- if (wide) {
- length = 4; // Including the wide byte
- } else {
- length = 2;
- }
- }
-
-
- /**
- * Read needed data (e.g. index) from file.
- */
- protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
- this.wide = wide;
- if (wide) {
- index = bytes.readUnsignedShort();
- length = 4;
- } else {
- index = bytes.readUnsignedByte();
- length = 2;
- }
- }
-
-
- /**
- * @return index of local variable containg the return address
- */
- public final int getIndex() {
- return index;
- }
-
-
- /**
- * Set index of local variable containg the return address
- */
- public final void setIndex( int n ) {
- if (n < 0) {
- throw new ClassGenException("Negative index value: " + n);
- }
- index = n;
- setWide();
- }
-
-
- /**
- * @return mnemonic for instruction
- */
- public String toString( boolean verbose ) {
- return super.toString(verbose) + " " + index;
- }
-
-
- /** @return return address type
- */
- public Type getType( ConstantPoolGen cp ) {
- return ReturnaddressType.NO_TARGET;
- }
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import org.apache.tomcat.util.bcel.Constants;
-
-/**
- * Returnaddress, the type JSR or JSR_W instructions push upon the stack.
- *
- * see vmspec2 �3.3.3
- * @version $Id$
- * @author Enver Haase
- */
-public class ReturnaddressType extends Type {
-
- public static final ReturnaddressType NO_TARGET = new ReturnaddressType();
- private InstructionHandle returnTarget;
-
-
- /**
- * A Returnaddress [that doesn't know where to return to].
- */
- private ReturnaddressType() {
- super(Constants.T_ADDRESS, "<return address>");
- }
-
-
- /**
- * Creates a ReturnaddressType object with a target.
- */
- public ReturnaddressType(InstructionHandle returnTarget) {
- super(Constants.T_ADDRESS, "<return address targeting " + returnTarget + ">");
- this.returnTarget = returnTarget;
- }
-
-
- /** @return a hash code value for the object.
- */
- public int hashCode() {
- if (returnTarget == null) {
- return 0;
- }
- return returnTarget.hashCode();
- }
-
-
- /**
- * Returns if the two Returnaddresses refer to the same target.
- */
- public boolean equals( Object rat ) {
- if (!(rat instanceof ReturnaddressType)) {
- return false;
- }
- ReturnaddressType that = (ReturnaddressType) rat;
- if (this.returnTarget == null || that.returnTarget == null) {
- return that.returnTarget == this.returnTarget;
- }
- return that.returnTarget.equals(this.returnTarget);
- }
-
-
-
-}
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import org.apache.tomcat.util.bcel.util.ByteSequence;
-
-/**
- * SIPUSH - Push short
- *
- * <PRE>Stack: ... -> ..., value</PRE>
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- */
-public class SIPUSH extends Instruction implements ConstantPushInstruction {
-
- private short b;
-
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- SIPUSH() {
- }
-
-
-
-
-
- /**
- * Dump instruction as short code to stream out.
- */
- public void dump( DataOutputStream out ) throws IOException {
- super.dump(out);
- out.writeShort(b);
- }
-
-
- /**
- * @return mnemonic for instruction
- */
- public String toString( boolean verbose ) {
- return super.toString(verbose) + " " + b;
- }
-
-
- /**
- * Read needed data (e.g. index) from file.
- */
- protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
- length = 3;
- b = bytes.readShort();
- }
-
-
- public Number getValue() {
- return new Integer(b);
- }
-
-
-
-}
- /**
- * @return array of match target offsets
- */
- public int[] getIndices() {
- return indices;
- }
+
/**
+++ /dev/null
-/*
- * Copyright 2000-2009 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.tomcat.util.bcel.generic;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import org.apache.tomcat.util.bcel.util.ByteSequence;
-
-/**
- * TABLESWITCH - Switch within given range of values, i.e., low..high
- *
- * @version $Id$
- * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
- * @see SWITCH
- */
-public class TABLESWITCH extends Select {
-
- /**
- * Empty constructor needed for the Class.newInstance() statement in
- * Instruction.readInstruction(). Not to be used otherwise.
- */
- TABLESWITCH() {
- }
-
-
-
-
-
- /**
- * Dump instruction as byte code to stream out.
- * @param out Output stream
- */
- public void dump( DataOutputStream out ) throws IOException {
- super.dump(out);
- int low = (match_length > 0) ? match[0] : 0;
- out.writeInt(low);
- int high = (match_length > 0) ? match[match_length - 1] : 0;
- out.writeInt(high);
- for (int i = 0; i < match_length; i++) {
- out.writeInt(indices[i] = getTargetOffset(targets[i]));
- }
- }
-
-
- /**
- * Read needed data (e.g. index) from file.
- */
- protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
- super.initFromFile(bytes, wide);
- int low = bytes.readInt();
- int high = bytes.readInt();
- match_length = high - low + 1;
- fixed_length = (short) (13 + match_length * 4);
- length = (short) (fixed_length + padding);
- match = new int[match_length];
- indices = new int[match_length];
- targets = new InstructionHandle[match_length];
- for (int i = low; i <= high; i++) {
- match[i - low] = i;
- }
- for (int i = 0; i < match_length; i++) {
- indices[i] = bytes.readInt();
- }
- }
-}
static int getArgumentTypesSize( String signature ) {
int res = 0;
int index;
- Type[] types;
try { // Read all declarations between for `(' and `)'
if (signature.charAt(0) != '(') {
throw new ClassFormatException("Invalid method signature: " + signature);