Clean up apache BCEL lib, no more stupid warnings
This commit is contained in:
parent
6548caeddb
commit
4f00ab70b1
@ -23,7 +23,8 @@ package org.apache.bcel;
|
|||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public interface Constants {
|
public interface Constants {
|
||||||
/** Major and minor version of the code.
|
/**
|
||||||
|
* Major and minor version of the code.
|
||||||
*/
|
*/
|
||||||
public final static short MAJOR_1_1 = 45;
|
public final static short MAJOR_1_1 = 45;
|
||||||
public final static short MINOR_1_1 = 3;
|
public final static short MINOR_1_1 = 3;
|
||||||
@ -38,15 +39,18 @@ public interface Constants {
|
|||||||
public final static short MAJOR = MAJOR_1_1; // Defaults
|
public final static short MAJOR = MAJOR_1_1; // Defaults
|
||||||
public final static short MINOR = MINOR_1_1;
|
public final static short MINOR = MINOR_1_1;
|
||||||
|
|
||||||
/** Maximum value for an unsigned short.
|
/**
|
||||||
|
* Maximum value for an unsigned short.
|
||||||
*/
|
*/
|
||||||
public final static int MAX_SHORT = 65535; // 2^16 - 1
|
public final static int MAX_SHORT = 65535; // 2^16 - 1
|
||||||
|
|
||||||
/** Maximum value for an unsigned byte.
|
/**
|
||||||
|
* Maximum value for an unsigned byte.
|
||||||
*/
|
*/
|
||||||
public final static int MAX_BYTE = 255; // 2^8 - 1
|
public final static int MAX_BYTE = 255; // 2^8 - 1
|
||||||
|
|
||||||
/** Access flags for classes, fields and methods.
|
/**
|
||||||
|
* Access flags for classes, fields and methods.
|
||||||
*/
|
*/
|
||||||
public final static short ACC_PUBLIC = 0x0001;
|
public final static short ACC_PUBLIC = 0x0001;
|
||||||
public final static short ACC_PRIVATE = 0x0002;
|
public final static short ACC_PRIVATE = 0x0002;
|
||||||
@ -74,13 +78,13 @@ public interface Constants {
|
|||||||
|
|
||||||
public final static short MAX_ACC_FLAG = ACC_ENUM;
|
public final static short MAX_ACC_FLAG = ACC_ENUM;
|
||||||
|
|
||||||
public final static String[] ACCESS_NAMES = {
|
public final static String[] ACCESS_NAMES = { "public", "private",
|
||||||
"public", "private", "protected", "static", "final", "synchronized",
|
"protected", "static", "final", "synchronized", "volatile",
|
||||||
"volatile", "transient", "native", "interface", "abstract", "strictfp",
|
"transient", "native", "interface", "abstract", "strictfp",
|
||||||
"synthetic", "annotation", "enum"
|
"synthetic", "annotation", "enum" };
|
||||||
};
|
|
||||||
|
|
||||||
/** Tags in constant pool to denote type of constant.
|
/**
|
||||||
|
* Tags in constant pool to denote type of constant.
|
||||||
*/
|
*/
|
||||||
public final static byte CONSTANT_Utf8 = 1;
|
public final static byte CONSTANT_Utf8 = 1;
|
||||||
public final static byte CONSTANT_Integer = 3;
|
public final static byte CONSTANT_Integer = 3;
|
||||||
@ -94,35 +98,39 @@ public interface Constants {
|
|||||||
public final static byte CONSTANT_InterfaceMethodref = 11;
|
public final static byte CONSTANT_InterfaceMethodref = 11;
|
||||||
public final static byte CONSTANT_NameAndType = 12;
|
public final static byte CONSTANT_NameAndType = 12;
|
||||||
|
|
||||||
public final static String[] CONSTANT_NAMES = {
|
public final static String[] CONSTANT_NAMES = { "", "CONSTANT_Utf8", "",
|
||||||
"", "CONSTANT_Utf8", "", "CONSTANT_Integer",
|
"CONSTANT_Integer", "CONSTANT_Float", "CONSTANT_Long",
|
||||||
"CONSTANT_Float", "CONSTANT_Long", "CONSTANT_Double",
|
"CONSTANT_Double", "CONSTANT_Class", "CONSTANT_String",
|
||||||
"CONSTANT_Class", "CONSTANT_String", "CONSTANT_Fieldref",
|
"CONSTANT_Fieldref", "CONSTANT_Methodref",
|
||||||
"CONSTANT_Methodref", "CONSTANT_InterfaceMethodref",
|
"CONSTANT_InterfaceMethodref", "CONSTANT_NameAndType" };
|
||||||
"CONSTANT_NameAndType" };
|
|
||||||
|
|
||||||
/** The name of the static initializer, also called "class
|
/**
|
||||||
|
* The name of the static initializer, also called "class
|
||||||
* initialization method" or "interface initialization
|
* initialization method" or "interface initialization
|
||||||
* method". This is "<clinit>".
|
* method". This is "<clinit>".
|
||||||
*/
|
*/
|
||||||
public final static String STATIC_INITIALIZER_NAME = "<clinit>";
|
public final static String STATIC_INITIALIZER_NAME = "<clinit>";
|
||||||
|
|
||||||
/** The name of every constructor method in a class, also called
|
/**
|
||||||
* "instance initialization method". This is "<init>".
|
* The name of every constructor method in a class, also called
|
||||||
|
* "instance initialization method". This is
|
||||||
|
* "<init>".
|
||||||
*/
|
*/
|
||||||
public final static String CONSTRUCTOR_NAME = "<init>";
|
public final static String CONSTRUCTOR_NAME = "<init>";
|
||||||
|
|
||||||
/** The names of the interfaces implemented by arrays */
|
/** The names of the interfaces implemented by arrays */
|
||||||
public final static String[] INTERFACES_IMPLEMENTED_BY_ARRAYS = {"java.lang.Cloneable", "java.io.Serializable"};
|
public final static String[] INTERFACES_IMPLEMENTED_BY_ARRAYS = {
|
||||||
|
"java.lang.Cloneable", "java.io.Serializable" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Limitations of the Java Virtual Machine.
|
* Limitations of the Java Virtual Machine. See The Java Virtual Machine
|
||||||
* See The Java Virtual Machine Specification, Second Edition, page 152, chapter 4.10.
|
* Specification, Second Edition, page 152, chapter 4.10.
|
||||||
*/
|
*/
|
||||||
public static final int MAX_CP_ENTRIES = 65535;
|
public static final int MAX_CP_ENTRIES = 65535;
|
||||||
public static final int MAX_CODE_SIZE = 65536; // bytes
|
public static final int MAX_CODE_SIZE = 65536; // bytes
|
||||||
|
|
||||||
/** Java VM opcodes.
|
/**
|
||||||
|
* Java VM opcodes.
|
||||||
*/
|
*/
|
||||||
public static final short NOP = 0;
|
public static final short NOP = 0;
|
||||||
public static final short ACONST_NULL = 1;
|
public static final short ACONST_NULL = 1;
|
||||||
@ -393,45 +401,45 @@ public interface Constants {
|
|||||||
public static final byte T_UNKNOWN = 15;
|
public static final byte T_UNKNOWN = 15;
|
||||||
public static final byte T_ADDRESS = 16;
|
public static final byte T_ADDRESS = 16;
|
||||||
|
|
||||||
/** The primitive type names corresponding to the T_XX constants,
|
/**
|
||||||
* e.g., TYPE_NAMES[T_INT] = "int"
|
* The primitive type names corresponding to the T_XX constants, e.g.,
|
||||||
|
* TYPE_NAMES[T_INT] = "int"
|
||||||
*/
|
*/
|
||||||
public static final String[] TYPE_NAMES = {
|
public static final String[] TYPE_NAMES = { ILLEGAL_TYPE, ILLEGAL_TYPE,
|
||||||
ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE,
|
ILLEGAL_TYPE, ILLEGAL_TYPE, "boolean", "char", "float", "double",
|
||||||
"boolean", "char", "float", "double", "byte", "short", "int", "long",
|
"byte", "short", "int", "long", "void", "array", "object",
|
||||||
"void", "array", "object", "unknown" // Non-standard
|
"unknown" // Non-standard
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The primitive class names corresponding to the T_XX constants,
|
/**
|
||||||
* e.g., CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer"
|
* The primitive class names corresponding to the T_XX constants, e.g.,
|
||||||
|
* CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer"
|
||||||
*/
|
*/
|
||||||
public static final String[] CLASS_TYPE_NAMES = {
|
public static final String[] CLASS_TYPE_NAMES = { ILLEGAL_TYPE,
|
||||||
ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE,
|
ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, "java.lang.Boolean",
|
||||||
"java.lang.Boolean", "java.lang.Character", "java.lang.Float",
|
"java.lang.Character", "java.lang.Float", "java.lang.Double",
|
||||||
"java.lang.Double", "java.lang.Byte", "java.lang.Short",
|
"java.lang.Byte", "java.lang.Short", "java.lang.Integer",
|
||||||
"java.lang.Integer", "java.lang.Long", "java.lang.Void",
|
"java.lang.Long", "java.lang.Void", ILLEGAL_TYPE, ILLEGAL_TYPE,
|
||||||
ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE
|
ILLEGAL_TYPE };
|
||||||
};
|
|
||||||
|
|
||||||
/** The signature characters corresponding to primitive types,
|
/**
|
||||||
* e.g., SHORT_TYPE_NAMES[T_INT] = "I"
|
* The signature characters corresponding to primitive types, e.g.,
|
||||||
|
* SHORT_TYPE_NAMES[T_INT] = "I"
|
||||||
*/
|
*/
|
||||||
public static final String[] SHORT_TYPE_NAMES = {
|
public static final String[] SHORT_TYPE_NAMES = { ILLEGAL_TYPE,
|
||||||
ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE,
|
ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, "Z", "C", "F", "D", "B",
|
||||||
"Z", "C", "F", "D", "B", "S", "I", "J",
|
"S", "I", "J", "V", ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE };
|
||||||
"V", ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of byte code operands, i.e., number of bytes after the tag byte
|
* Number of byte code operands, i.e., number of bytes after the tag byte
|
||||||
* itself.
|
* itself.
|
||||||
*/
|
*/
|
||||||
public static final short[] NO_OF_OPERANDS = {
|
public static final short[] NO_OF_OPERANDS = { 0/* nop */,
|
||||||
0/*nop*/, 0/*aconst_null*/, 0/*iconst_m1*/, 0/*iconst_0*/,
|
0/* aconst_null */, 0/* iconst_m1 */, 0/* iconst_0 */, 0/* iconst_1 */,
|
||||||
0/*iconst_1*/, 0/*iconst_2*/, 0/*iconst_3*/, 0/*iconst_4*/,
|
0/* iconst_2 */, 0/* iconst_3 */, 0/* iconst_4 */, 0/* iconst_5 */,
|
||||||
0/*iconst_5*/, 0/*lconst_0*/, 0/*lconst_1*/, 0/*fconst_0*/,
|
0/* lconst_0 */, 0/* lconst_1 */, 0/* fconst_0 */, 0/* fconst_1 */,
|
||||||
0/*fconst_1*/, 0/*fconst_2*/, 0/*dconst_0*/, 0/*dconst_1*/,
|
0/* fconst_2 */, 0/* dconst_0 */, 0/* dconst_1 */, 1/* bipush */,
|
||||||
1/*bipush*/, 2/*sipush*/, 1/*ldc*/, 2/*ldc_w*/, 2/*ldc2_w*/,
|
2/* sipush */, 1/* ldc */, 2/* ldc_w */, 2/* ldc2_w */,
|
||||||
1/* iload */, 1/* lload */, 1/* fload */, 1/* dload */, 1/* aload */,
|
1/* iload */, 1/* lload */, 1/* fload */, 1/* dload */, 1/* aload */,
|
||||||
0/* iload_0 */, 0/* iload_1 */, 0/* iload_2 */, 0/* iload_3 */,
|
0/* iload_0 */, 0/* iload_1 */, 0/* iload_2 */, 0/* iload_3 */,
|
||||||
0/* lload_0 */, 0/* lload_1 */, 0/* lload_2 */, 0/* lload_3 */,
|
0/* lload_0 */, 0/* lload_1 */, 0/* lload_2 */, 0/* lload_3 */,
|
||||||
@ -449,33 +457,33 @@ public interface Constants {
|
|||||||
0/* astore_3 */, 0/* iastore */, 0/* lastore */, 0/* fastore */,
|
0/* astore_3 */, 0/* iastore */, 0/* lastore */, 0/* fastore */,
|
||||||
0/* dastore */, 0/* aastore */, 0/* bastore */, 0/* castore */,
|
0/* dastore */, 0/* aastore */, 0/* bastore */, 0/* castore */,
|
||||||
0/* sastore */, 0/* pop */, 0/* pop2 */, 0/* dup */, 0/* dup_x1 */,
|
0/* sastore */, 0/* pop */, 0/* pop2 */, 0/* dup */, 0/* dup_x1 */,
|
||||||
0/*dup_x2*/, 0/*dup2*/, 0/*dup2_x1*/, 0/*dup2_x2*/, 0/*swap*/,
|
0/* dup_x2 */, 0/* dup2 */, 0/* dup2_x1 */, 0/* dup2_x2 */,
|
||||||
0/*iadd*/, 0/*ladd*/, 0/*fadd*/, 0/*dadd*/, 0/*isub*/,
|
0/* swap */, 0/* iadd */, 0/* ladd */, 0/* fadd */, 0/* dadd */,
|
||||||
0/*lsub*/, 0/*fsub*/, 0/*dsub*/, 0/*imul*/, 0/*lmul*/,
|
0/* isub */, 0/* lsub */, 0/* fsub */, 0/* dsub */, 0/* imul */,
|
||||||
0/*fmul*/, 0/*dmul*/, 0/*idiv*/, 0/*ldiv*/, 0/*fdiv*/,
|
0/* lmul */, 0/* fmul */, 0/* dmul */, 0/* idiv */, 0/* ldiv */,
|
||||||
0/*ddiv*/, 0/*irem*/, 0/*lrem*/, 0/*frem*/, 0/*drem*/,
|
0/* fdiv */, 0/* ddiv */, 0/* irem */, 0/* lrem */, 0/* frem */,
|
||||||
0/*ineg*/, 0/*lneg*/, 0/*fneg*/, 0/*dneg*/, 0/*ishl*/,
|
0/* drem */, 0/* ineg */, 0/* lneg */, 0/* fneg */, 0/* dneg */,
|
||||||
0/*lshl*/, 0/*ishr*/, 0/*lshr*/, 0/*iushr*/, 0/*lushr*/,
|
0/* ishl */, 0/* lshl */, 0/* ishr */, 0/* lshr */, 0/* iushr */,
|
||||||
0/*iand*/, 0/*land*/, 0/*ior*/, 0/*lor*/, 0/*ixor*/, 0/*lxor*/,
|
0/* lushr */, 0/* iand */, 0/* land */, 0/* ior */, 0/* lor */,
|
||||||
2/*iinc*/, 0/*i2l*/, 0/*i2f*/, 0/*i2d*/, 0/*l2i*/, 0/*l2f*/,
|
0/* ixor */, 0/* lxor */, 2/* iinc */, 0/* i2l */, 0/* i2f */,
|
||||||
0/*l2d*/, 0/*f2i*/, 0/*f2l*/, 0/*f2d*/, 0/*d2i*/, 0/*d2l*/,
|
0/* i2d */, 0/* l2i */, 0/* l2f */, 0/* l2d */, 0/* f2i */,
|
||||||
0/*d2f*/, 0/*i2b*/, 0/*i2c*/, 0/*i2s*/, 0/*lcmp*/, 0/*fcmpl*/,
|
0/* f2l */, 0/* f2d */, 0/* d2i */, 0/* d2l */, 0/* d2f */,
|
||||||
|
0/* i2b */, 0/* i2c */, 0/* i2s */, 0/* lcmp */, 0/* fcmpl */,
|
||||||
0/* fcmpg */, 0/* dcmpl */, 0/* dcmpg */, 2/* ifeq */, 2/* ifne */,
|
0/* fcmpg */, 0/* dcmpl */, 0/* dcmpg */, 2/* ifeq */, 2/* ifne */,
|
||||||
2/* iflt */, 2/* ifge */, 2/* ifgt */, 2/* ifle */, 2/* if_icmpeq */,
|
2/* iflt */, 2/* ifge */, 2/* ifgt */, 2/* ifle */, 2/* if_icmpeq */,
|
||||||
2/* if_icmpne */, 2/* if_icmplt */, 2/* if_icmpge */, 2/* if_icmpgt */,
|
2/* if_icmpne */, 2/* if_icmplt */, 2/* if_icmpge */, 2/* if_icmpgt */,
|
||||||
2/* if_icmple */, 2/* if_acmpeq */, 2/* if_acmpne */, 2/* goto */,
|
2/* if_icmple */, 2/* if_acmpeq */, 2/* if_acmpne */, 2/* goto */,
|
||||||
2/*jsr*/, 1/*ret*/, UNPREDICTABLE/*tableswitch*/, UNPREDICTABLE/*lookupswitch*/,
|
2/* jsr */, 1/* ret */, UNPREDICTABLE/* tableswitch */,
|
||||||
0/*ireturn*/, 0/*lreturn*/, 0/*freturn*/,
|
UNPREDICTABLE/* lookupswitch */, 0/* ireturn */, 0/* lreturn */,
|
||||||
0/*dreturn*/, 0/*areturn*/, 0/*return*/,
|
0/* freturn */, 0/* dreturn */, 0/* areturn */, 0/* return */,
|
||||||
2/*getstatic*/, 2/*putstatic*/, 2/*getfield*/,
|
2/* getstatic */, 2/* putstatic */, 2/* getfield */, 2/* putfield */,
|
||||||
2/*putfield*/, 2/*invokevirtual*/, 2/*invokespecial*/, 2/*invokestatic*/,
|
2/* invokevirtual */, 2/* invokespecial */, 2/* invokestatic */,
|
||||||
4/*invokeinterface*/, UNDEFINED, 2/*new*/,
|
4/* invokeinterface */, UNDEFINED, 2/* new */, 1/* newarray */,
|
||||||
1/*newarray*/, 2/*anewarray*/,
|
2/* anewarray */, 0/* arraylength */, 0/* athrow */,
|
||||||
0/*arraylength*/, 0/*athrow*/, 2/*checkcast*/,
|
2/* checkcast */, 2/* instanceof */, 0/* monitorenter */,
|
||||||
2/*instanceof*/, 0/*monitorenter*/,
|
|
||||||
0/* monitorexit */, UNPREDICTABLE/* wide */, 3/* multianewarray */,
|
0/* monitorexit */, UNPREDICTABLE/* wide */, 3/* multianewarray */,
|
||||||
2/*ifnull*/, 2/*ifnonnull*/, 4/*goto_w*/,
|
2/* ifnull */, 2/* ifnonnull */, 4/* goto_w */, 4/* jsr_w */,
|
||||||
4/*jsr_w*/, 0/*breakpoint*/, UNDEFINED,
|
0/* breakpoint */, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
@ -483,95 +491,98 @@ public interface Constants {
|
|||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, RESERVED/*impdep1*/, RESERVED/*impdep2*/
|
RESERVED/* impdep1 */, RESERVED /* impdep2 */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How the byte code operands are to be interpreted.
|
* How the byte code operands are to be interpreted.
|
||||||
*/
|
*/
|
||||||
public static final short[][] TYPE_OF_OPERANDS = {
|
public static final short[][] TYPE_OF_OPERANDS = { {}/* nop */,
|
||||||
{}/*nop*/, {}/*aconst_null*/, {}/*iconst_m1*/, {}/*iconst_0*/,
|
{}/* aconst_null */, {}/* iconst_m1 */, {}/* iconst_0 */,
|
||||||
{}/* iconst_1 */, {}/* iconst_2 */, {}/* iconst_3 */, {}/* iconst_4 */,
|
{}/* iconst_1 */, {}/* iconst_2 */, {}/* iconst_3 */, {}/* iconst_4 */,
|
||||||
{}/* iconst_5 */, {}/* lconst_0 */, {}/* lconst_1 */, {}/* fconst_0 */,
|
{}/* iconst_5 */, {}/* lconst_0 */, {}/* lconst_1 */, {}/* fconst_0 */,
|
||||||
{}/* fconst_1 */, {}/* fconst_2 */, {}/* dconst_0 */, {}/* dconst_1 */,
|
{}/* fconst_1 */, {}/* fconst_2 */, {}/* dconst_0 */, {}/* dconst_1 */,
|
||||||
{ T_BYTE }/* bipush */, { T_SHORT }/* sipush */, { T_BYTE }/* ldc */,
|
{ T_BYTE }/* bipush */, { T_SHORT }/* sipush */, { T_BYTE }/* ldc */,
|
||||||
{ T_SHORT }/* ldc_w */, { T_SHORT }/* ldc2_w */,
|
{ T_SHORT }/* ldc_w */, { T_SHORT }/* ldc2_w */,
|
||||||
{T_BYTE}/*iload*/, {T_BYTE}/*lload*/, {T_BYTE}/*fload*/,
|
{ T_BYTE }/* iload */, { T_BYTE }/* lload */,
|
||||||
{T_BYTE}/*dload*/, {T_BYTE}/*aload*/, {}/*iload_0*/,
|
{ T_BYTE }/* fload */, { T_BYTE }/* dload */,
|
||||||
{}/*iload_1*/, {}/*iload_2*/, {}/*iload_3*/, {}/*lload_0*/,
|
{ T_BYTE }/* aload */, {}/* iload_0 */, {}/* iload_1 */,
|
||||||
{}/*lload_1*/, {}/*lload_2*/, {}/*lload_3*/, {}/*fload_0*/,
|
{}/* iload_2 */, {}/* iload_3 */, {}/* lload_0 */, {}/* lload_1 */,
|
||||||
{}/*fload_1*/, {}/*fload_2*/, {}/*fload_3*/, {}/*dload_0*/,
|
{}/* lload_2 */, {}/* lload_3 */, {}/* fload_0 */, {}/* fload_1 */,
|
||||||
{}/*dload_1*/, {}/*dload_2*/, {}/*dload_3*/, {}/*aload_0*/,
|
{}/* fload_2 */, {}/* fload_3 */, {}/* dload_0 */, {}/* dload_1 */,
|
||||||
{}/*aload_1*/, {}/*aload_2*/, {}/*aload_3*/, {}/*iaload*/,
|
{}/* dload_2 */, {}/* dload_3 */, {}/* aload_0 */, {}/* aload_1 */,
|
||||||
{}/*laload*/, {}/*faload*/, {}/*daload*/, {}/*aaload*/,
|
{}/* aload_2 */, {}/* aload_3 */, {}/* iaload */, {}/* laload */,
|
||||||
{}/*baload*/, {}/*caload*/, {}/*saload*/, {T_BYTE}/*istore*/,
|
{}/* faload */, {}/* daload */, {}/* aaload */, {}/* baload */,
|
||||||
{T_BYTE}/*lstore*/, {T_BYTE}/*fstore*/, {T_BYTE}/*dstore*/,
|
{}/* caload */, {}/* saload */, { T_BYTE }/* istore */,
|
||||||
{T_BYTE}/*astore*/, {}/*istore_0*/, {}/*istore_1*/,
|
{ T_BYTE }/* lstore */, { T_BYTE }/* fstore */,
|
||||||
{}/*istore_2*/, {}/*istore_3*/, {}/*lstore_0*/, {}/*lstore_1*/,
|
{ T_BYTE }/* dstore */, { T_BYTE }/* astore */, {}/* istore_0 */,
|
||||||
{}/*lstore_2*/, {}/*lstore_3*/, {}/*fstore_0*/, {}/*fstore_1*/,
|
{}/* istore_1 */, {}/* istore_2 */, {}/* istore_3 */, {}/* lstore_0 */,
|
||||||
{}/*fstore_2*/, {}/*fstore_3*/, {}/*dstore_0*/, {}/*dstore_1*/,
|
{}/* lstore_1 */, {}/* lstore_2 */, {}/* lstore_3 */, {}/* fstore_0 */,
|
||||||
{}/*dstore_2*/, {}/*dstore_3*/, {}/*astore_0*/, {}/*astore_1*/,
|
{}/* fstore_1 */, {}/* fstore_2 */, {}/* fstore_3 */, {}/* dstore_0 */,
|
||||||
{}/*astore_2*/, {}/*astore_3*/, {}/*iastore*/, {}/*lastore*/,
|
{}/* dstore_1 */, {}/* dstore_2 */, {}/* dstore_3 */, {}/* astore_0 */,
|
||||||
{}/*fastore*/, {}/*dastore*/, {}/*aastore*/, {}/*bastore*/,
|
{}/* astore_1 */, {}/* astore_2 */, {}/* astore_3 */, {}/* iastore */,
|
||||||
{}/*castore*/, {}/*sastore*/, {}/*pop*/, {}/*pop2*/, {}/*dup*/,
|
{}/* lastore */, {}/* fastore */, {}/* dastore */, {}/* aastore */,
|
||||||
{}/*dup_x1*/, {}/*dup_x2*/, {}/*dup2*/, {}/*dup2_x1*/,
|
{}/* bastore */, {}/* castore */, {}/* sastore */, {}/* pop */,
|
||||||
{}/*dup2_x2*/, {}/*swap*/, {}/*iadd*/, {}/*ladd*/, {}/*fadd*/,
|
{}/* pop2 */, {}/* dup */, {}/* dup_x1 */, {}/* dup_x2 */, {}/* dup2 */,
|
||||||
{}/*dadd*/, {}/*isub*/, {}/*lsub*/, {}/*fsub*/, {}/*dsub*/,
|
{}/* dup2_x1 */, {}/* dup2_x2 */, {}/* swap */, {}/* iadd */, {}/* ladd */,
|
||||||
{}/*imul*/, {}/*lmul*/, {}/*fmul*/, {}/*dmul*/, {}/*idiv*/,
|
{}/* fadd */, {}/* dadd */, {}/* isub */, {}/* lsub */, {}/* fsub */,
|
||||||
{}/*ldiv*/, {}/*fdiv*/, {}/*ddiv*/, {}/*irem*/, {}/*lrem*/,
|
{}/* dsub */, {}/* imul */, {}/* lmul */, {}/* fmul */, {}/* dmul */,
|
||||||
{}/*frem*/, {}/*drem*/, {}/*ineg*/, {}/*lneg*/, {}/*fneg*/,
|
{}/* idiv */, {}/* ldiv */, {}/* fdiv */, {}/* ddiv */, {}/* irem */,
|
||||||
{}/*dneg*/, {}/*ishl*/, {}/*lshl*/, {}/*ishr*/, {}/*lshr*/,
|
{}/* lrem */, {}/* frem */, {}/* drem */, {}/* ineg */, {}/* lneg */,
|
||||||
{}/*iushr*/, {}/*lushr*/, {}/*iand*/, {}/*land*/, {}/*ior*/,
|
{}/* fneg */, {}/* dneg */, {}/* ishl */, {}/* lshl */, {}/* ishr */,
|
||||||
{}/*lor*/, {}/*ixor*/, {}/*lxor*/, {T_BYTE, T_BYTE}/*iinc*/,
|
{}/* lshr */, {}/* iushr */, {}/* lushr */, {}/* iand */, {}/* land */,
|
||||||
{}/*i2l*/, {}/*i2f*/, {}/*i2d*/, {}/*l2i*/, {}/*l2f*/, {}/*l2d*/,
|
{}/* ior */, {}/* lor */, {}/* ixor */, {}/* lxor */,
|
||||||
{}/*f2i*/, {}/*f2l*/, {}/*f2d*/, {}/*d2i*/, {}/*d2l*/, {}/*d2f*/,
|
{ T_BYTE, T_BYTE }/* iinc */, {}/* i2l */, {}/* i2f */, {}/* i2d */,
|
||||||
{}/*i2b*/, {}/*i2c*/,{}/*i2s*/, {}/*lcmp*/, {}/*fcmpl*/,
|
{}/* l2i */, {}/* l2f */, {}/* l2d */, {}/* f2i */, {}/* f2l */,
|
||||||
{}/*fcmpg*/, {}/*dcmpl*/, {}/*dcmpg*/, {T_SHORT}/*ifeq*/,
|
{}/* f2d */, {}/* d2i */, {}/* d2l */, {}/* d2f */, {}/* i2b */,
|
||||||
{T_SHORT}/*ifne*/, {T_SHORT}/*iflt*/, {T_SHORT}/*ifge*/,
|
{}/* i2c */, {}/* i2s */, {}/* lcmp */, {}/* fcmpl */, {}/* fcmpg */,
|
||||||
{T_SHORT}/*ifgt*/, {T_SHORT}/*ifle*/, {T_SHORT}/*if_icmpeq*/,
|
{}/* dcmpl */, {}/* dcmpg */, { T_SHORT }/* ifeq */,
|
||||||
|
{ T_SHORT }/* ifne */, { T_SHORT }/* iflt */,
|
||||||
|
{ T_SHORT }/* ifge */, { T_SHORT }/* ifgt */,
|
||||||
|
{ T_SHORT }/* ifle */, { T_SHORT }/* if_icmpeq */,
|
||||||
{ T_SHORT }/* if_icmpne */, { T_SHORT }/* if_icmplt */,
|
{ T_SHORT }/* if_icmpne */, { T_SHORT }/* if_icmplt */,
|
||||||
{ T_SHORT }/* if_icmpge */, { T_SHORT }/* if_icmpgt */,
|
{ T_SHORT }/* if_icmpge */, { T_SHORT }/* if_icmpgt */,
|
||||||
{ T_SHORT }/* if_icmple */, { T_SHORT }/* if_acmpeq */,
|
{ T_SHORT }/* if_icmple */, { T_SHORT }/* if_acmpeq */,
|
||||||
{T_SHORT}/*if_acmpne*/, {T_SHORT}/*goto*/, {T_SHORT}/*jsr*/,
|
{ T_SHORT }/* if_acmpne */, { T_SHORT }/* goto */,
|
||||||
{T_BYTE}/*ret*/, {}/*tableswitch*/, {}/*lookupswitch*/,
|
{ T_SHORT }/* jsr */, { T_BYTE }/* ret */, {}/* tableswitch */,
|
||||||
{}/*ireturn*/, {}/*lreturn*/, {}/*freturn*/, {}/*dreturn*/,
|
{}/* lookupswitch */, {}/* ireturn */, {}/* lreturn */, {}/* freturn */,
|
||||||
{}/*areturn*/, {}/*return*/, {T_SHORT}/*getstatic*/,
|
{}/* dreturn */, {}/* areturn */, {}/* return */,
|
||||||
{T_SHORT}/*putstatic*/, {T_SHORT}/*getfield*/,
|
{ T_SHORT }/* getstatic */, { T_SHORT }/* putstatic */,
|
||||||
{T_SHORT}/*putfield*/, {T_SHORT}/*invokevirtual*/,
|
{ T_SHORT }/* getfield */, { T_SHORT }/* putfield */,
|
||||||
{T_SHORT}/*invokespecial*/, {T_SHORT}/*invokestatic*/,
|
{ T_SHORT }/* invokevirtual */, { T_SHORT }/* invokespecial */,
|
||||||
|
{ T_SHORT }/* invokestatic */,
|
||||||
{ T_SHORT, T_BYTE, T_BYTE }/* invokeinterface */, {},
|
{ T_SHORT, T_BYTE, T_BYTE }/* invokeinterface */, {},
|
||||||
{ T_SHORT }/* new */, { T_BYTE }/* newarray */,
|
{ T_SHORT }/* new */, { T_BYTE }/* newarray */,
|
||||||
{ T_SHORT }/* anewarray */, {}/* arraylength */, {}/* athrow */,
|
{ T_SHORT }/* anewarray */, {}/* arraylength */, {}/* athrow */,
|
||||||
{ T_SHORT }/* checkcast */, { T_SHORT }/* instanceof */,
|
{ T_SHORT }/* checkcast */, { T_SHORT }/* instanceof */,
|
||||||
{}/* monitorenter */, {}/* monitorexit */, { T_BYTE }/* wide */,
|
{}/* monitorenter */, {}/* monitorexit */, { T_BYTE }/* wide */,
|
||||||
{ T_SHORT, T_BYTE }/* multianewarray */, { T_SHORT }/* ifnull */,
|
{ T_SHORT, T_BYTE }/* multianewarray */, { T_SHORT }/* ifnull */,
|
||||||
{T_SHORT}/*ifnonnull*/, {T_INT}/*goto_w*/, {T_INT}/*jsr_w*/,
|
{ T_SHORT }/* ifnonnull */, { T_INT }/* goto_w */,
|
||||||
{}/*breakpoint*/, {}, {}, {}, {}, {}, {}, {},
|
{ T_INT }/* jsr_w */, {}/* breakpoint */, {}, {}, {}, {}, {}, {},
|
||||||
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
|
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
|
||||||
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
|
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
|
||||||
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
|
{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}/* impdep1 */, {} /* impdep2 */
|
||||||
{}/*impdep1*/, {}/*impdep2*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Names of opcodes.
|
* Names of opcodes.
|
||||||
*/
|
*/
|
||||||
public static final String[] OPCODE_NAMES = {
|
public static final String[] OPCODE_NAMES = { "nop", "aconst_null",
|
||||||
"nop", "aconst_null", "iconst_m1", "iconst_0", "iconst_1",
|
"iconst_m1", "iconst_0", "iconst_1", "iconst_2", "iconst_3",
|
||||||
"iconst_2", "iconst_3", "iconst_4", "iconst_5", "lconst_0",
|
"iconst_4", "iconst_5", "lconst_0", "lconst_1", "fconst_0",
|
||||||
"lconst_1", "fconst_0", "fconst_1", "fconst_2", "dconst_0",
|
"fconst_1", "fconst_2", "dconst_0", "dconst_1", "bipush", "sipush",
|
||||||
"dconst_1", "bipush", "sipush", "ldc", "ldc_w", "ldc2_w", "iload",
|
"ldc", "ldc_w", "ldc2_w", "iload", "lload", "fload", "dload",
|
||||||
"lload", "fload", "dload", "aload", "iload_0", "iload_1", "iload_2",
|
"aload", "iload_0", "iload_1", "iload_2", "iload_3", "lload_0",
|
||||||
"iload_3", "lload_0", "lload_1", "lload_2", "lload_3", "fload_0",
|
"lload_1", "lload_2", "lload_3", "fload_0", "fload_1", "fload_2",
|
||||||
"fload_1", "fload_2", "fload_3", "dload_0", "dload_1", "dload_2",
|
"fload_3", "dload_0", "dload_1", "dload_2", "dload_3", "aload_0",
|
||||||
"dload_3", "aload_0", "aload_1", "aload_2", "aload_3", "iaload",
|
"aload_1", "aload_2", "aload_3", "iaload", "laload", "faload",
|
||||||
"laload", "faload", "daload", "aaload", "baload", "caload", "saload",
|
"daload", "aaload", "baload", "caload", "saload", "istore",
|
||||||
"istore", "lstore", "fstore", "dstore", "astore", "istore_0",
|
"lstore", "fstore", "dstore", "astore", "istore_0", "istore_1",
|
||||||
"istore_1", "istore_2", "istore_3", "lstore_0", "lstore_1",
|
"istore_2", "istore_3", "lstore_0", "lstore_1", "lstore_2",
|
||||||
"lstore_2", "lstore_3", "fstore_0", "fstore_1", "fstore_2",
|
"lstore_3", "fstore_0", "fstore_1", "fstore_2", "fstore_3",
|
||||||
"fstore_3", "dstore_0", "dstore_1", "dstore_2", "dstore_3",
|
"dstore_0", "dstore_1", "dstore_2", "dstore_3", "astore_0",
|
||||||
"astore_0", "astore_1", "astore_2", "astore_3", "iastore", "lastore",
|
"astore_1", "astore_2", "astore_3", "iastore", "lastore",
|
||||||
"fastore", "dastore", "aastore", "bastore", "castore", "sastore",
|
"fastore", "dastore", "aastore", "bastore", "castore", "sastore",
|
||||||
"pop", "pop2", "dup", "dup_x1", "dup_x2", "dup2", "dup2_x1",
|
"pop", "pop2", "dup", "dup_x1", "dup_x2", "dup2", "dup2_x1",
|
||||||
"dup2_x2", "swap", "iadd", "ladd", "fadd", "dadd", "isub", "lsub",
|
"dup2_x2", "swap", "iadd", "ladd", "fadd", "dadd", "isub", "lsub",
|
||||||
@ -579,18 +590,19 @@ public interface Constants {
|
|||||||
"fdiv", "ddiv", "irem", "lrem", "frem", "drem", "ineg", "lneg",
|
"fdiv", "ddiv", "irem", "lrem", "frem", "drem", "ineg", "lneg",
|
||||||
"fneg", "dneg", "ishl", "lshl", "ishr", "lshr", "iushr", "lushr",
|
"fneg", "dneg", "ishl", "lshl", "ishr", "lshr", "iushr", "lushr",
|
||||||
"iand", "land", "ior", "lor", "ixor", "lxor", "iinc", "i2l", "i2f",
|
"iand", "land", "ior", "lor", "ixor", "lxor", "iinc", "i2l", "i2f",
|
||||||
"i2d", "l2i", "l2f", "l2d", "f2i", "f2l", "f2d", "d2i", "d2l", "d2f",
|
"i2d", "l2i", "l2f", "l2d", "f2i", "f2l", "f2d", "d2i", "d2l",
|
||||||
"i2b", "i2c", "i2s", "lcmp", "fcmpl", "fcmpg",
|
"d2f", "i2b", "i2c", "i2s", "lcmp", "fcmpl", "fcmpg", "dcmpl",
|
||||||
"dcmpl", "dcmpg", "ifeq", "ifne", "iflt", "ifge", "ifgt", "ifle",
|
"dcmpg", "ifeq", "ifne", "iflt", "ifge", "ifgt", "ifle",
|
||||||
"if_icmpeq", "if_icmpne", "if_icmplt", "if_icmpge", "if_icmpgt",
|
"if_icmpeq", "if_icmpne", "if_icmplt", "if_icmpge", "if_icmpgt",
|
||||||
"if_icmple", "if_acmpeq", "if_acmpne", "goto", "jsr", "ret",
|
"if_icmple", "if_acmpeq", "if_acmpne", "goto", "jsr", "ret",
|
||||||
"tableswitch", "lookupswitch", "ireturn", "lreturn", "freturn",
|
"tableswitch", "lookupswitch", "ireturn", "lreturn", "freturn",
|
||||||
"dreturn", "areturn", "return", "getstatic", "putstatic", "getfield",
|
"dreturn", "areturn", "return", "getstatic", "putstatic",
|
||||||
"putfield", "invokevirtual", "invokespecial", "invokestatic",
|
"getfield", "putfield", "invokevirtual", "invokespecial",
|
||||||
"invokeinterface", ILLEGAL_OPCODE, "new", "newarray", "anewarray",
|
"invokestatic", "invokeinterface", ILLEGAL_OPCODE, "new",
|
||||||
"arraylength", "athrow", "checkcast", "instanceof", "monitorenter",
|
"newarray", "anewarray", "arraylength", "athrow", "checkcast",
|
||||||
"monitorexit", "wide", "multianewarray", "ifnull", "ifnonnull",
|
"instanceof", "monitorenter", "monitorexit", "wide",
|
||||||
"goto_w", "jsr_w", "breakpoint", ILLEGAL_OPCODE, ILLEGAL_OPCODE,
|
"multianewarray", "ifnull", "ifnonnull", "goto_w", "jsr_w",
|
||||||
|
"breakpoint", ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
|
||||||
ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
|
ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
|
||||||
ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
|
ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
|
||||||
ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
|
ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
|
||||||
@ -603,118 +615,140 @@ public interface Constants {
|
|||||||
ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
|
ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
|
||||||
ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
|
ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
|
||||||
ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
|
ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
|
||||||
ILLEGAL_OPCODE, "impdep1", "impdep2"
|
"impdep1", "impdep2" };
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of words consumed on operand stack by instructions.
|
* Number of words consumed on operand stack by instructions.
|
||||||
*/
|
*/
|
||||||
public static final int[] CONSUME_STACK = {
|
public static final int[] CONSUME_STACK = { 0/* nop */, 0/* aconst_null */,
|
||||||
0/*nop*/, 0/*aconst_null*/, 0/*iconst_m1*/, 0/*iconst_0*/, 0/*iconst_1*/,
|
0/* iconst_m1 */, 0/* iconst_0 */, 0/* iconst_1 */, 0/* iconst_2 */,
|
||||||
0/*iconst_2*/, 0/*iconst_3*/, 0/*iconst_4*/, 0/*iconst_5*/, 0/*lconst_0*/,
|
0/* iconst_3 */, 0/* iconst_4 */, 0/* iconst_5 */, 0/* lconst_0 */,
|
||||||
0/*lconst_1*/, 0/*fconst_0*/, 0/*fconst_1*/, 0/*fconst_2*/, 0/*dconst_0*/,
|
0/* lconst_1 */, 0/* fconst_0 */, 0/* fconst_1 */, 0/* fconst_2 */,
|
||||||
0/*dconst_1*/, 0/*bipush*/, 0/*sipush*/, 0/*ldc*/, 0/*ldc_w*/, 0/*ldc2_w*/, 0/*iload*/,
|
0/* dconst_0 */, 0/* dconst_1 */, 0/* bipush */, 0/* sipush */,
|
||||||
0/*lload*/, 0/*fload*/, 0/*dload*/, 0/*aload*/, 0/*iload_0*/, 0/*iload_1*/, 0/*iload_2*/,
|
0/* ldc */, 0/* ldc_w */, 0/* ldc2_w */, 0/* iload */, 0/* lload */,
|
||||||
0/*iload_3*/, 0/*lload_0*/, 0/*lload_1*/, 0/*lload_2*/, 0/*lload_3*/, 0/*fload_0*/,
|
0/* fload */, 0/* dload */, 0/* aload */, 0/* iload_0 */, 0/* iload_1 */,
|
||||||
0/*fload_1*/, 0/*fload_2*/, 0/*fload_3*/, 0/*dload_0*/, 0/*dload_1*/, 0/*dload_2*/,
|
0/* iload_2 */, 0/* iload_3 */, 0/* lload_0 */, 0/* lload_1 */,
|
||||||
0/*dload_3*/, 0/*aload_0*/, 0/*aload_1*/, 0/*aload_2*/, 0/*aload_3*/, 2/*iaload*/,
|
0/* lload_2 */, 0/* lload_3 */, 0/* fload_0 */, 0/* fload_1 */,
|
||||||
2/*laload*/, 2/*faload*/, 2/*daload*/, 2/*aaload*/, 2/*baload*/, 2/*caload*/, 2/*saload*/,
|
0/* fload_2 */, 0/* fload_3 */, 0/* dload_0 */, 0/* dload_1 */,
|
||||||
1/*istore*/, 2/*lstore*/, 1/*fstore*/, 2/*dstore*/, 1/*astore*/, 1/*istore_0*/,
|
0/* dload_2 */, 0/* dload_3 */, 0/* aload_0 */, 0/* aload_1 */,
|
||||||
1/*istore_1*/, 1/*istore_2*/, 1/*istore_3*/, 2/*lstore_0*/, 2/*lstore_1*/,
|
0/* aload_2 */, 0/* aload_3 */, 2/* iaload */, 2/* laload */,
|
||||||
2/*lstore_2*/, 2/*lstore_3*/, 1/*fstore_0*/, 1/*fstore_1*/, 1/*fstore_2*/,
|
2/* faload */, 2/* daload */, 2/* aaload */, 2/* baload */,
|
||||||
1/*fstore_3*/, 2/*dstore_0*/, 2/*dstore_1*/, 2/*dstore_2*/, 2/*dstore_3*/,
|
2/* caload */, 2/* saload */, 1/* istore */, 2/* lstore */,
|
||||||
1/*astore_0*/, 1/*astore_1*/, 1/*astore_2*/, 1/*astore_3*/, 3/*iastore*/, 4/*lastore*/,
|
1/* fstore */, 2/* dstore */, 1/* astore */, 1/* istore_0 */,
|
||||||
3/*fastore*/, 4/*dastore*/, 3/*aastore*/, 3/*bastore*/, 3/*castore*/, 3/*sastore*/,
|
1/* istore_1 */, 1/* istore_2 */, 1/* istore_3 */, 2/* lstore_0 */,
|
||||||
1/*pop*/, 2/*pop2*/, 1/*dup*/, 2/*dup_x1*/, 3/*dup_x2*/, 2/*dup2*/, 3/*dup2_x1*/,
|
2/* lstore_1 */, 2/* lstore_2 */, 2/* lstore_3 */, 1/* fstore_0 */,
|
||||||
4/*dup2_x2*/, 2/*swap*/, 2/*iadd*/, 4/*ladd*/, 2/*fadd*/, 4/*dadd*/, 2/*isub*/, 4/*lsub*/,
|
1/* fstore_1 */, 1/* fstore_2 */, 1/* fstore_3 */, 2/* dstore_0 */,
|
||||||
2/*fsub*/, 4/*dsub*/, 2/*imul*/, 4/*lmul*/, 2/*fmul*/, 4/*dmul*/, 2/*idiv*/, 4/*ldiv*/,
|
2/* dstore_1 */, 2/* dstore_2 */, 2/* dstore_3 */, 1/* astore_0 */,
|
||||||
2/*fdiv*/, 4/*ddiv*/, 2/*irem*/, 4/*lrem*/, 2/*frem*/, 4/*drem*/, 1/*ineg*/, 2/*lneg*/,
|
1/* astore_1 */, 1/* astore_2 */, 1/* astore_3 */, 3/* iastore */,
|
||||||
1/*fneg*/, 2/*dneg*/, 2/*ishl*/, 3/*lshl*/, 2/*ishr*/, 3/*lshr*/, 2/*iushr*/, 3/*lushr*/,
|
4/* lastore */, 3/* fastore */, 4/* dastore */, 3/* aastore */,
|
||||||
2/*iand*/, 4/*land*/, 2/*ior*/, 4/*lor*/, 2/*ixor*/, 4/*lxor*/, 0/*iinc*/,
|
3/* bastore */, 3/* castore */, 3/* sastore */, 1/* pop */,
|
||||||
1/*i2l*/, 1/*i2f*/, 1/*i2d*/, 2/*l2i*/, 2/*l2f*/, 2/*l2d*/, 1/*f2i*/, 1/*f2l*/,
|
2/* pop2 */, 1/* dup */, 2/* dup_x1 */, 3/* dup_x2 */, 2/* dup2 */,
|
||||||
1/*f2d*/, 2/*d2i*/, 2/*d2l*/, 2/*d2f*/, 1/*i2b*/, 1/*i2c*/, 1/*i2s*/,
|
3/* dup2_x1 */, 4/* dup2_x2 */, 2/* swap */, 2/* iadd */, 4/* ladd */,
|
||||||
4/*lcmp*/, 2/*fcmpl*/, 2/*fcmpg*/, 4/*dcmpl*/, 4/*dcmpg*/, 1/*ifeq*/, 1/*ifne*/,
|
2/* fadd */, 4/* dadd */, 2/* isub */, 4/* lsub */, 2/* fsub */,
|
||||||
1/*iflt*/, 1/*ifge*/, 1/*ifgt*/, 1/*ifle*/, 2/*if_icmpeq*/, 2/*if_icmpne*/, 2/*if_icmplt*/,
|
4/* dsub */, 2/* imul */, 4/* lmul */, 2/* fmul */, 4/* dmul */,
|
||||||
2 /*if_icmpge*/, 2/*if_icmpgt*/, 2/*if_icmple*/, 2/*if_acmpeq*/, 2/*if_acmpne*/,
|
2/* idiv */, 4/* ldiv */, 2/* fdiv */, 4/* ddiv */, 2/* irem */,
|
||||||
0/*goto*/, 0/*jsr*/, 0/*ret*/, 1/*tableswitch*/, 1/*lookupswitch*/, 1/*ireturn*/,
|
4/* lrem */, 2/* frem */, 4/* drem */, 1/* ineg */, 2/* lneg */,
|
||||||
2/*lreturn*/, 1/*freturn*/, 2/*dreturn*/, 1/*areturn*/, 0/*return*/, 0/*getstatic*/,
|
1/* fneg */, 2/* dneg */, 2/* ishl */, 3/* lshl */, 2/* ishr */,
|
||||||
UNPREDICTABLE/*putstatic*/, 1/*getfield*/, UNPREDICTABLE/*putfield*/,
|
3/* lshr */, 2/* iushr */, 3/* lushr */, 2/* iand */, 4/* land */,
|
||||||
|
2/* ior */, 4/* lor */, 2/* ixor */, 4/* lxor */, 0/* iinc */,
|
||||||
|
1/* i2l */, 1/* i2f */, 1/* i2d */, 2/* l2i */, 2/* l2f */,
|
||||||
|
2/* l2d */, 1/* f2i */, 1/* f2l */, 1/* f2d */, 2/* d2i */,
|
||||||
|
2/* d2l */, 2/* d2f */, 1/* i2b */, 1/* i2c */, 1/* i2s */,
|
||||||
|
4/* lcmp */, 2/* fcmpl */, 2/* fcmpg */, 4/* dcmpl */, 4/* dcmpg */,
|
||||||
|
1/* ifeq */, 1/* ifne */, 1/* iflt */, 1/* ifge */, 1/* ifgt */,
|
||||||
|
1/* ifle */, 2/* if_icmpeq */, 2/* if_icmpne */, 2/* if_icmplt */,
|
||||||
|
2 /* if_icmpge */, 2/* if_icmpgt */, 2/* if_icmple */, 2/* if_acmpeq */,
|
||||||
|
2/* if_acmpne */, 0/* goto */, 0/* jsr */, 0/* ret */,
|
||||||
|
1/* tableswitch */, 1/* lookupswitch */, 1/* ireturn */,
|
||||||
|
2/* lreturn */, 1/* freturn */, 2/* dreturn */, 1/* areturn */,
|
||||||
|
0/* return */, 0/* getstatic */, UNPREDICTABLE/* putstatic */,
|
||||||
|
1/* getfield */, UNPREDICTABLE/* putfield */,
|
||||||
UNPREDICTABLE/* invokevirtual */, UNPREDICTABLE/* invokespecial */,
|
UNPREDICTABLE/* invokevirtual */, UNPREDICTABLE/* invokespecial */,
|
||||||
UNPREDICTABLE/*invokestatic*/,
|
UNPREDICTABLE/* invokestatic */, UNPREDICTABLE/* invokeinterface */,
|
||||||
UNPREDICTABLE/*invokeinterface*/, UNDEFINED, 0/*new*/, 1/*newarray*/, 1/*anewarray*/,
|
UNDEFINED, 0/* new */, 1/* newarray */, 1/* anewarray */,
|
||||||
1/*arraylength*/, 1/*athrow*/, 1/*checkcast*/, 1/*instanceof*/, 1/*monitorenter*/,
|
1/* arraylength */, 1/* athrow */, 1/* checkcast */,
|
||||||
1/*monitorexit*/, 0/*wide*/, UNPREDICTABLE/*multianewarray*/, 1/*ifnull*/, 1/*ifnonnull*/,
|
1/* instanceof */, 1/* monitorenter */, 1/* monitorexit */,
|
||||||
0/*goto_w*/, 0/*jsr_w*/, 0/*breakpoint*/, UNDEFINED, UNDEFINED,
|
0/* wide */, UNPREDICTABLE/* multianewarray */, 1/* ifnull */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
1/* ifnonnull */, 0/* goto_w */, 0/* jsr_w */, 0/* breakpoint */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, UNDEFINED, UNDEFINED, UNPREDICTABLE/* impdep1 */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNPREDICTABLE /* impdep2 */
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
|
||||||
UNDEFINED, UNPREDICTABLE/*impdep1*/, UNPREDICTABLE/*impdep2*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of words produced onto operand stack by instructions.
|
* Number of words produced onto operand stack by instructions.
|
||||||
*/
|
*/
|
||||||
public static final int[] PRODUCE_STACK = {
|
public static final int[] PRODUCE_STACK = { 0/* nop */, 1/* aconst_null */,
|
||||||
0/*nop*/, 1/*aconst_null*/, 1/*iconst_m1*/, 1/*iconst_0*/, 1/*iconst_1*/,
|
1/* iconst_m1 */, 1/* iconst_0 */, 1/* iconst_1 */, 1/* iconst_2 */,
|
||||||
1/*iconst_2*/, 1/*iconst_3*/, 1/*iconst_4*/, 1/*iconst_5*/, 2/*lconst_0*/,
|
1/* iconst_3 */, 1/* iconst_4 */, 1/* iconst_5 */, 2/* lconst_0 */,
|
||||||
2/*lconst_1*/, 1/*fconst_0*/, 1/*fconst_1*/, 1/*fconst_2*/, 2/*dconst_0*/,
|
2/* lconst_1 */, 1/* fconst_0 */, 1/* fconst_1 */, 1/* fconst_2 */,
|
||||||
2/*dconst_1*/, 1/*bipush*/, 1/*sipush*/, 1/*ldc*/, 1/*ldc_w*/, 2/*ldc2_w*/, 1/*iload*/,
|
2/* dconst_0 */, 2/* dconst_1 */, 1/* bipush */, 1/* sipush */,
|
||||||
2/*lload*/, 1/*fload*/, 2/*dload*/, 1/*aload*/, 1/*iload_0*/, 1/*iload_1*/, 1/*iload_2*/,
|
1/* ldc */, 1/* ldc_w */, 2/* ldc2_w */, 1/* iload */, 2/* lload */,
|
||||||
1/*iload_3*/, 2/*lload_0*/, 2/*lload_1*/, 2/*lload_2*/, 2/*lload_3*/, 1/*fload_0*/,
|
1/* fload */, 2/* dload */, 1/* aload */, 1/* iload_0 */, 1/* iload_1 */,
|
||||||
1/*fload_1*/, 1/*fload_2*/, 1/*fload_3*/, 2/*dload_0*/, 2/*dload_1*/, 2/*dload_2*/,
|
1/* iload_2 */, 1/* iload_3 */, 2/* lload_0 */, 2/* lload_1 */,
|
||||||
2/*dload_3*/, 1/*aload_0*/, 1/*aload_1*/, 1/*aload_2*/, 1/*aload_3*/, 1/*iaload*/,
|
2/* lload_2 */, 2/* lload_3 */, 1/* fload_0 */, 1/* fload_1 */,
|
||||||
2/*laload*/, 1/*faload*/, 2/*daload*/, 1/*aaload*/, 1/*baload*/, 1/*caload*/, 1/*saload*/,
|
1/* fload_2 */, 1/* fload_3 */, 2/* dload_0 */, 2/* dload_1 */,
|
||||||
0/*istore*/, 0/*lstore*/, 0/*fstore*/, 0/*dstore*/, 0/*astore*/, 0/*istore_0*/,
|
2/* dload_2 */, 2/* dload_3 */, 1/* aload_0 */, 1/* aload_1 */,
|
||||||
0/*istore_1*/, 0/*istore_2*/, 0/*istore_3*/, 0/*lstore_0*/, 0/*lstore_1*/,
|
1/* aload_2 */, 1/* aload_3 */, 1/* iaload */, 2/* laload */,
|
||||||
0/*lstore_2*/, 0/*lstore_3*/, 0/*fstore_0*/, 0/*fstore_1*/, 0/*fstore_2*/,
|
1/* faload */, 2/* daload */, 1/* aaload */, 1/* baload */,
|
||||||
0/*fstore_3*/, 0/*dstore_0*/, 0/*dstore_1*/, 0/*dstore_2*/, 0/*dstore_3*/,
|
1/* caload */, 1/* saload */, 0/* istore */, 0/* lstore */,
|
||||||
0/*astore_0*/, 0/*astore_1*/, 0/*astore_2*/, 0/*astore_3*/, 0/*iastore*/, 0/*lastore*/,
|
0/* fstore */, 0/* dstore */, 0/* astore */, 0/* istore_0 */,
|
||||||
0/*fastore*/, 0/*dastore*/, 0/*aastore*/, 0/*bastore*/, 0/*castore*/, 0/*sastore*/,
|
0/* istore_1 */, 0/* istore_2 */, 0/* istore_3 */, 0/* lstore_0 */,
|
||||||
0/*pop*/, 0/*pop2*/, 2/*dup*/, 3/*dup_x1*/, 4/*dup_x2*/, 4/*dup2*/, 5/*dup2_x1*/,
|
0/* lstore_1 */, 0/* lstore_2 */, 0/* lstore_3 */, 0/* fstore_0 */,
|
||||||
6/*dup2_x2*/, 2/*swap*/, 1/*iadd*/, 2/*ladd*/, 1/*fadd*/, 2/*dadd*/, 1/*isub*/, 2/*lsub*/,
|
0/* fstore_1 */, 0/* fstore_2 */, 0/* fstore_3 */, 0/* dstore_0 */,
|
||||||
1/*fsub*/, 2/*dsub*/, 1/*imul*/, 2/*lmul*/, 1/*fmul*/, 2/*dmul*/, 1/*idiv*/, 2/*ldiv*/,
|
0/* dstore_1 */, 0/* dstore_2 */, 0/* dstore_3 */, 0/* astore_0 */,
|
||||||
1/*fdiv*/, 2/*ddiv*/, 1/*irem*/, 2/*lrem*/, 1/*frem*/, 2/*drem*/, 1/*ineg*/, 2/*lneg*/,
|
0/* astore_1 */, 0/* astore_2 */, 0/* astore_3 */, 0/* iastore */,
|
||||||
1/*fneg*/, 2/*dneg*/, 1/*ishl*/, 2/*lshl*/, 1/*ishr*/, 2/*lshr*/, 1/*iushr*/, 2/*lushr*/,
|
0/* lastore */, 0/* fastore */, 0/* dastore */, 0/* aastore */,
|
||||||
1/*iand*/, 2/*land*/, 1/*ior*/, 2/*lor*/, 1/*ixor*/, 2/*lxor*/,
|
0/* bastore */, 0/* castore */, 0/* sastore */, 0/* pop */,
|
||||||
0/*iinc*/, 2/*i2l*/, 1/*i2f*/, 2/*i2d*/, 1/*l2i*/, 1/*l2f*/, 2/*l2d*/, 1/*f2i*/,
|
0/* pop2 */, 2/* dup */, 3/* dup_x1 */, 4/* dup_x2 */, 4/* dup2 */,
|
||||||
2/*f2l*/, 2/*f2d*/, 1/*d2i*/, 2/*d2l*/, 1/*d2f*/,
|
5/* dup2_x1 */, 6/* dup2_x2 */, 2/* swap */, 1/* iadd */, 2/* ladd */,
|
||||||
1/*i2b*/, 1/*i2c*/, 1/*i2s*/, 1/*lcmp*/, 1/*fcmpl*/, 1/*fcmpg*/,
|
1/* fadd */, 2/* dadd */, 1/* isub */, 2/* lsub */, 1/* fsub */,
|
||||||
1/*dcmpl*/, 1/*dcmpg*/, 0/*ifeq*/, 0/*ifne*/, 0/*iflt*/, 0/*ifge*/, 0/*ifgt*/, 0/*ifle*/,
|
2/* dsub */, 1/* imul */, 2/* lmul */, 1/* fmul */, 2/* dmul */,
|
||||||
0/*if_icmpeq*/, 0/*if_icmpne*/, 0/*if_icmplt*/, 0/*if_icmpge*/, 0/*if_icmpgt*/,
|
1/* idiv */, 2/* ldiv */, 1/* fdiv */, 2/* ddiv */, 1/* irem */,
|
||||||
0/*if_icmple*/, 0/*if_acmpeq*/, 0/*if_acmpne*/, 0/*goto*/, 1/*jsr*/, 0/*ret*/,
|
2/* lrem */, 1/* frem */, 2/* drem */, 1/* ineg */, 2/* lneg */,
|
||||||
0/*tableswitch*/, 0/*lookupswitch*/, 0/*ireturn*/, 0/*lreturn*/, 0/*freturn*/,
|
1/* fneg */, 2/* dneg */, 1/* ishl */, 2/* lshl */, 1/* ishr */,
|
||||||
0/*dreturn*/, 0/*areturn*/, 0/*return*/, UNPREDICTABLE/*getstatic*/, 0/*putstatic*/,
|
2/* lshr */, 1/* iushr */, 2/* lushr */, 1/* iand */, 2/* land */,
|
||||||
UNPREDICTABLE/*getfield*/, 0/*putfield*/, UNPREDICTABLE/*invokevirtual*/,
|
1/* ior */, 2/* lor */, 1/* ixor */, 2/* lxor */, 0/* iinc */,
|
||||||
UNPREDICTABLE/*invokespecial*/, UNPREDICTABLE/*invokestatic*/,
|
2/* i2l */, 1/* i2f */, 2/* i2d */, 1/* l2i */, 1/* l2f */,
|
||||||
UNPREDICTABLE/*invokeinterface*/, UNDEFINED, 1/*new*/, 1/*newarray*/, 1/*anewarray*/,
|
2/* l2d */, 1/* f2i */, 2/* f2l */, 2/* f2d */, 1/* d2i */,
|
||||||
1/*arraylength*/, 1/*athrow*/, 1/*checkcast*/, 1/*instanceof*/, 0/*monitorenter*/,
|
2/* d2l */, 1/* d2f */, 1/* i2b */, 1/* i2c */, 1/* i2s */,
|
||||||
0/*monitorexit*/, 0/*wide*/, 1/*multianewarray*/, 0/*ifnull*/, 0/*ifnonnull*/,
|
1/* lcmp */, 1/* fcmpl */, 1/* fcmpg */, 1/* dcmpl */, 1/* dcmpg */,
|
||||||
0/*goto_w*/, 1/*jsr_w*/, 0/*breakpoint*/, UNDEFINED, UNDEFINED,
|
0/* ifeq */, 0/* ifne */, 0/* iflt */, 0/* ifge */, 0/* ifgt */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
0/* ifle */, 0/* if_icmpeq */, 0/* if_icmpne */, 0/* if_icmplt */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
0/* if_icmpge */, 0/* if_icmpgt */, 0/* if_icmple */, 0/* if_acmpeq */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
0/* if_acmpne */, 0/* goto */, 1/* jsr */, 0/* ret */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
0/* tableswitch */, 0/* lookupswitch */, 0/* ireturn */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
0/* lreturn */, 0/* freturn */, 0/* dreturn */, 0/* areturn */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
0/* return */, UNPREDICTABLE/* getstatic */, 0/* putstatic */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNPREDICTABLE/* getfield */, 0/* putfield */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNPREDICTABLE/* invokevirtual */, UNPREDICTABLE/* invokespecial */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNPREDICTABLE/* invokestatic */, UNPREDICTABLE/* invokeinterface */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
UNDEFINED, 1/* new */, 1/* newarray */, 1/* anewarray */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
1/* arraylength */, 1/* athrow */, 1/* checkcast */,
|
||||||
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
1/* instanceof */, 0/* monitorenter */, 0/* monitorexit */,
|
||||||
UNDEFINED, UNPREDICTABLE/*impdep1*/, UNPREDICTABLE/*impdep2*/
|
0/* wide */, 1/* multianewarray */, 0/* ifnull */,
|
||||||
|
0/* ifnonnull */, 0/* goto_w */, 1/* jsr_w */, 0/* breakpoint */,
|
||||||
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
|
UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
|
||||||
|
UNDEFINED, UNDEFINED, UNDEFINED, UNPREDICTABLE/* impdep1 */,
|
||||||
|
UNPREDICTABLE /* impdep2 */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Attributes and their corresponding names.
|
/**
|
||||||
|
* Attributes and their corresponding names.
|
||||||
*/
|
*/
|
||||||
public static final byte ATTR_UNKNOWN = -1;
|
public static final byte ATTR_UNKNOWN = -1;
|
||||||
public static final byte ATTR_SOURCE_FILE = 0;
|
public static final byte ATTR_SOURCE_FILE = 0;
|
||||||
@ -737,17 +771,16 @@ public interface Constants {
|
|||||||
|
|
||||||
public static final short KNOWN_ATTRIBUTES = 12;// should be 17
|
public static final short KNOWN_ATTRIBUTES = 12;// should be 17
|
||||||
|
|
||||||
public static final String[] ATTRIBUTE_NAMES = {
|
public static final String[] ATTRIBUTE_NAMES = { "SourceFile",
|
||||||
"SourceFile", "ConstantValue", "Code", "Exceptions",
|
"ConstantValue", "Code", "Exceptions", "LineNumberTable",
|
||||||
"LineNumberTable", "LocalVariableTable",
|
"LocalVariableTable", "InnerClasses", "Synthetic", "Deprecated",
|
||||||
"InnerClasses", "Synthetic", "Deprecated",
|
"PMGClass", "Signature", "StackMap", "RuntimeVisibleAnnotations",
|
||||||
"PMGClass", "Signature", "StackMap",
|
"RuntimeInvisibleAnnotations",
|
||||||
"RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations",
|
"RuntimeVisibleParameterAnnotations",
|
||||||
"RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations",
|
"RuntimeInvisibleParameterAnnotations", "AnnotationDefault" };
|
||||||
"AnnotationDefault"
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Constants used in the StackMap attribute.
|
/**
|
||||||
|
* Constants used in the StackMap attribute.
|
||||||
*/
|
*/
|
||||||
public static final byte ITEM_Bogus = 0;
|
public static final byte ITEM_Bogus = 0;
|
||||||
public static final byte ITEM_Integer = 1;
|
public static final byte ITEM_Integer = 1;
|
||||||
@ -759,8 +792,6 @@ public interface Constants {
|
|||||||
public static final byte ITEM_Object = 7;
|
public static final byte ITEM_Object = 7;
|
||||||
public static final byte ITEM_NewObject = 8;
|
public static final byte ITEM_NewObject = 8;
|
||||||
|
|
||||||
public static final String[] ITEM_NAMES = {
|
public static final String[] ITEM_NAMES = { "Bogus", "Integer", "Float",
|
||||||
"Bogus", "Integer", "Float", "Double", "Long",
|
"Double", "Long", "Null", "InitObject", "Object", "NewObject" };
|
||||||
"Null", "InitObject", "Object", "NewObject"
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@ -24,16 +24,20 @@ package org.apache.bcel;
|
|||||||
*/
|
*/
|
||||||
public interface ExceptionConstants {
|
public interface ExceptionConstants {
|
||||||
|
|
||||||
/** The mother of all exceptions
|
/**
|
||||||
|
* The mother of all exceptions
|
||||||
*/
|
*/
|
||||||
public static final Class<Throwable> THROWABLE = Throwable.class;
|
public static final Class<Throwable> THROWABLE = Throwable.class;
|
||||||
/** Super class of any run-time exception
|
/**
|
||||||
|
* Super class of any run-time exception
|
||||||
*/
|
*/
|
||||||
public static final Class<RuntimeException> RUNTIME_EXCEPTION = RuntimeException.class;
|
public static final Class<RuntimeException> RUNTIME_EXCEPTION = RuntimeException.class;
|
||||||
/** Super class of any linking exception (aka Linkage Error)
|
/**
|
||||||
|
* Super class of any linking exception (aka Linkage Error)
|
||||||
*/
|
*/
|
||||||
public static final Class<LinkageError> LINKING_EXCEPTION = LinkageError.class;
|
public static final Class<LinkageError> LINKING_EXCEPTION = LinkageError.class;
|
||||||
/** Linking Exceptions
|
/**
|
||||||
|
* Linking Exceptions
|
||||||
*/
|
*/
|
||||||
public static final Class<ClassCircularityError> CLASS_CIRCULARITY_ERROR = ClassCircularityError.class;
|
public static final Class<ClassCircularityError> CLASS_CIRCULARITY_ERROR = ClassCircularityError.class;
|
||||||
public static final Class<ClassFormatError> CLASS_FORMAT_ERROR = ClassFormatError.class;
|
public static final Class<ClassFormatError> CLASS_FORMAT_ERROR = ClassFormatError.class;
|
||||||
@ -48,8 +52,10 @@ public interface ExceptionConstants {
|
|||||||
public static final Class<UnsatisfiedLinkError> UNSATISFIED_LINK_ERROR = UnsatisfiedLinkError.class;
|
public static final Class<UnsatisfiedLinkError> UNSATISFIED_LINK_ERROR = UnsatisfiedLinkError.class;
|
||||||
public static final Class<VerifyError> VERIFY_ERROR = VerifyError.class;
|
public static final Class<VerifyError> VERIFY_ERROR = VerifyError.class;
|
||||||
/* UnsupportedClassVersionError is new in JDK 1.2 */
|
/* UnsupportedClassVersionError is new in JDK 1.2 */
|
||||||
//public static final Class UnsupportedClassVersionError = UnsupportedClassVersionError.class;
|
// public static final Class UnsupportedClassVersionError =
|
||||||
/** Run-Time Exceptions
|
// UnsupportedClassVersionError.class;
|
||||||
|
/**
|
||||||
|
* Run-Time Exceptions
|
||||||
*/
|
*/
|
||||||
public static final Class<NullPointerException> NULL_POINTER_EXCEPTION = NullPointerException.class;
|
public static final Class<NullPointerException> NULL_POINTER_EXCEPTION = NullPointerException.class;
|
||||||
public static final Class<ArrayIndexOutOfBoundsException> ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION = ArrayIndexOutOfBoundsException.class;
|
public static final Class<ArrayIndexOutOfBoundsException> ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION = ArrayIndexOutOfBoundsException.class;
|
||||||
@ -57,20 +63,24 @@ public interface ExceptionConstants {
|
|||||||
public static final Class<NegativeArraySizeException> NEGATIVE_ARRAY_SIZE_EXCEPTION = NegativeArraySizeException.class;
|
public static final Class<NegativeArraySizeException> NEGATIVE_ARRAY_SIZE_EXCEPTION = NegativeArraySizeException.class;
|
||||||
public static final Class<ClassCastException> CLASS_CAST_EXCEPTION = ClassCastException.class;
|
public static final Class<ClassCastException> CLASS_CAST_EXCEPTION = ClassCastException.class;
|
||||||
public static final Class<IllegalMonitorStateException> ILLEGAL_MONITOR_STATE = IllegalMonitorStateException.class;
|
public static final Class<IllegalMonitorStateException> ILLEGAL_MONITOR_STATE = IllegalMonitorStateException.class;
|
||||||
/** Pre-defined exception arrays according to chapters 5.1-5.4 of the Java Virtual
|
/**
|
||||||
* Machine Specification
|
* Pre-defined exception arrays according to chapters 5.1-5.4 of the Java
|
||||||
|
* Virtual Machine Specification
|
||||||
*/
|
*/
|
||||||
public static final Class<?>[] EXCS_CLASS_AND_INTERFACE_RESOLUTION = {
|
public static final Class<?>[] EXCS_CLASS_AND_INTERFACE_RESOLUTION = {
|
||||||
NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR, ABSTRACT_METHOD_ERROR,
|
NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR,
|
||||||
EXCEPTION_IN_INITIALIZER_ERROR, ILLEGAL_ACCESS_ERROR
|
ABSTRACT_METHOD_ERROR, EXCEPTION_IN_INITIALIZER_ERROR,
|
||||||
}; // Chapter 5.1
|
ILLEGAL_ACCESS_ERROR }; // Chapter 5.1
|
||||||
public static final Class<?>[] EXCS_FIELD_AND_METHOD_RESOLUTION = {
|
public static final Class<?>[] EXCS_FIELD_AND_METHOD_RESOLUTION = {
|
||||||
NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR
|
NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR }; // Chapter
|
||||||
}; // Chapter 5.2
|
// 5.2
|
||||||
public static final Class<?>[] EXCS_INTERFACE_METHOD_RESOLUTION = new Class[0]; // Chapter 5.3 (as below)
|
public static final Class<?>[] EXCS_INTERFACE_METHOD_RESOLUTION = new Class[0]; // Chapter
|
||||||
|
// 5.3
|
||||||
|
// (as
|
||||||
|
// below)
|
||||||
public static final Class<?>[] EXCS_STRING_RESOLUTION = new Class[0];
|
public static final Class<?>[] EXCS_STRING_RESOLUTION = new Class[0];
|
||||||
// Chapter 5.4 (no errors but the ones that _always_ could happen! How stupid.)
|
// Chapter 5.4 (no errors but the ones that _always_ could happen! How
|
||||||
|
// stupid.)
|
||||||
public static final Class<?>[] EXCS_ARRAY_EXCEPTION = {
|
public static final Class<?>[] EXCS_ARRAY_EXCEPTION = {
|
||||||
NULL_POINTER_EXCEPTION, ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION
|
NULL_POINTER_EXCEPTION, ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION };
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ import org.apache.bcel.util.SyntheticRepository;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The repository maintains informations about class interdependencies, e.g.,
|
* The repository maintains informations about class interdependencies, e.g.,
|
||||||
* whether a class is a sub-class of another. Delegates actual class loading
|
* whether a class is a sub-class of another. Delegates actual class loading to
|
||||||
* to SyntheticRepository with current class path by default.
|
* SyntheticRepository with current class path by default.
|
||||||
*
|
*
|
||||||
* @see org.apache.bcel.util.Repository
|
* @see org.apache.bcel.util.Repository
|
||||||
* @see org.apache.bcel.util.SyntheticRepository
|
* @see org.apache.bcel.util.SyntheticRepository
|
||||||
@ -34,51 +34,52 @@ import org.apache.bcel.util.SyntheticRepository;
|
|||||||
*/
|
*/
|
||||||
public abstract class Repository {
|
public abstract class Repository {
|
||||||
|
|
||||||
private static org.apache.bcel.util.Repository _repository = SyntheticRepository.getInstance();
|
private static org.apache.bcel.util.Repository _repository = SyntheticRepository
|
||||||
|
.getInstance();
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return currently used repository instance
|
* @return currently used repository instance
|
||||||
*/
|
*/
|
||||||
public static org.apache.bcel.util.Repository getRepository() {
|
public static org.apache.bcel.util.Repository getRepository() {
|
||||||
return _repository;
|
return _repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Set repository instance to be used for class loading
|
* Set repository instance to be used for class loading
|
||||||
*/
|
*/
|
||||||
public static void setRepository(org.apache.bcel.util.Repository rep) {
|
public static void setRepository(org.apache.bcel.util.Repository rep) {
|
||||||
_repository = rep;
|
_repository = rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Lookup class somewhere found on your CLASSPATH, or whereever the
|
* Lookup class somewhere found on your CLASSPATH, or whereever the
|
||||||
* repository instance looks for it.
|
* repository instance looks for it.
|
||||||
*
|
*
|
||||||
* @return class object for given fully qualified class name
|
* @return class object for given fully qualified class name
|
||||||
* @throws ClassNotFoundException if the class could not be found or
|
* @throws ClassNotFoundException
|
||||||
* parsed correctly
|
* if the class could not be found or parsed correctly
|
||||||
*/
|
*/
|
||||||
public static JavaClass lookupClass( String class_name ) throws ClassNotFoundException {
|
public static JavaClass lookupClass(String class_name)
|
||||||
|
throws ClassNotFoundException {
|
||||||
return _repository.loadClass(class_name);
|
return _repository.loadClass(class_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to find class source using the internal repository instance.
|
* Try to find class source using the internal repository instance.
|
||||||
|
*
|
||||||
* @see Class
|
* @see Class
|
||||||
* @return JavaClass object for given runtime class
|
* @return JavaClass object for given runtime class
|
||||||
* @throws ClassNotFoundException if the class could not be found or
|
* @throws ClassNotFoundException
|
||||||
* parsed correctly
|
* if the class could not be found or parsed correctly
|
||||||
*/
|
*/
|
||||||
public static JavaClass lookupClass( Class<?> clazz ) throws ClassNotFoundException {
|
public static JavaClass lookupClass(Class<?> clazz)
|
||||||
|
throws ClassNotFoundException {
|
||||||
return _repository.loadClass(clazz);
|
return _repository.loadClass(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return class file object for given Java class by looking on the
|
* @return class file object for given Java class by looking on the system
|
||||||
* system class path; returns null if the class file can't be
|
* class path; returns null if the class file can't be found
|
||||||
* found
|
|
||||||
*/
|
*/
|
||||||
public static ClassPath.ClassFile lookupClassFile(String class_name) {
|
public static ClassPath.ClassFile lookupClassFile(String class_name) {
|
||||||
try {
|
try {
|
||||||
@ -92,16 +93,16 @@ public abstract class Repository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Clear the repository.
|
* Clear the repository.
|
||||||
*/
|
*/
|
||||||
public static void clearCache() {
|
public static void clearCache() {
|
||||||
_repository.clear();
|
_repository.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add clazz to repository if there isn't an equally named class already in there.
|
* Add clazz to repository if there isn't an equally named class already in
|
||||||
|
* there.
|
||||||
*
|
*
|
||||||
* @return old entry in repository
|
* @return old entry in repository
|
||||||
*/
|
*/
|
||||||
@ -111,7 +112,6 @@ public abstract class Repository {
|
|||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove class with given (fully qualified) name from repository.
|
* Remove class with given (fully qualified) name from repository.
|
||||||
*/
|
*/
|
||||||
@ -119,7 +119,6 @@ public abstract class Repository {
|
|||||||
_repository.removeClass(_repository.findClass(clazz));
|
_repository.removeClass(_repository.findClass(clazz));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove given class from repository.
|
* Remove given class from repository.
|
||||||
*/
|
*/
|
||||||
@ -127,132 +126,135 @@ public abstract class Repository {
|
|||||||
_repository.removeClass(clazz);
|
_repository.removeClass(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return list of super classes of clazz in ascending order, i.e.,
|
* @return list of super classes of clazz in ascending order, i.e., Object
|
||||||
* Object is always the last element
|
* is always the last element
|
||||||
* @throws ClassNotFoundException if any of the superclasses can't be found
|
* @throws ClassNotFoundException
|
||||||
|
* if any of the superclasses can't be found
|
||||||
*/
|
*/
|
||||||
public static JavaClass[] getSuperClasses( JavaClass clazz ) throws ClassNotFoundException {
|
public static JavaClass[] getSuperClasses(JavaClass clazz)
|
||||||
|
throws ClassNotFoundException {
|
||||||
return clazz.getSuperClasses();
|
return clazz.getSuperClasses();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return list of super classes of clazz in ascending order, i.e.,
|
* @return list of super classes of clazz in ascending order, i.e., Object
|
||||||
* Object is always the last element.
|
* is always the last element.
|
||||||
* @throws ClassNotFoundException if the named class or any of its
|
* @throws ClassNotFoundException
|
||||||
* superclasses can't be found
|
* if the named class or any of its superclasses can't be found
|
||||||
*/
|
*/
|
||||||
public static JavaClass[] getSuperClasses( String class_name ) throws ClassNotFoundException {
|
public static JavaClass[] getSuperClasses(String class_name)
|
||||||
|
throws ClassNotFoundException {
|
||||||
JavaClass jc = lookupClass(class_name);
|
JavaClass jc = lookupClass(class_name);
|
||||||
return getSuperClasses(jc);
|
return getSuperClasses(jc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return all interfaces implemented by class and its super
|
* @return all interfaces implemented by class and its super classes and the
|
||||||
* classes and the interfaces that those interfaces extend, and so on.
|
* interfaces that those interfaces extend, and so on. (Some people
|
||||||
* (Some people call this a transitive hull).
|
* call this a transitive hull).
|
||||||
* @throws ClassNotFoundException if any of the class's
|
* @throws ClassNotFoundException
|
||||||
* superclasses or superinterfaces can't be found
|
* if any of the class's superclasses or superinterfaces can't
|
||||||
|
* be found
|
||||||
*/
|
*/
|
||||||
public static JavaClass[] getInterfaces( JavaClass clazz ) throws ClassNotFoundException {
|
public static JavaClass[] getInterfaces(JavaClass clazz)
|
||||||
|
throws ClassNotFoundException {
|
||||||
return clazz.getAllInterfaces();
|
return clazz.getAllInterfaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return all interfaces implemented by class and its super
|
* @return all interfaces implemented by class and its super classes and the
|
||||||
* classes and the interfaces that extend those interfaces, and so on
|
* interfaces that extend those interfaces, and so on
|
||||||
* @throws ClassNotFoundException if the named class can't be found,
|
* @throws ClassNotFoundException
|
||||||
* or if any of its superclasses or superinterfaces can't be found
|
* if the named class can't be found, or if any of its
|
||||||
|
* superclasses or superinterfaces can't be found
|
||||||
*/
|
*/
|
||||||
public static JavaClass[] getInterfaces( String class_name ) throws ClassNotFoundException {
|
public static JavaClass[] getInterfaces(String class_name)
|
||||||
|
throws ClassNotFoundException {
|
||||||
return getInterfaces(lookupClass(class_name));
|
return getInterfaces(lookupClass(class_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Equivalent to runtime "instanceof" operator.
|
* Equivalent to runtime "instanceof" operator.
|
||||||
|
*
|
||||||
* @return true, if clazz is an instance of super_class
|
* @return true, if clazz is an instance of super_class
|
||||||
* @throws ClassNotFoundException if any superclasses or superinterfaces
|
* @throws ClassNotFoundException
|
||||||
* of clazz can't be found
|
* if any superclasses or superinterfaces of clazz can't be
|
||||||
|
* found
|
||||||
*/
|
*/
|
||||||
public static boolean instanceOf(JavaClass clazz, JavaClass super_class)
|
public static boolean instanceOf(JavaClass clazz, JavaClass super_class)
|
||||||
throws ClassNotFoundException {
|
throws ClassNotFoundException {
|
||||||
return clazz.instanceOf(super_class);
|
return clazz.instanceOf(super_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true, if clazz is an instance of super_class
|
* @return true, if clazz is an instance of super_class
|
||||||
* @throws ClassNotFoundException if either clazz or super_class
|
* @throws ClassNotFoundException
|
||||||
* can't be found
|
* if either clazz or super_class can't be found
|
||||||
*/
|
*/
|
||||||
public static boolean instanceOf(String clazz, String super_class)
|
public static boolean instanceOf(String clazz, String super_class)
|
||||||
throws ClassNotFoundException {
|
throws ClassNotFoundException {
|
||||||
return instanceOf(lookupClass(clazz), lookupClass(super_class));
|
return instanceOf(lookupClass(clazz), lookupClass(super_class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true, if clazz is an instance of super_class
|
* @return true, if clazz is an instance of super_class
|
||||||
* @throws ClassNotFoundException if super_class can't be found
|
* @throws ClassNotFoundException
|
||||||
|
* if super_class can't be found
|
||||||
*/
|
*/
|
||||||
public static boolean instanceOf(JavaClass clazz, String super_class)
|
public static boolean instanceOf(JavaClass clazz, String super_class)
|
||||||
throws ClassNotFoundException {
|
throws ClassNotFoundException {
|
||||||
return instanceOf(clazz, lookupClass(super_class));
|
return instanceOf(clazz, lookupClass(super_class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true, if clazz is an instance of super_class
|
* @return true, if clazz is an instance of super_class
|
||||||
* @throws ClassNotFoundException if clazz can't be found
|
* @throws ClassNotFoundException
|
||||||
|
* if clazz can't be found
|
||||||
*/
|
*/
|
||||||
public static boolean instanceOf(String clazz, JavaClass super_class)
|
public static boolean instanceOf(String clazz, JavaClass super_class)
|
||||||
throws ClassNotFoundException {
|
throws ClassNotFoundException {
|
||||||
return instanceOf(lookupClass(clazz), super_class);
|
return instanceOf(lookupClass(clazz), super_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true, if clazz is an implementation of interface inter
|
* @return true, if clazz is an implementation of interface inter
|
||||||
* @throws ClassNotFoundException if any superclasses or superinterfaces
|
* @throws ClassNotFoundException
|
||||||
* of clazz can't be found
|
* if any superclasses or superinterfaces of clazz can't be
|
||||||
|
* found
|
||||||
*/
|
*/
|
||||||
public static boolean implementationOf(JavaClass clazz, JavaClass inter)
|
public static boolean implementationOf(JavaClass clazz, JavaClass inter)
|
||||||
throws ClassNotFoundException {
|
throws ClassNotFoundException {
|
||||||
return clazz.implementationOf(inter);
|
return clazz.implementationOf(inter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true, if clazz is an implementation of interface inter
|
* @return true, if clazz is an implementation of interface inter
|
||||||
* @throws ClassNotFoundException if clazz, inter, or any superclasses
|
* @throws ClassNotFoundException
|
||||||
* or superinterfaces of clazz can't be found
|
* if clazz, inter, or any superclasses or superinterfaces of
|
||||||
|
* clazz can't be found
|
||||||
*/
|
*/
|
||||||
public static boolean implementationOf(String clazz, String inter)
|
public static boolean implementationOf(String clazz, String inter)
|
||||||
throws ClassNotFoundException {
|
throws ClassNotFoundException {
|
||||||
return implementationOf(lookupClass(clazz), lookupClass(inter));
|
return implementationOf(lookupClass(clazz), lookupClass(inter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true, if clazz is an implementation of interface inter
|
* @return true, if clazz is an implementation of interface inter
|
||||||
* @throws ClassNotFoundException if inter or any superclasses
|
* @throws ClassNotFoundException
|
||||||
* or superinterfaces of clazz can't be found
|
* if inter or any superclasses or superinterfaces of clazz
|
||||||
|
* can't be found
|
||||||
*/
|
*/
|
||||||
public static boolean implementationOf(JavaClass clazz, String inter)
|
public static boolean implementationOf(JavaClass clazz, String inter)
|
||||||
throws ClassNotFoundException {
|
throws ClassNotFoundException {
|
||||||
return implementationOf(clazz, lookupClass(inter));
|
return implementationOf(clazz, lookupClass(inter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true, if clazz is an implementation of interface inter
|
* @return true, if clazz is an implementation of interface inter
|
||||||
* @throws ClassNotFoundException if clazz or any superclasses or
|
* @throws ClassNotFoundException
|
||||||
* superinterfaces of clazz can't be found
|
* if clazz or any superclasses or superinterfaces of clazz
|
||||||
|
* can't be found
|
||||||
*/
|
*/
|
||||||
public static boolean implementationOf(String clazz, JavaClass inter)
|
public static boolean implementationOf(String clazz, JavaClass inter)
|
||||||
throws ClassNotFoundException {
|
throws ClassNotFoundException {
|
||||||
|
@ -19,29 +19,31 @@ package org.apache.bcel.classfile;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Super class for all objects that have modifiers like private, final, ...
|
* Super class for all objects that have modifiers like private, final, ... I.e.
|
||||||
* I.e. classes, fields, and methods.
|
* classes, fields, and methods.
|
||||||
*
|
*
|
||||||
* @version $Id: AccessFlags.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: AccessFlags.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public abstract class AccessFlags implements java.io.Serializable {
|
public abstract class AccessFlags implements java.io.Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
protected int access_flags;
|
protected int access_flags;
|
||||||
|
|
||||||
|
|
||||||
public AccessFlags() {
|
public AccessFlags() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param a inital access flags
|
* @param a
|
||||||
|
* inital access flags
|
||||||
*/
|
*/
|
||||||
public AccessFlags(int a) {
|
public AccessFlags(int a) {
|
||||||
access_flags = a;
|
access_flags = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Access flags of the object aka. "modifiers".
|
* @return Access flags of the object aka. "modifiers".
|
||||||
*/
|
*/
|
||||||
@ -49,7 +51,6 @@ public abstract class AccessFlags implements java.io.Serializable {
|
|||||||
return access_flags;
|
return access_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Access flags of the object aka. "modifiers".
|
* @return Access flags of the object aka. "modifiers".
|
||||||
*/
|
*/
|
||||||
@ -57,23 +58,26 @@ public abstract class AccessFlags implements java.io.Serializable {
|
|||||||
return access_flags;
|
return access_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Set access flags aka "modifiers".
|
* Set access flags aka "modifiers".
|
||||||
* @param access_flags Access flags of the object.
|
*
|
||||||
|
* @param access_flags
|
||||||
|
* Access flags of the object.
|
||||||
*/
|
*/
|
||||||
public final void setAccessFlags(int access_flags) {
|
public final void setAccessFlags(int access_flags) {
|
||||||
this.access_flags = access_flags;
|
this.access_flags = access_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Set access flags aka "modifiers".
|
* Set access flags aka "modifiers".
|
||||||
* @param access_flags Access flags of the object.
|
*
|
||||||
|
* @param access_flags
|
||||||
|
* Access flags of the object.
|
||||||
*/
|
*/
|
||||||
public final void setModifiers(int access_flags) {
|
public final void setModifiers(int access_flags) {
|
||||||
setAccessFlags(access_flags);
|
setAccessFlags(access_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final void setFlag(int flag, boolean set) {
|
private final void setFlag(int flag, boolean set) {
|
||||||
if ((access_flags & flag) != 0) { // Flag is set already
|
if ((access_flags & flag) != 0) { // Flag is set already
|
||||||
if (!set) {
|
if (!set) {
|
||||||
@ -86,152 +90,122 @@ public abstract class AccessFlags implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isPublic(boolean flag) {
|
public final void isPublic(boolean flag) {
|
||||||
setFlag(Constants.ACC_PUBLIC, flag);
|
setFlag(Constants.ACC_PUBLIC, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isPublic() {
|
public final boolean isPublic() {
|
||||||
return (access_flags & Constants.ACC_PUBLIC) != 0;
|
return (access_flags & Constants.ACC_PUBLIC) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isPrivate(boolean flag) {
|
public final void isPrivate(boolean flag) {
|
||||||
setFlag(Constants.ACC_PRIVATE, flag);
|
setFlag(Constants.ACC_PRIVATE, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isPrivate() {
|
public final boolean isPrivate() {
|
||||||
return (access_flags & Constants.ACC_PRIVATE) != 0;
|
return (access_flags & Constants.ACC_PRIVATE) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isProtected(boolean flag) {
|
public final void isProtected(boolean flag) {
|
||||||
setFlag(Constants.ACC_PROTECTED, flag);
|
setFlag(Constants.ACC_PROTECTED, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isProtected() {
|
public final boolean isProtected() {
|
||||||
return (access_flags & Constants.ACC_PROTECTED) != 0;
|
return (access_flags & Constants.ACC_PROTECTED) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isStatic(boolean flag) {
|
public final void isStatic(boolean flag) {
|
||||||
setFlag(Constants.ACC_STATIC, flag);
|
setFlag(Constants.ACC_STATIC, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isStatic() {
|
public final boolean isStatic() {
|
||||||
return (access_flags & Constants.ACC_STATIC) != 0;
|
return (access_flags & Constants.ACC_STATIC) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isFinal(boolean flag) {
|
public final void isFinal(boolean flag) {
|
||||||
setFlag(Constants.ACC_FINAL, flag);
|
setFlag(Constants.ACC_FINAL, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isFinal() {
|
public final boolean isFinal() {
|
||||||
return (access_flags & Constants.ACC_FINAL) != 0;
|
return (access_flags & Constants.ACC_FINAL) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isSynchronized(boolean flag) {
|
public final void isSynchronized(boolean flag) {
|
||||||
setFlag(Constants.ACC_SYNCHRONIZED, flag);
|
setFlag(Constants.ACC_SYNCHRONIZED, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isSynchronized() {
|
public final boolean isSynchronized() {
|
||||||
return (access_flags & Constants.ACC_SYNCHRONIZED) != 0;
|
return (access_flags & Constants.ACC_SYNCHRONIZED) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isVolatile(boolean flag) {
|
public final void isVolatile(boolean flag) {
|
||||||
setFlag(Constants.ACC_VOLATILE, flag);
|
setFlag(Constants.ACC_VOLATILE, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isVolatile() {
|
public final boolean isVolatile() {
|
||||||
return (access_flags & Constants.ACC_VOLATILE) != 0;
|
return (access_flags & Constants.ACC_VOLATILE) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isTransient(boolean flag) {
|
public final void isTransient(boolean flag) {
|
||||||
setFlag(Constants.ACC_TRANSIENT, flag);
|
setFlag(Constants.ACC_TRANSIENT, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isTransient() {
|
public final boolean isTransient() {
|
||||||
return (access_flags & Constants.ACC_TRANSIENT) != 0;
|
return (access_flags & Constants.ACC_TRANSIENT) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isNative(boolean flag) {
|
public final void isNative(boolean flag) {
|
||||||
setFlag(Constants.ACC_NATIVE, flag);
|
setFlag(Constants.ACC_NATIVE, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isNative() {
|
public final boolean isNative() {
|
||||||
return (access_flags & Constants.ACC_NATIVE) != 0;
|
return (access_flags & Constants.ACC_NATIVE) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isInterface(boolean flag) {
|
public final void isInterface(boolean flag) {
|
||||||
setFlag(Constants.ACC_INTERFACE, flag);
|
setFlag(Constants.ACC_INTERFACE, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isInterface() {
|
public final boolean isInterface() {
|
||||||
return (access_flags & Constants.ACC_INTERFACE) != 0;
|
return (access_flags & Constants.ACC_INTERFACE) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isAbstract(boolean flag) {
|
public final void isAbstract(boolean flag) {
|
||||||
setFlag(Constants.ACC_ABSTRACT, flag);
|
setFlag(Constants.ACC_ABSTRACT, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isAbstract() {
|
public final boolean isAbstract() {
|
||||||
return (access_flags & Constants.ACC_ABSTRACT) != 0;
|
return (access_flags & Constants.ACC_ABSTRACT) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isStrictfp(boolean flag) {
|
public final void isStrictfp(boolean flag) {
|
||||||
setFlag(Constants.ACC_STRICT, flag);
|
setFlag(Constants.ACC_STRICT, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isStrictfp() {
|
public final boolean isStrictfp() {
|
||||||
return (access_flags & Constants.ACC_STRICT) != 0;
|
return (access_flags & Constants.ACC_STRICT) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isSynthetic(boolean flag) {
|
public final void isSynthetic(boolean flag) {
|
||||||
setFlag(Constants.ACC_SYNTHETIC, flag);
|
setFlag(Constants.ACC_SYNTHETIC, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isSynthetic() {
|
public final boolean isSynthetic() {
|
||||||
return (access_flags & Constants.ACC_SYNTHETIC) != 0;
|
return (access_flags & Constants.ACC_SYNTHETIC) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isAnnotation(boolean flag) {
|
public final void isAnnotation(boolean flag) {
|
||||||
setFlag(Constants.ACC_ANNOTATION, flag);
|
setFlag(Constants.ACC_ANNOTATION, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isAnnotation() {
|
public final boolean isAnnotation() {
|
||||||
return (access_flags & Constants.ACC_ANNOTATION) != 0;
|
return (access_flags & Constants.ACC_ANNOTATION) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void isEnum(boolean flag) {
|
public final void isEnum(boolean flag) {
|
||||||
setFlag(Constants.ACC_ENUM, flag);
|
setFlag(Constants.ACC_ENUM, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isEnum() {
|
public final boolean isEnum() {
|
||||||
return (access_flags & Constants.ACC_ENUM) != 0;
|
return (access_flags & Constants.ACC_ENUM) != 0;
|
||||||
}
|
}
|
||||||
|
@ -22,15 +22,16 @@ import java.io.IOException;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract super class for <em>Attribute</em> objects. Currently the
|
* Abstract super class for <em>Attribute</em> objects. Currently the
|
||||||
* <em>ConstantValue</em>, <em>SourceFile</em>, <em>Code</em>,
|
* <em>ConstantValue</em>, <em>SourceFile</em>, <em>Code</em>,
|
||||||
* <em>Exceptiontable</em>, <em>LineNumberTable</em>,
|
* <em>Exceptiontable</em>, <em>LineNumberTable</em>,
|
||||||
* <em>LocalVariableTable</em>, <em>InnerClasses</em> and
|
* <em>LocalVariableTable</em>, <em>InnerClasses</em> and <em>Synthetic</em>
|
||||||
* <em>Synthetic</em> attributes are supported. The
|
* attributes are supported. The <em>Unknown</em> attribute stands for
|
||||||
* <em>Unknown</em> attribute stands for non-standard-attributes.
|
* non-standard-attributes.
|
||||||
*
|
*
|
||||||
* @version $Id: Attribute.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: Attribute.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -48,34 +49,39 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public abstract class Attribute implements Cloneable, Node, Serializable {
|
public abstract class Attribute implements Cloneable, Node, Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
protected int name_index; // Points to attribute name in constant pool
|
protected int name_index; // Points to attribute name in constant pool
|
||||||
protected int length; // Content length of attribute field
|
protected int length; // Content length of attribute field
|
||||||
protected byte tag; // Tag to distiguish subclasses
|
protected byte tag; // Tag to distiguish subclasses
|
||||||
protected ConstantPool constant_pool;
|
protected ConstantPool constant_pool;
|
||||||
|
|
||||||
|
protected Attribute(byte tag, int name_index, int length,
|
||||||
protected Attribute(byte tag, int name_index, int length, ConstantPool constant_pool) {
|
ConstantPool constant_pool) {
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.name_index = name_index;
|
this.name_index = name_index;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.constant_pool = constant_pool;
|
this.constant_pool = constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public abstract void accept(Visitor v);
|
public abstract void accept(Visitor v);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump attribute to file stream in binary format.
|
* Dump attribute to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void dump(DataOutputStream file) throws IOException {
|
public void dump(DataOutputStream file) throws IOException {
|
||||||
@ -83,44 +89,54 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
|
|||||||
file.writeInt(length);
|
file.writeInt(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map readers = new HashMap();
|
private static Map<String, AttributeReader> readers = new HashMap<String, AttributeReader>();
|
||||||
|
|
||||||
|
/**
|
||||||
/** Add an Attribute reader capable of parsing (user-defined) attributes
|
* Add an Attribute reader capable of parsing (user-defined) attributes
|
||||||
* named "name". You should not add readers for the standard attributes
|
* named "name". You should not add readers for the standard attributes such
|
||||||
* such as "LineNumberTable", because those are handled internally.
|
* as "LineNumberTable", because those are handled internally.
|
||||||
*
|
*
|
||||||
* @param name the name of the attribute as stored in the class file
|
* @param name
|
||||||
* @param r the reader object
|
* the name of the attribute as stored in the class file
|
||||||
|
* @param r
|
||||||
|
* the reader object
|
||||||
*/
|
*/
|
||||||
public static void addAttributeReader(String name, AttributeReader r) {
|
public static void addAttributeReader(String name, AttributeReader r) {
|
||||||
readers.put(name, r);
|
readers.put(name, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Remove attribute reader
|
* Remove attribute reader
|
||||||
*
|
*
|
||||||
* @param name the name of the attribute as stored in the class file
|
* @param name
|
||||||
|
* the name of the attribute as stored in the class file
|
||||||
*/
|
*/
|
||||||
public static void removeAttributeReader(String name) {
|
public static void removeAttributeReader(String name) {
|
||||||
readers.remove(name);
|
readers.remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
/* Class method reads one attribute from the input data stream.
|
* Class method reads one attribute from the input data stream. This method
|
||||||
* This method must not be accessible from the outside. It is
|
* must not be accessible from the outside. It is called by the Field and
|
||||||
* called by the Field and Method constructor methods.
|
* Method constructor methods.
|
||||||
*
|
*
|
||||||
* @see Field
|
* @see Field
|
||||||
|
*
|
||||||
* @see Method
|
* @see Method
|
||||||
|
*
|
||||||
* @param file Input stream
|
* @param file Input stream
|
||||||
|
*
|
||||||
* @param constant_pool Array of constants
|
* @param constant_pool Array of constants
|
||||||
|
*
|
||||||
* @return Attribute
|
* @return Attribute
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
*
|
||||||
* @throws ClassFormatException
|
* @throws ClassFormatException
|
||||||
*/
|
*/
|
||||||
public static final Attribute readAttribute( DataInputStream file, ConstantPool constant_pool )
|
public static final Attribute readAttribute(DataInputStream file,
|
||||||
throws IOException, ClassFormatException {
|
ConstantPool constant_pool) throws IOException,
|
||||||
|
ClassFormatException {
|
||||||
ConstantUtf8 c;
|
ConstantUtf8 c;
|
||||||
String name;
|
String name;
|
||||||
int name_index;
|
int name_index;
|
||||||
@ -128,7 +144,8 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
|
|||||||
byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute
|
byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute
|
||||||
// Get class name from constant pool via `name_index' indirection
|
// Get class name from constant pool via `name_index' indirection
|
||||||
name_index = file.readUnsignedShort();
|
name_index = file.readUnsignedShort();
|
||||||
c = (ConstantUtf8) constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8);
|
c = (ConstantUtf8) constant_pool.getConstant(name_index,
|
||||||
|
Constants.CONSTANT_Utf8);
|
||||||
name = c.getBytes();
|
name = c.getBytes();
|
||||||
// Length of data in bytes
|
// Length of data in bytes
|
||||||
length = file.readInt();
|
length = file.readInt();
|
||||||
@ -142,9 +159,10 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
|
|||||||
// Call proper constructor, depending on `tag'
|
// Call proper constructor, depending on `tag'
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case Constants.ATTR_UNKNOWN:
|
case Constants.ATTR_UNKNOWN:
|
||||||
AttributeReader r = (AttributeReader) readers.get(name);
|
AttributeReader r = readers.get(name);
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
return r.createAttribute(name_index, length, file, constant_pool);
|
return r.createAttribute(name_index, length, file,
|
||||||
|
constant_pool);
|
||||||
}
|
}
|
||||||
return new Unknown(name_index, length, file, constant_pool);
|
return new Unknown(name_index, length, file, constant_pool);
|
||||||
case Constants.ATTR_CONSTANT_VALUE:
|
case Constants.ATTR_CONSTANT_VALUE:
|
||||||
@ -158,7 +176,8 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
|
|||||||
case Constants.ATTR_LINE_NUMBER_TABLE:
|
case Constants.ATTR_LINE_NUMBER_TABLE:
|
||||||
return new LineNumberTable(name_index, length, file, constant_pool);
|
return new LineNumberTable(name_index, length, file, constant_pool);
|
||||||
case Constants.ATTR_LOCAL_VARIABLE_TABLE:
|
case Constants.ATTR_LOCAL_VARIABLE_TABLE:
|
||||||
return new LocalVariableTable(name_index, length, file, constant_pool);
|
return new LocalVariableTable(name_index, length, file,
|
||||||
|
constant_pool);
|
||||||
case Constants.ATTR_INNER_CLASSES:
|
case Constants.ATTR_INNER_CLASSES:
|
||||||
return new InnerClasses(name_index, length, file, constant_pool);
|
return new InnerClasses(name_index, length, file, constant_pool);
|
||||||
case Constants.ATTR_SYNTHETIC:
|
case Constants.ATTR_SYNTHETIC:
|
||||||
@ -172,21 +191,25 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
|
|||||||
case Constants.ATTR_STACK_MAP:
|
case Constants.ATTR_STACK_MAP:
|
||||||
return new StackMap(name_index, length, file, constant_pool);
|
return new StackMap(name_index, length, file, constant_pool);
|
||||||
// case Constants.ATTR_RUNTIMEVISIBLE_ANNOTATIONS:
|
// case Constants.ATTR_RUNTIMEVISIBLE_ANNOTATIONS:
|
||||||
// return new RuntimeVisibleAnnotations(name_index, length, file, constant_pool);
|
// return new RuntimeVisibleAnnotations(name_index, length, file,
|
||||||
|
// constant_pool);
|
||||||
// case Constants.ATTR_RUNTIMEINVISIBLE_ANNOTATIONS:
|
// case Constants.ATTR_RUNTIMEINVISIBLE_ANNOTATIONS:
|
||||||
// return new RuntimeInvisibleAnnotations(name_index, length, file, constant_pool);
|
// return new RuntimeInvisibleAnnotations(name_index, length, file,
|
||||||
|
// constant_pool);
|
||||||
// case Constants.ATTR_RUNTIMEVISIBLE_PARAMETER_ANNOTATIONS:
|
// case Constants.ATTR_RUNTIMEVISIBLE_PARAMETER_ANNOTATIONS:
|
||||||
// return new RuntimeVisibleParameterAnnotations(name_index, length, file, constant_pool);
|
// return new RuntimeVisibleParameterAnnotations(name_index, length,
|
||||||
|
// file, constant_pool);
|
||||||
// case Constants.ATTR_RUNTIMEINVISIBLE_PARAMETER_ANNOTATIONS:
|
// case Constants.ATTR_RUNTIMEINVISIBLE_PARAMETER_ANNOTATIONS:
|
||||||
// return new RuntimeInvisibleParameterAnnotations(name_index, length, file, constant_pool);
|
// return new RuntimeInvisibleParameterAnnotations(name_index,
|
||||||
|
// length, file, constant_pool);
|
||||||
// case Constants.ATTR_ANNOTATION_DEFAULT:
|
// case Constants.ATTR_ANNOTATION_DEFAULT:
|
||||||
// return new AnnotationDefault(name_index, length, file, constant_pool);
|
// return new AnnotationDefault(name_index, length, file,
|
||||||
|
// constant_pool);
|
||||||
default: // Never reached
|
default: // Never reached
|
||||||
throw new IllegalStateException("Ooops! default case reached.");
|
throw new IllegalStateException("Ooops! default case reached.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Length of attribute field in bytes.
|
* @return Length of attribute field in bytes.
|
||||||
*/
|
*/
|
||||||
@ -194,23 +217,22 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
|
|||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param length length in bytes.
|
* @param length
|
||||||
|
* length in bytes.
|
||||||
*/
|
*/
|
||||||
public final void setLength(int length) {
|
public final void setLength(int length) {
|
||||||
this.length = length;
|
this.length = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index of attribute.
|
* @param name_index
|
||||||
|
* of attribute.
|
||||||
*/
|
*/
|
||||||
public final void setNameIndex(int name_index) {
|
public final void setNameIndex(int name_index) {
|
||||||
this.name_index = name_index;
|
this.name_index = name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Name index in constant pool of attribute name.
|
* @return Name index in constant pool of attribute name.
|
||||||
*/
|
*/
|
||||||
@ -218,7 +240,6 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
|
|||||||
return name_index;
|
return name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Tag of attribute, i.e., its type. Value may not be altered, thus
|
* @return Tag of attribute, i.e., its type. Value may not be altered, thus
|
||||||
* there is no setTag() method.
|
* there is no setTag() method.
|
||||||
@ -227,7 +248,6 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
|
|||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Constant pool used by this object.
|
* @return Constant pool used by this object.
|
||||||
* @see ConstantPool
|
* @see ConstantPool
|
||||||
@ -236,22 +256,22 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
|
|||||||
return constant_pool;
|
return constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param constant_pool Constant pool to be used for this object.
|
* @param constant_pool
|
||||||
|
* Constant pool to be used for this object.
|
||||||
* @see ConstantPool
|
* @see ConstantPool
|
||||||
*/
|
*/
|
||||||
public final void setConstantPool(ConstantPool constant_pool) {
|
public final void setConstantPool(ConstantPool constant_pool) {
|
||||||
this.constant_pool = constant_pool;
|
this.constant_pool = constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use copy() if you want to have a deep copy(), i.e., with all references
|
* Use copy() if you want to have a deep copy(), i.e., with all references
|
||||||
* copied correctly.
|
* copied correctly.
|
||||||
*
|
*
|
||||||
* @return shallow copy of this attribute
|
* @return shallow copy of this attribute
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
Object o = null;
|
Object o = null;
|
||||||
try {
|
try {
|
||||||
@ -262,16 +282,15 @@ public abstract class Attribute implements Cloneable, Node, Serializable {
|
|||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this attribute
|
* @return deep copy of this attribute
|
||||||
*/
|
*/
|
||||||
public abstract Attribute copy(ConstantPool _constant_pool);
|
public abstract Attribute copy(ConstantPool _constant_pool);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return attribute name.
|
* @return attribute name.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return Constants.ATTRIBUTE_NAMES[tag];
|
return Constants.ATTRIBUTE_NAMES[tag];
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@ package org.apache.bcel.classfile;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Unknown (non-standard) attributes may be read via user-defined factory
|
* Unknown (non-standard) attributes may be read via user-defined factory
|
||||||
* objects that can be registered with the Attribute.addAttributeReader
|
* objects that can be registered with the Attribute.addAttributeReader method.
|
||||||
* method. These factory objects should implement this interface.
|
* These factory objects should implement this interface.
|
||||||
|
*
|
||||||
* @see Attribute
|
* @see Attribute
|
||||||
* @version $Id: AttributeReader.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: AttributeReader.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -28,31 +28,29 @@ package org.apache.bcel.classfile;
|
|||||||
public interface AttributeReader {
|
public interface AttributeReader {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
When this attribute reader is added via the static method
|
* When this attribute reader is added via the static method
|
||||||
Attribute.addAttributeReader, an attribute name is associated with it.
|
* Attribute.addAttributeReader, an attribute name is associated with it. As
|
||||||
As the class file parser parses attributes, it will call various
|
* the class file parser parses attributes, it will call various
|
||||||
AttributeReaders based on the name of the attributes it is
|
* AttributeReaders based on the name of the attributes it is constructing.
|
||||||
constructing.
|
*
|
||||||
|
* @param name_index
|
||||||
@param name_index An index into the constant pool, indexing a
|
* An index into the constant pool, indexing a ConstantUtf8 that
|
||||||
ConstantUtf8 that represents the name of the attribute.
|
* represents the name of the attribute.
|
||||||
|
* @param length
|
||||||
@param length The length of the data contained in the attribute. This
|
* The length of the data contained in the attribute. This is
|
||||||
is written into the constant pool and should agree with what the
|
* written into the constant pool and should agree with what the
|
||||||
factory expects the length to be.
|
* factory expects the length to be.
|
||||||
|
* @param file
|
||||||
@param file This is the data input stream that the factory needs to read
|
* This is the data input stream that the factory needs to read
|
||||||
its data from.
|
* its data from.
|
||||||
|
* @param constant_pool
|
||||||
@param constant_pool This is the constant pool associated with the
|
* This is the constant pool associated with the Attribute that
|
||||||
Attribute that we are constructing.
|
* we are constructing.
|
||||||
|
* @return The user-defined AttributeReader should take this data and use it
|
||||||
@return The user-defined AttributeReader should take this data and use
|
* to construct an attribute. In the case of errors, a null can be
|
||||||
it to construct an attribute. In the case of errors, a null can be
|
* returned which will cause the parsing of the class file to fail.
|
||||||
returned which will cause the parsing of the class file to fail.
|
* @see Attribute#addAttributeReader(String, AttributeReader )
|
||||||
|
|
||||||
@see Attribute#addAttributeReader( String, AttributeReader )
|
|
||||||
*/
|
*/
|
||||||
public Attribute createAttribute( int name_index, int length, java.io.DataInputStream file,
|
public Attribute createAttribute(int name_index, int length,
|
||||||
ConstantPool constant_pool );
|
java.io.DataInputStream file, ConstantPool constant_pool);
|
||||||
}
|
}
|
||||||
|
@ -17,20 +17,23 @@
|
|||||||
package org.apache.bcel.classfile;
|
package org.apache.bcel.classfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when the BCEL attempts to read a class file and determines
|
* Thrown when the BCEL attempts to read a class file and determines that the
|
||||||
* that the file is malformed or otherwise cannot be interpreted as a
|
* file is malformed or otherwise cannot be interpreted as a class file.
|
||||||
* class file.
|
|
||||||
*
|
*
|
||||||
* @version $Id: ClassFormatException.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ClassFormatException.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class ClassFormatException extends RuntimeException {
|
public class ClassFormatException extends RuntimeException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public ClassFormatException() {
|
public ClassFormatException() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ClassFormatException(String s) {
|
public ClassFormatException(String s) {
|
||||||
super(s);
|
super(s);
|
||||||
}
|
}
|
||||||
|
@ -26,16 +26,15 @@ import java.util.zip.ZipFile;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper class that parses a given Java .class file. The method <A
|
* Wrapper class that parses a given Java .class file. The method <A href
|
||||||
* href ="#parse">parse</A> returns a <A href ="JavaClass.html">
|
* ="#parse">parse</A> returns a <A href ="JavaClass.html"> JavaClass</A> object
|
||||||
* JavaClass</A> object on success. When an I/O error or an
|
* on success. When an I/O error or an inconsistency occurs an appropiate
|
||||||
* inconsistency occurs an appropiate exception is propagated back to
|
* exception is propagated back to the caller.
|
||||||
* the caller.
|
|
||||||
*
|
*
|
||||||
* The structure and the names comply, except for a few conveniences,
|
* The structure and the names comply, except for a few conveniences, exactly
|
||||||
* exactly with the <A href="ftp://java.sun.com/docs/specs/vmspec.ps">
|
* with the <A href="ftp://java.sun.com/docs/specs/vmspec.ps"> JVM specification
|
||||||
* JVM specification 1.0</a>. See this paper for
|
* 1.0</a>. See this paper for further details about the structure of a bytecode
|
||||||
* further details about the structure of a bytecode file.
|
* file.
|
||||||
*
|
*
|
||||||
* @version $Id: ClassParser.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ClassParser.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -57,29 +56,34 @@ public final class ClassParser {
|
|||||||
private boolean is_zip; // Loaded from zip file
|
private boolean is_zip; // Loaded from zip file
|
||||||
private static final int BUFSIZE = 8192;
|
private static final int BUFSIZE = 8192;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse class from the given stream.
|
* Parse class from the given stream.
|
||||||
*
|
*
|
||||||
* @param file Input stream
|
* @param file
|
||||||
* @param file_name File name
|
* Input stream
|
||||||
|
* @param file_name
|
||||||
|
* File name
|
||||||
*/
|
*/
|
||||||
public ClassParser(InputStream file, String file_name) {
|
public ClassParser(InputStream file, String file_name) {
|
||||||
this.file_name = file_name;
|
this.file_name = file_name;
|
||||||
fileOwned = false;
|
fileOwned = false;
|
||||||
String clazz = file.getClass().getName(); // Not a very clean solution ...
|
String clazz = file.getClass().getName(); // Not a very clean solution
|
||||||
is_zip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar.");
|
// ...
|
||||||
|
is_zip = clazz.startsWith("java.util.zip.")
|
||||||
|
|| clazz.startsWith("java.util.jar.");
|
||||||
if (file instanceof DataInputStream) {
|
if (file instanceof DataInputStream) {
|
||||||
this.file = (DataInputStream) file;
|
this.file = (DataInputStream) file;
|
||||||
} else {
|
} else {
|
||||||
this.file = new DataInputStream(new BufferedInputStream(file, BUFSIZE));
|
this.file = new DataInputStream(new BufferedInputStream(file,
|
||||||
|
BUFSIZE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Parse class from given .class file.
|
* Parse class from given .class file.
|
||||||
*
|
*
|
||||||
* @param file_name file name
|
* @param file_name
|
||||||
|
* file name
|
||||||
*/
|
*/
|
||||||
public ClassParser(String file_name) throws IOException {
|
public ClassParser(String file_name) throws IOException {
|
||||||
is_zip = false;
|
is_zip = false;
|
||||||
@ -87,11 +91,13 @@ public final class ClassParser {
|
|||||||
fileOwned = true;
|
fileOwned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Parse class from given .class file in a ZIP-archive
|
* Parse class from given .class file in a ZIP-archive
|
||||||
*
|
*
|
||||||
* @param zip_file zip file name
|
* @param zip_file
|
||||||
* @param file_name file name
|
* zip file name
|
||||||
|
* @param file_name
|
||||||
|
* file name
|
||||||
*/
|
*/
|
||||||
public ClassParser(String zip_file, String file_name) {
|
public ClassParser(String zip_file, String file_name) {
|
||||||
is_zip = true;
|
is_zip = true;
|
||||||
@ -100,11 +106,10 @@ public final class ClassParser {
|
|||||||
this.file_name = file_name;
|
this.file_name = file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the given Java class file and return an object that represents
|
* Parse the given Java class file and return an object that represents the
|
||||||
* the contained data, i.e., constants, methods, fields and commands.
|
* contained data, i.e., constants, methods, fields and commands. A
|
||||||
* A <em>ClassFormatException</em> is raised, if the file is not a valid
|
* <em>ClassFormatException</em> is raised, if the file is not a valid
|
||||||
* .class file. (This does not include verification of the byte code as it
|
* .class file. (This does not include verification of the byte code as it
|
||||||
* is performed by the java interpreter).
|
* is performed by the java interpreter).
|
||||||
*
|
*
|
||||||
@ -119,11 +124,11 @@ public final class ClassParser {
|
|||||||
if (is_zip) {
|
if (is_zip) {
|
||||||
zip = new ZipFile(zip_file);
|
zip = new ZipFile(zip_file);
|
||||||
ZipEntry entry = zip.getEntry(file_name);
|
ZipEntry entry = zip.getEntry(file_name);
|
||||||
file = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry),
|
file = new DataInputStream(new BufferedInputStream(
|
||||||
BUFSIZE));
|
zip.getInputStream(entry), BUFSIZE));
|
||||||
} else {
|
} else {
|
||||||
file = new DataInputStream(new BufferedInputStream(new FileInputStream(
|
file = new DataInputStream(new BufferedInputStream(
|
||||||
file_name), BUFSIZE));
|
new FileInputStream(file_name), BUFSIZE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/****************** Read headers ********************************/
|
/****************** Read headers ********************************/
|
||||||
@ -155,8 +160,10 @@ public final class ClassParser {
|
|||||||
// byte[] buf = new byte[bytes];
|
// byte[] buf = new byte[bytes];
|
||||||
// file.read(buf);
|
// file.read(buf);
|
||||||
// if(!(is_zip && (buf.length == 1))) {
|
// if(!(is_zip && (buf.length == 1))) {
|
||||||
// System.err.println("WARNING: Trailing garbage at end of " + file_name);
|
// System.err.println("WARNING: Trailing garbage at end of " +
|
||||||
// System.err.println(bytes + " extra bytes: " + Utility.toHexString(buf));
|
// file_name);
|
||||||
|
// System.err.println(bytes + " extra bytes: " +
|
||||||
|
// Utility.toHexString(buf));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
} finally {
|
} finally {
|
||||||
@ -169,19 +176,20 @@ public final class ClassParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Return the information we have gathered in a new object
|
// Return the information we have gathered in a new object
|
||||||
return new JavaClass(class_name_index, superclass_name_index, file_name, major, minor,
|
return new JavaClass(class_name_index, superclass_name_index,
|
||||||
access_flags, constant_pool, interfaces, fields, methods, attributes, is_zip
|
file_name, major, minor, access_flags, constant_pool,
|
||||||
? JavaClass.ZIP
|
interfaces, fields, methods, attributes, is_zip ? JavaClass.ZIP
|
||||||
: JavaClass.FILE);
|
: JavaClass.FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read information about the attributes of the class.
|
* Read information about the attributes of the class.
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassFormatException
|
* @throws ClassFormatException
|
||||||
*/
|
*/
|
||||||
private final void readAttributes() throws IOException, ClassFormatException {
|
private final void readAttributes() throws IOException,
|
||||||
|
ClassFormatException {
|
||||||
int attributes_count;
|
int attributes_count;
|
||||||
attributes_count = file.readUnsignedShort();
|
attributes_count = file.readUnsignedShort();
|
||||||
attributes = new Attribute[attributes_count];
|
attributes = new Attribute[attributes_count];
|
||||||
@ -190,41 +198,44 @@ public final class ClassParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read information about the class and its super class.
|
* Read information about the class and its super class.
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassFormatException
|
* @throws ClassFormatException
|
||||||
*/
|
*/
|
||||||
private final void readClassInfo() throws IOException, ClassFormatException {
|
private final void readClassInfo() throws IOException, ClassFormatException {
|
||||||
access_flags = file.readUnsignedShort();
|
access_flags = file.readUnsignedShort();
|
||||||
/* Interfaces are implicitely abstract, the flag should be set
|
/*
|
||||||
* according to the JVM specification.
|
* Interfaces are implicitely abstract, the flag should be set according
|
||||||
|
* to the JVM specification.
|
||||||
*/
|
*/
|
||||||
if ((access_flags & Constants.ACC_INTERFACE) != 0) {
|
if ((access_flags & Constants.ACC_INTERFACE) != 0) {
|
||||||
access_flags |= Constants.ACC_ABSTRACT;
|
access_flags |= Constants.ACC_ABSTRACT;
|
||||||
}
|
}
|
||||||
if (((access_flags & Constants.ACC_ABSTRACT) != 0)
|
if (((access_flags & Constants.ACC_ABSTRACT) != 0)
|
||||||
&& ((access_flags & Constants.ACC_FINAL) != 0)) {
|
&& ((access_flags & Constants.ACC_FINAL) != 0)) {
|
||||||
throw new ClassFormatException("Class can't be both final and abstract");
|
throw new ClassFormatException(
|
||||||
|
"Class can't be both final and abstract");
|
||||||
}
|
}
|
||||||
class_name_index = file.readUnsignedShort();
|
class_name_index = file.readUnsignedShort();
|
||||||
superclass_name_index = file.readUnsignedShort();
|
superclass_name_index = file.readUnsignedShort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read constant pool entries.
|
* Read constant pool entries.
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassFormatException
|
* @throws ClassFormatException
|
||||||
*/
|
*/
|
||||||
private final void readConstantPool() throws IOException, ClassFormatException {
|
private final void readConstantPool() throws IOException,
|
||||||
|
ClassFormatException {
|
||||||
constant_pool = new ConstantPool(file);
|
constant_pool = new ConstantPool(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read information about the fields of the class, i.e., its variables.
|
* Read information about the fields of the class, i.e., its variables.
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassFormatException
|
* @throws ClassFormatException
|
||||||
*/
|
*/
|
||||||
@ -237,28 +248,30 @@ public final class ClassParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************** Private utility methods **********************/
|
/******************** Private utility methods **********************/
|
||||||
/**
|
/**
|
||||||
* Check whether the header of the file is ok.
|
* Check whether the header of the file is ok. Of course, this has to be the
|
||||||
* Of course, this has to be the first action on successive file reads.
|
* first action on successive file reads.
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassFormatException
|
* @throws ClassFormatException
|
||||||
*/
|
*/
|
||||||
private final void readID() throws IOException, ClassFormatException {
|
private final void readID() throws IOException, ClassFormatException {
|
||||||
int magic = 0xCAFEBABE;
|
int magic = 0xCAFEBABE;
|
||||||
if (file.readInt() != magic) {
|
if (file.readInt() != magic) {
|
||||||
throw new ClassFormatException(file_name + " is not a Java .class file");
|
throw new ClassFormatException(file_name
|
||||||
|
+ " is not a Java .class file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read information about the interfaces implemented by this class.
|
* Read information about the interfaces implemented by this class.
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassFormatException
|
* @throws ClassFormatException
|
||||||
*/
|
*/
|
||||||
private final void readInterfaces() throws IOException, ClassFormatException {
|
private final void readInterfaces() throws IOException,
|
||||||
|
ClassFormatException {
|
||||||
int interfaces_count;
|
int interfaces_count;
|
||||||
interfaces_count = file.readUnsignedShort();
|
interfaces_count = file.readUnsignedShort();
|
||||||
interfaces = new int[interfaces_count];
|
interfaces = new int[interfaces_count];
|
||||||
@ -267,9 +280,9 @@ public final class ClassParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read information about the methods of the class.
|
* Read information about the methods of the class.
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassFormatException
|
* @throws ClassFormatException
|
||||||
*/
|
*/
|
||||||
@ -282,9 +295,9 @@ public final class ClassParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read major and minor version of compiler which created the file.
|
* Read major and minor version of compiler which created the file.
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassFormatException
|
* @throws ClassFormatException
|
||||||
*/
|
*/
|
||||||
|
@ -22,16 +22,14 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a chunk of Java byte code contained in a
|
* This class represents a chunk of Java byte code contained in a method. It is
|
||||||
* method. It is instantiated by the
|
* instantiated by the <em>Attribute.readAttribute()</em> method. A
|
||||||
* <em>Attribute.readAttribute()</em> method. A <em>Code</em>
|
* <em>Code</em> attribute contains informations about operand stack, local
|
||||||
* attribute contains informations about operand stack, local
|
* variables, byte code and the exceptions handled within this method.
|
||||||
* variables, byte code and the exceptions handled within this
|
|
||||||
* method.
|
|
||||||
*
|
*
|
||||||
* This attribute has attributes itself, namely <em>LineNumberTable</em> which
|
* This attribute has attributes itself, namely <em>LineNumberTable</em> which
|
||||||
* is used for debugging purposes and <em>LocalVariableTable</em> which
|
* is used for debugging purposes and <em>LocalVariableTable</em> which contains
|
||||||
* contains information about the local variables.
|
* information about the local variables.
|
||||||
*
|
*
|
||||||
* @version $Id: Code.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: Code.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -42,6 +40,10 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class Code extends Attribute {
|
public final class Code extends Attribute {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int max_stack; // Maximum size of stack used by this method
|
private int max_stack; // Maximum size of stack used by this method
|
||||||
private int max_locals; // Number of local variables
|
private int max_locals; // Number of local variables
|
||||||
private int code_length; // Length of code in bytes
|
private int code_length; // Length of code in bytes
|
||||||
@ -51,32 +53,37 @@ public final class Code extends Attribute {
|
|||||||
private int attributes_count; // Attributes of code: LineNumber
|
private int attributes_count; // Attributes of code: LineNumber
|
||||||
private Attribute[] attributes; // or LocalVariable
|
private Attribute[] attributes; // or LocalVariable
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use copy() for a physical copy.
|
* references (shallow copy). Use copy() for a physical copy.
|
||||||
*/
|
*/
|
||||||
public Code(Code c) {
|
public Code(Code c) {
|
||||||
this(c.getNameIndex(), c.getLength(), c.getMaxStack(), c.getMaxLocals(), c.getCode(), c
|
this(c.getNameIndex(), c.getLength(), c.getMaxStack(),
|
||||||
.getExceptionTable(), c.getAttributes(), c.getConstantPool());
|
c.getMaxLocals(), c.getCode(), c.getExceptionTable(), c
|
||||||
|
.getAttributes(), c.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index Index pointing to the name <em>Code</em>
|
* @param name_index
|
||||||
* @param length Content length in bytes
|
* Index pointing to the name <em>Code</em>
|
||||||
* @param file Input stream
|
* @param length
|
||||||
* @param constant_pool Array of constants
|
* Content length in bytes
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
Code(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
Code(int name_index, int length, DataInputStream file,
|
||||||
throws IOException {
|
ConstantPool constant_pool) throws IOException {
|
||||||
// Initialize with some default values which will be overwritten later
|
// Initialize with some default values which will be overwritten later
|
||||||
this(name_index, length, file.readUnsignedShort(), file.readUnsignedShort(), (byte[]) null,
|
this(name_index, length, file.readUnsignedShort(), file
|
||||||
(CodeException[]) null, (Attribute[]) null, constant_pool);
|
.readUnsignedShort(), (byte[]) null, (CodeException[]) null,
|
||||||
|
(Attribute[]) null, constant_pool);
|
||||||
code_length = file.readInt();
|
code_length = file.readInt();
|
||||||
code = new byte[code_length]; // Read byte code
|
code = new byte[code_length]; // Read byte code
|
||||||
file.readFully(code);
|
file.readFully(code);
|
||||||
/* Read exception table that contains all regions where an exception
|
/*
|
||||||
|
* Read exception table that contains all regions where an exception
|
||||||
* handler is active, i.e., a try { ... } catch() block.
|
* handler is active, i.e., a try { ... } catch() block.
|
||||||
*/
|
*/
|
||||||
exception_table_length = file.readUnsignedShort();
|
exception_table_length = file.readUnsignedShort();
|
||||||
@ -84,7 +91,8 @@ public final class Code extends Attribute {
|
|||||||
for (int i = 0; i < exception_table_length; i++) {
|
for (int i = 0; i < exception_table_length; i++) {
|
||||||
exception_table[i] = new CodeException(file);
|
exception_table[i] = new CodeException(file);
|
||||||
}
|
}
|
||||||
/* Read all attributes, currently `LineNumberTable' and
|
/*
|
||||||
|
* Read all attributes, currently `LineNumberTable' and
|
||||||
* `LocalVariableTable'
|
* `LocalVariableTable'
|
||||||
*/
|
*/
|
||||||
attributes_count = file.readUnsignedShort();
|
attributes_count = file.readUnsignedShort();
|
||||||
@ -92,26 +100,35 @@ public final class Code extends Attribute {
|
|||||||
for (int i = 0; i < attributes_count; i++) {
|
for (int i = 0; i < attributes_count; i++) {
|
||||||
attributes[i] = Attribute.readAttribute(file, constant_pool);
|
attributes[i] = Attribute.readAttribute(file, constant_pool);
|
||||||
}
|
}
|
||||||
/* Adjust length, because of setAttributes in this(), s.b. length
|
/*
|
||||||
* is incorrect, because it didn't take the internal attributes
|
* Adjust length, because of setAttributes in this(), s.b. length is
|
||||||
* into account yet! Very subtle bug, fixed in 3.1.1.
|
* incorrect, because it didn't take the internal attributes into
|
||||||
|
* account yet! Very subtle bug, fixed in 3.1.1.
|
||||||
*/
|
*/
|
||||||
this.length = length;
|
this.length = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index Index pointing to the name <em>Code</em>
|
* @param name_index
|
||||||
* @param length Content length in bytes
|
* Index pointing to the name <em>Code</em>
|
||||||
* @param max_stack Maximum size of stack
|
* @param length
|
||||||
* @param max_locals Number of local variables
|
* Content length in bytes
|
||||||
* @param code Actual byte code
|
* @param max_stack
|
||||||
* @param exception_table Table of handled exceptions
|
* Maximum size of stack
|
||||||
* @param attributes Attributes of code: LineNumber or LocalVariable
|
* @param max_locals
|
||||||
* @param constant_pool Array of constants
|
* Number of local variables
|
||||||
|
* @param code
|
||||||
|
* Actual byte code
|
||||||
|
* @param exception_table
|
||||||
|
* Table of handled exceptions
|
||||||
|
* @param attributes
|
||||||
|
* Attributes of code: LineNumber or LocalVariable
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
public Code(int name_index, int length, int max_stack, int max_locals, byte[] code,
|
public Code(int name_index, int length, int max_stack, int max_locals,
|
||||||
CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) {
|
byte[] code, CodeException[] exception_table,
|
||||||
|
Attribute[] attributes, ConstantPool constant_pool) {
|
||||||
super(Constants.ATTR_CODE, name_index, length, constant_pool);
|
super(Constants.ATTR_CODE, name_index, length, constant_pool);
|
||||||
this.max_stack = max_stack;
|
this.max_stack = max_stack;
|
||||||
this.max_locals = max_locals;
|
this.max_locals = max_locals;
|
||||||
@ -120,25 +137,27 @@ public final class Code extends Attribute {
|
|||||||
setAttributes(attributes); // Overwrites length!
|
setAttributes(attributes); // Overwrites length!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitCode(this);
|
v.visitCode(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump code attribute to file stream in binary format.
|
* Dump code attribute to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
super.dump(file);
|
super.dump(file);
|
||||||
file.writeShort(max_stack);
|
file.writeShort(max_stack);
|
||||||
@ -155,7 +174,6 @@ public final class Code extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection of code attributes.
|
* @return Collection of code attributes.
|
||||||
* @see Attribute
|
* @see Attribute
|
||||||
@ -164,7 +182,6 @@ public final class Code extends Attribute {
|
|||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return LineNumberTable of Code, if it has one
|
* @return LineNumberTable of Code, if it has one
|
||||||
*/
|
*/
|
||||||
@ -177,7 +194,6 @@ public final class Code extends Attribute {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return LocalVariableTable of Code, if it has one
|
* @return LocalVariableTable of Code, if it has one
|
||||||
*/
|
*/
|
||||||
@ -190,7 +206,6 @@ public final class Code extends Attribute {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Actual byte code of the method.
|
* @return Actual byte code of the method.
|
||||||
*/
|
*/
|
||||||
@ -198,7 +213,6 @@ public final class Code extends Attribute {
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Table of handled exceptions.
|
* @return Table of handled exceptions.
|
||||||
* @see CodeException
|
* @see CodeException
|
||||||
@ -207,7 +221,6 @@ public final class Code extends Attribute {
|
|||||||
return exception_table;
|
return exception_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Number of local variables.
|
* @return Number of local variables.
|
||||||
*/
|
*/
|
||||||
@ -215,7 +228,6 @@ public final class Code extends Attribute {
|
|||||||
return max_locals;
|
return max_locals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Maximum size of stack used by this method.
|
* @return Maximum size of stack used by this method.
|
||||||
*/
|
*/
|
||||||
@ -223,10 +235,9 @@ public final class Code extends Attribute {
|
|||||||
return max_stack;
|
return max_stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the internal length of this code attribute (minus the first 6 bytes)
|
* @return the internal length of this code attribute (minus the first 6
|
||||||
* and excluding all its attributes
|
* bytes) and excluding all its attributes
|
||||||
*/
|
*/
|
||||||
private final int getInternalLength() {
|
private final int getInternalLength() {
|
||||||
return 2 /* max_stack */+ 2 /* max_locals */+ 4 /* code length */
|
return 2 /* max_stack */+ 2 /* max_locals */+ 4 /* code length */
|
||||||
@ -236,7 +247,6 @@ public final class Code extends Attribute {
|
|||||||
+ 2 /* attributes count */;
|
+ 2 /* attributes count */;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the full size of this code attribute, minus its first 6 bytes,
|
* @return the full size of this code attribute, minus its first 6 bytes,
|
||||||
* including the size of all its contained attributes
|
* including the size of all its contained attributes
|
||||||
@ -249,9 +259,9 @@ public final class Code extends Attribute {
|
|||||||
return len + getInternalLength();
|
return len + getInternalLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param attributes the attributes to set for this Code
|
* @param attributes
|
||||||
|
* the attributes to set for this Code
|
||||||
*/
|
*/
|
||||||
public final void setAttributes(Attribute[] attributes) {
|
public final void setAttributes(Attribute[] attributes) {
|
||||||
this.attributes = attributes;
|
this.attributes = attributes;
|
||||||
@ -259,54 +269,62 @@ public final class Code extends Attribute {
|
|||||||
length = calculateLength(); // Adjust length
|
length = calculateLength(); // Adjust length
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param code byte code
|
* @param code
|
||||||
|
* byte code
|
||||||
*/
|
*/
|
||||||
public final void setCode(byte[] code) {
|
public final void setCode(byte[] code) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
code_length = (code == null) ? 0 : code.length;
|
code_length = (code == null) ? 0 : code.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param exception_table exception table
|
* @param exception_table
|
||||||
|
* exception table
|
||||||
*/
|
*/
|
||||||
public final void setExceptionTable(CodeException[] exception_table) {
|
public final void setExceptionTable(CodeException[] exception_table) {
|
||||||
this.exception_table = exception_table;
|
this.exception_table = exception_table;
|
||||||
exception_table_length = (exception_table == null) ? 0 : exception_table.length;
|
exception_table_length = (exception_table == null) ? 0
|
||||||
|
: exception_table.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param max_locals maximum number of local variables
|
* @param max_locals
|
||||||
|
* maximum number of local variables
|
||||||
*/
|
*/
|
||||||
public final void setMaxLocals(int max_locals) {
|
public final void setMaxLocals(int max_locals) {
|
||||||
this.max_locals = max_locals;
|
this.max_locals = max_locals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param max_stack maximum stack size
|
* @param max_stack
|
||||||
|
* maximum stack size
|
||||||
*/
|
*/
|
||||||
public final void setMaxStack(int max_stack) {
|
public final void setMaxStack(int max_stack) {
|
||||||
this.max_stack = max_stack;
|
this.max_stack = max_stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation of code chunk.
|
* @return String representation of code chunk.
|
||||||
*/
|
*/
|
||||||
public final String toString(boolean verbose) {
|
public final String toString(boolean verbose) {
|
||||||
StringBuffer buf;
|
StringBuffer buf;
|
||||||
buf = new StringBuffer(100);
|
buf = new StringBuffer(100);
|
||||||
buf.append("Code(max_stack = ").append(max_stack).append(", max_locals = ").append(
|
buf.append("Code(max_stack = ")
|
||||||
max_locals).append(", code_length = ").append(code_length).append(")\n").append(
|
.append(max_stack)
|
||||||
Utility.codeToString(code, constant_pool, 0, -1, verbose));
|
.append(", max_locals = ")
|
||||||
|
.append(max_locals)
|
||||||
|
.append(", code_length = ")
|
||||||
|
.append(code_length)
|
||||||
|
.append(")\n")
|
||||||
|
.append(Utility.codeToString(code, constant_pool, 0, -1,
|
||||||
|
verbose));
|
||||||
if (exception_table_length > 0) {
|
if (exception_table_length > 0) {
|
||||||
buf.append("\nException handler(s) = \n").append("From\tTo\tHandler\tType\n");
|
buf.append("\nException handler(s) = \n").append(
|
||||||
|
"From\tTo\tHandler\tType\n");
|
||||||
for (int i = 0; i < exception_table_length; i++) {
|
for (int i = 0; i < exception_table_length; i++) {
|
||||||
buf.append(exception_table[i].toString(constant_pool, verbose)).append("\n");
|
buf.append(exception_table[i].toString(constant_pool, verbose))
|
||||||
|
.append("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (attributes_count > 0) {
|
if (attributes_count > 0) {
|
||||||
@ -318,20 +336,21 @@ public final class Code extends Attribute {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation of code chunk.
|
* @return String representation of code chunk.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return toString(true);
|
return toString(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this attribute
|
* @return deep copy of this attribute
|
||||||
*
|
*
|
||||||
* @param _constant_pool the constant pool to duplicate
|
* @param _constant_pool
|
||||||
|
* the constant pool to duplicate
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Attribute copy(ConstantPool _constant_pool) {
|
public Attribute copy(ConstantPool _constant_pool) {
|
||||||
Code c = (Code) clone();
|
Code c = (Code) clone();
|
||||||
if (code != null) {
|
if (code != null) {
|
||||||
|
@ -24,26 +24,32 @@ import org.apache.bcel.Constants;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents an entry in the exception table of the <em>Code</em>
|
* This class represents an entry in the exception table of the <em>Code</em>
|
||||||
* attribute and is used only there. It contains a range in which a
|
* attribute and is used only there. It contains a range in which a particular
|
||||||
* particular exception handler is active.
|
* exception handler is active.
|
||||||
*
|
*
|
||||||
* @version $Id: CodeException.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: CodeException.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
* @see Code
|
* @see Code
|
||||||
*/
|
*/
|
||||||
public final class CodeException implements Cloneable, Constants, Node, Serializable {
|
public final class CodeException implements Cloneable, Constants, Node,
|
||||||
|
Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int start_pc; // Range in the code the exception handler is
|
private int start_pc; // Range in the code the exception handler is
|
||||||
private int end_pc; // active. start_pc is inclusive, end_pc exclusive
|
private int end_pc; // active. start_pc is inclusive, end_pc exclusive
|
||||||
private int handler_pc; /* Starting address of exception handler, i.e.,
|
private int handler_pc; /*
|
||||||
* an offset from start of code.
|
* Starting address of exception handler, i.e., an
|
||||||
|
* offset from start of code.
|
||||||
*/
|
*/
|
||||||
private int catch_type; /* If this is zero the handler catches any
|
private int catch_type; /*
|
||||||
* exception, otherwise it points to the
|
* If this is zero the handler catches any
|
||||||
* exception class which is to be caught.
|
* exception, otherwise it points to the exception
|
||||||
|
* class which is to be caught.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object.
|
* Initialize from another object.
|
||||||
*/
|
*/
|
||||||
@ -51,52 +57,57 @@ public final class CodeException implements Cloneable, Constants, Node, Serializ
|
|||||||
this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType());
|
this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param file Input stream
|
*
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
CodeException(DataInputStream file) throws IOException {
|
CodeException(DataInputStream file) throws IOException {
|
||||||
this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file
|
this(file.readUnsignedShort(), file.readUnsignedShort(), file
|
||||||
.readUnsignedShort());
|
.readUnsignedShort(), file.readUnsignedShort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param start_pc Range in the code the exception handler is active,
|
* @param start_pc
|
||||||
* start_pc is inclusive while
|
* Range in the code the exception handler is active, start_pc is
|
||||||
* @param end_pc is exclusive
|
* inclusive while
|
||||||
* @param handler_pc Starting address of exception handler, i.e.,
|
* @param end_pc
|
||||||
* an offset from start of code.
|
* is exclusive
|
||||||
* @param catch_type If zero the handler catches any
|
* @param handler_pc
|
||||||
* exception, otherwise it points to the exception class which is
|
* Starting address of exception handler, i.e., an offset from
|
||||||
* to be caught.
|
* start of code.
|
||||||
|
* @param catch_type
|
||||||
|
* If zero the handler catches any exception, otherwise it points
|
||||||
|
* to the exception class which is to be caught.
|
||||||
*/
|
*/
|
||||||
public CodeException(int start_pc, int end_pc, int handler_pc, int catch_type) {
|
public CodeException(int start_pc, int end_pc, int handler_pc,
|
||||||
|
int catch_type) {
|
||||||
this.start_pc = start_pc;
|
this.start_pc = start_pc;
|
||||||
this.end_pc = end_pc;
|
this.end_pc = end_pc;
|
||||||
this.handler_pc = handler_pc;
|
this.handler_pc = handler_pc;
|
||||||
this.catch_type = catch_type;
|
this.catch_type = catch_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitCodeException(this);
|
v.visitCodeException(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump code exception to file stream in binary format.
|
* Dump code exception to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
@ -106,7 +117,6 @@ public final class CodeException implements Cloneable, Constants, Node, Serializ
|
|||||||
file.writeShort(catch_type);
|
file.writeShort(catch_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 0, if the handler catches any exception, otherwise it points to
|
* @return 0, if the handler catches any exception, otherwise it points to
|
||||||
* the exception class which is to be caught.
|
* the exception class which is to be caught.
|
||||||
@ -115,7 +125,6 @@ public final class CodeException implements Cloneable, Constants, Node, Serializ
|
|||||||
return catch_type;
|
return catch_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Exclusive end index of the region where the handler is active.
|
* @return Exclusive end index of the region where the handler is active.
|
||||||
*/
|
*/
|
||||||
@ -123,7 +132,6 @@ public final class CodeException implements Cloneable, Constants, Node, Serializ
|
|||||||
return end_pc;
|
return end_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Starting address of exception handler, relative to the code.
|
* @return Starting address of exception handler, relative to the code.
|
||||||
*/
|
*/
|
||||||
@ -131,7 +139,6 @@ public final class CodeException implements Cloneable, Constants, Node, Serializ
|
|||||||
return handler_pc;
|
return handler_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Inclusive start index of the region where the handler is active.
|
* @return Inclusive start index of the region where the handler is active.
|
||||||
*/
|
*/
|
||||||
@ -139,48 +146,48 @@ public final class CodeException implements Cloneable, Constants, Node, Serializ
|
|||||||
return start_pc;
|
return start_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param catch_type the type of exception that is caught
|
* @param catch_type
|
||||||
|
* the type of exception that is caught
|
||||||
*/
|
*/
|
||||||
public final void setCatchType(int catch_type) {
|
public final void setCatchType(int catch_type) {
|
||||||
this.catch_type = catch_type;
|
this.catch_type = catch_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param end_pc end of handled block
|
* @param end_pc
|
||||||
|
* end of handled block
|
||||||
*/
|
*/
|
||||||
public final void setEndPC(int end_pc) {
|
public final void setEndPC(int end_pc) {
|
||||||
this.end_pc = end_pc;
|
this.end_pc = end_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param handler_pc where the actual code is
|
* @param handler_pc
|
||||||
|
* where the actual code is
|
||||||
*/
|
*/
|
||||||
public final void setHandlerPC(int handler_pc) {
|
public final void setHandlerPC(int handler_pc) {
|
||||||
this.handler_pc = handler_pc;
|
this.handler_pc = handler_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param start_pc start of handled block
|
* @param start_pc
|
||||||
|
* start of handled block
|
||||||
*/
|
*/
|
||||||
public final void setStartPC(int start_pc) {
|
public final void setStartPC(int start_pc) {
|
||||||
this.start_pc = start_pc;
|
this.start_pc = start_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return "CodeException(start_pc = " + start_pc + ", end_pc = " + end_pc + ", handler_pc = "
|
return "CodeException(start_pc = " + start_pc + ", end_pc = " + end_pc
|
||||||
+ handler_pc + ", catch_type = " + catch_type + ")";
|
+ ", handler_pc = " + handler_pc + ", catch_type = "
|
||||||
|
+ catch_type + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
@ -189,18 +196,17 @@ public final class CodeException implements Cloneable, Constants, Node, Serializ
|
|||||||
if (catch_type == 0) {
|
if (catch_type == 0) {
|
||||||
str = "<Any exception>(0)";
|
str = "<Any exception>(0)";
|
||||||
} else {
|
} else {
|
||||||
str = Utility.compactClassName(cp.getConstantString(catch_type, CONSTANT_Class), false)
|
str = Utility.compactClassName(
|
||||||
|
cp.getConstantString(catch_type, CONSTANT_Class), false)
|
||||||
+ (verbose ? "(" + catch_type + ")" : "");
|
+ (verbose ? "(" + catch_type + ")" : "");
|
||||||
}
|
}
|
||||||
return start_pc + "\t" + end_pc + "\t" + handler_pc + "\t" + str;
|
return start_pc + "\t" + end_pc + "\t" + handler_pc + "\t" + str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final String toString(ConstantPool cp) {
|
public final String toString(ConstantPool cp) {
|
||||||
return toString(cp, true);
|
return toString(cp, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this object
|
* @return deep copy of this object
|
||||||
*/
|
*/
|
||||||
|
@ -24,32 +24,38 @@ import org.apache.bcel.Constants;
|
|||||||
import org.apache.bcel.util.BCELComparator;
|
import org.apache.bcel.util.BCELComparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract superclass for classes to represent the different constant types
|
* Abstract superclass for classes to represent the different constant types in
|
||||||
* in the constant pool of a class file. The classes keep closely to
|
* the constant pool of a class file. The classes keep closely to the JVM
|
||||||
* the JVM specification.
|
* specification.
|
||||||
*
|
*
|
||||||
* @version $Id: Constant.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: Constant.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @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, Node, Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private static BCELComparator _cmp = new BCELComparator() {
|
private static BCELComparator _cmp = new BCELComparator() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object o1, Object o2) {
|
public boolean equals(Object o1, Object o2) {
|
||||||
Constant THIS = (Constant) o1;
|
Constant THIS = (Constant) o1;
|
||||||
Constant THAT = (Constant) o2;
|
Constant THAT = (Constant) o2;
|
||||||
return THIS.toString().equals(THAT.toString());
|
return THIS.toString().equals(THAT.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int hashCode(Object o) {
|
public int hashCode(Object o) {
|
||||||
Constant THIS = (Constant) o;
|
Constant THIS = (Constant) o;
|
||||||
return THIS.toString().hashCode();
|
return THIS.toString().hashCode();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/* In fact this tag is redundant since we can distinguish different
|
/*
|
||||||
* `Constant' objects by their type, i.e., via `instanceof'. In some
|
* In fact this tag is redundant since we can distinguish different
|
||||||
* places we will use the tag for switch()es anyway.
|
* `Constant' objects by their type, i.e., via `instanceof'. In some places
|
||||||
|
* we will use the tag for switch()es anyway.
|
||||||
*
|
*
|
||||||
* First, we want match the specification as closely as possible. Second we
|
* First, we want match the specification as closely as possible. Second we
|
||||||
* need the tag as an index to select the corresponding class name from the
|
* need the tag as an index to select the corresponding class name from the
|
||||||
@ -57,25 +63,23 @@ public abstract class Constant implements Cloneable, Node, Serializable {
|
|||||||
*/
|
*/
|
||||||
protected byte tag;
|
protected byte tag;
|
||||||
|
|
||||||
|
|
||||||
Constant(byte tag) {
|
Constant(byte tag) {
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public abstract void accept(Visitor v);
|
public abstract void accept(Visitor v);
|
||||||
|
|
||||||
|
|
||||||
public abstract void dump(DataOutputStream file) throws IOException;
|
public abstract void dump(DataOutputStream file) throws IOException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Tag of constant, i.e., its type. No setTag() method to avoid
|
* @return Tag of constant, i.e., its type. No setTag() method to avoid
|
||||||
* confusion.
|
* confusion.
|
||||||
@ -84,15 +88,14 @@ public abstract class Constant implements Cloneable, Node, Serializable {
|
|||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return Constants.CONSTANT_NAMES[tag] + "[" + tag + "]";
|
return Constants.CONSTANT_NAMES[tag] + "[" + tag + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this constant
|
* @return deep copy of this constant
|
||||||
*/
|
*/
|
||||||
@ -104,20 +107,20 @@ public abstract class Constant implements Cloneable, Node, Serializable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
return super.clone();
|
return super.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read one constant from the given file, the type depends on a tag byte.
|
* Read one constant from the given file, the type depends on a tag byte.
|
||||||
*
|
*
|
||||||
* @param file Input stream
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @return Constant object
|
* @return Constant object
|
||||||
*/
|
*/
|
||||||
static final Constant readConstant( DataInputStream file ) throws IOException,
|
static final Constant readConstant(DataInputStream file)
|
||||||
ClassFormatException {
|
throws IOException, ClassFormatException {
|
||||||
byte b = file.readByte(); // Read tag byte
|
byte b = file.readByte(); // Read tag byte
|
||||||
switch (b) {
|
switch (b) {
|
||||||
case Constants.CONSTANT_Class:
|
case Constants.CONSTANT_Class:
|
||||||
@ -143,11 +146,11 @@ public abstract class Constant implements Cloneable, Node, Serializable {
|
|||||||
case Constants.CONSTANT_Utf8:
|
case Constants.CONSTANT_Utf8:
|
||||||
return new ConstantUtf8(file);
|
return new ConstantUtf8(file);
|
||||||
default:
|
default:
|
||||||
throw new ClassFormatException("Invalid byte tag in constant pool: " + b);
|
throw new ClassFormatException(
|
||||||
|
"Invalid byte tag in constant pool: " + b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Comparison strategy object
|
* @return Comparison strategy object
|
||||||
*/
|
*/
|
||||||
@ -155,33 +158,33 @@ public abstract class Constant implements Cloneable, Node, Serializable {
|
|||||||
return _cmp;
|
return _cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param comparator Comparison strategy object
|
* @param comparator
|
||||||
|
* Comparison strategy object
|
||||||
*/
|
*/
|
||||||
public static void setComparator(BCELComparator comparator) {
|
public static void setComparator(BCELComparator comparator) {
|
||||||
_cmp = comparator;
|
_cmp = comparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value as defined by given BCELComparator strategy.
|
* Return value as defined by given BCELComparator strategy. By default two
|
||||||
* By default two Constant objects are said to be equal when
|
* Constant objects are said to be equal when the result of toString() is
|
||||||
* the result of toString() is equal.
|
* equal.
|
||||||
*
|
*
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return _cmp.equals(this, obj);
|
return _cmp.equals(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value as defined by given BCELComparator strategy.
|
* Return value as defined by given BCELComparator strategy. By default
|
||||||
* By default return the hashcode of the result of toString().
|
* return the hashcode of the result of toString().
|
||||||
*
|
*
|
||||||
* @see java.lang.Object#hashCode()
|
* @see java.lang.Object#hashCode()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return _cmp.hashCode(this);
|
return _cmp.hashCode(this);
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,15 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public abstract class ConstantCP extends Constant {
|
public abstract class ConstantCP extends Constant {
|
||||||
|
|
||||||
/** References to the constants containing the class and the field signature
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
/**
|
||||||
|
* References to the constants containing the class and the field signature
|
||||||
*/
|
*/
|
||||||
protected int class_index, name_and_type_index;
|
protected int class_index, name_and_type_index;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object.
|
* Initialize from another object.
|
||||||
*/
|
*/
|
||||||
@ -44,22 +48,24 @@ public abstract class ConstantCP extends Constant {
|
|||||||
this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex());
|
this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize instance from file data.
|
* Initialize instance from file data.
|
||||||
*
|
*
|
||||||
* @param tag Constant type tag
|
* @param tag
|
||||||
* @param file Input stream
|
* Constant type tag
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ConstantCP(byte tag, DataInputStream file) throws IOException {
|
ConstantCP(byte tag, DataInputStream file) throws IOException {
|
||||||
this(tag, file.readUnsignedShort(), file.readUnsignedShort());
|
this(tag, file.readUnsignedShort(), file.readUnsignedShort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param class_index Reference to the class containing the field
|
* @param class_index
|
||||||
* @param name_and_type_index and the field signature
|
* Reference to the class containing the field
|
||||||
|
* @param name_and_type_index
|
||||||
|
* and the field signature
|
||||||
*/
|
*/
|
||||||
protected ConstantCP(byte tag, int class_index, int name_and_type_index) {
|
protected ConstantCP(byte tag, int class_index, int name_and_type_index) {
|
||||||
super(tag);
|
super(tag);
|
||||||
@ -67,20 +73,20 @@ public abstract class ConstantCP extends Constant {
|
|||||||
this.name_and_type_index = name_and_type_index;
|
this.name_and_type_index = name_and_type_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump constant field reference to file stream in binary format.
|
* Dump constant field reference to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
file.writeByte(tag);
|
file.writeByte(tag);
|
||||||
file.writeShort(class_index);
|
file.writeShort(class_index);
|
||||||
file.writeShort(name_and_type_index);
|
file.writeShort(name_and_type_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Reference (index) to class this field or method belongs to.
|
* @return Reference (index) to class this field or method belongs to.
|
||||||
*/
|
*/
|
||||||
@ -88,7 +94,6 @@ public abstract class ConstantCP extends Constant {
|
|||||||
return class_index;
|
return class_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Reference (index) to signature of the field.
|
* @return Reference (index) to signature of the field.
|
||||||
*/
|
*/
|
||||||
@ -96,15 +101,14 @@ public abstract class ConstantCP extends Constant {
|
|||||||
return name_and_type_index;
|
return name_and_type_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param class_index points to Constant_class
|
* @param class_index
|
||||||
|
* points to Constant_class
|
||||||
*/
|
*/
|
||||||
public final void setClassIndex(int class_index) {
|
public final void setClassIndex(int class_index) {
|
||||||
this.class_index = class_index;
|
this.class_index = class_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Class this field belongs to.
|
* @return Class this field belongs to.
|
||||||
*/
|
*/
|
||||||
@ -112,20 +116,20 @@ public abstract class ConstantCP extends Constant {
|
|||||||
return cp.constantToString(class_index, Constants.CONSTANT_Class);
|
return cp.constantToString(class_index, Constants.CONSTANT_Class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_and_type_index points to Constant_NameAndType
|
* @param name_and_type_index
|
||||||
|
* points to Constant_NameAndType
|
||||||
*/
|
*/
|
||||||
public final void setNameAndTypeIndex(int name_and_type_index) {
|
public final void setNameAndTypeIndex(int name_and_type_index) {
|
||||||
this.name_and_type_index = name_and_type_index;
|
this.name_and_type_index = name_and_type_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return super.toString() + "(class_index = " + class_index + ", name_and_type_index = "
|
return super.toString() + "(class_index = " + class_index
|
||||||
+ name_and_type_index + ")";
|
+ ", name_and_type_index = " + name_and_type_index + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from the abstract
|
* This class is derived from the abstract <A
|
||||||
* <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
|
* HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class and
|
||||||
* and represents a reference to a (external) class.
|
* represents a reference to a (external) class.
|
||||||
*
|
*
|
||||||
* @version $Id: ConstantClass.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConstantClass.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -32,9 +32,12 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class ConstantClass extends Constant implements ConstantObject {
|
public final class ConstantClass extends Constant implements ConstantObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int name_index; // Identical to ConstantString except for the name
|
private int name_index; // Identical to ConstantString except for the name
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object.
|
* Initialize from another object.
|
||||||
*/
|
*/
|
||||||
@ -42,52 +45,52 @@ public final class ConstantClass extends Constant implements ConstantObject {
|
|||||||
this(c.getNameIndex());
|
this(c.getNameIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize instance from file data.
|
* Initialize instance from file data.
|
||||||
*
|
*
|
||||||
* @param file Input stream
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ConstantClass(DataInputStream file) throws IOException {
|
ConstantClass(DataInputStream file) throws IOException {
|
||||||
this(file.readUnsignedShort());
|
this(file.readUnsignedShort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index Name index in constant pool. Should refer to a
|
* @param name_index
|
||||||
* ConstantUtf8.
|
* Name index in constant pool. Should refer to a ConstantUtf8.
|
||||||
*/
|
*/
|
||||||
public ConstantClass(int name_index) {
|
public ConstantClass(int name_index) {
|
||||||
super(Constants.CONSTANT_Class);
|
super(Constants.CONSTANT_Class);
|
||||||
this.name_index = name_index;
|
this.name_index = name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitConstantClass(this);
|
v.visitConstantClass(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump constant class to file stream in binary format.
|
* Dump constant class to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
file.writeByte(tag);
|
file.writeByte(tag);
|
||||||
file.writeShort(name_index);
|
file.writeShort(name_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Name index in constant pool of class name.
|
* @return Name index in constant pool of class name.
|
||||||
*/
|
*/
|
||||||
@ -95,33 +98,34 @@ public final class ConstantClass extends Constant implements ConstantObject {
|
|||||||
return name_index;
|
return name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index the name index in the constant pool of this Constant Class
|
* @param name_index
|
||||||
|
* the name index in the constant pool of this Constant Class
|
||||||
*/
|
*/
|
||||||
public final void setNameIndex(int name_index) {
|
public final void setNameIndex(int name_index) {
|
||||||
this.name_index = name_index;
|
this.name_index = name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return String object
|
* @return String object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object getConstantValue(ConstantPool cp) {
|
public Object getConstantValue(ConstantPool cp) {
|
||||||
Constant c = cp.getConstant(name_index, Constants.CONSTANT_Utf8);
|
Constant c = cp.getConstant(name_index, Constants.CONSTANT_Utf8);
|
||||||
return ((ConstantUtf8) c).getBytes();
|
return ((ConstantUtf8) c).getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return dereferenced string
|
* @return dereferenced string
|
||||||
*/
|
*/
|
||||||
public String getBytes(ConstantPool cp) {
|
public String getBytes(ConstantPool cp) {
|
||||||
return (String) getConstantValue(cp);
|
return (String) getConstantValue(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return super.toString() + "(name_index = " + name_index + ")";
|
return super.toString() + "(name_index = " + name_index + ")";
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from the abstract
|
* This class is derived from the abstract <A
|
||||||
* <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
|
* HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class and
|
||||||
* and represents a reference to a Double object.
|
* represents a reference to a Double object.
|
||||||
*
|
*
|
||||||
* @version $Id: ConstantDouble.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConstantDouble.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -32,18 +32,21 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class ConstantDouble extends Constant implements ConstantObject {
|
public final class ConstantDouble extends Constant implements ConstantObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private double bytes;
|
private double bytes;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bytes Data
|
* @param bytes
|
||||||
|
* Data
|
||||||
*/
|
*/
|
||||||
public ConstantDouble(double bytes) {
|
public ConstantDouble(double bytes) {
|
||||||
super(Constants.CONSTANT_Double);
|
super(Constants.CONSTANT_Double);
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object.
|
* Initialize from another object.
|
||||||
*/
|
*/
|
||||||
@ -51,42 +54,43 @@ public final class ConstantDouble extends Constant implements ConstantObject {
|
|||||||
this(c.getBytes());
|
this(c.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize instance from file data.
|
* Initialize instance from file data.
|
||||||
*
|
*
|
||||||
* @param file Input stream
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ConstantDouble(DataInputStream file) throws IOException {
|
ConstantDouble(DataInputStream file) throws IOException {
|
||||||
this(file.readDouble());
|
this(file.readDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitConstantDouble(this);
|
v.visitConstantDouble(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump constant double to file stream in binary format.
|
* Dump constant double to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
file.writeByte(tag);
|
file.writeByte(tag);
|
||||||
file.writeDouble(bytes);
|
file.writeDouble(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return data, i.e., 8 bytes.
|
* @return data, i.e., 8 bytes.
|
||||||
*/
|
*/
|
||||||
@ -94,25 +98,26 @@ public final class ConstantDouble extends Constant implements ConstantObject {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bytes the raw bytes that represent the double value
|
* @param bytes
|
||||||
|
* the raw bytes that represent the double value
|
||||||
*/
|
*/
|
||||||
public final void setBytes(double bytes) {
|
public final void setBytes(double bytes) {
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return super.toString() + "(bytes = " + bytes + ")";
|
return super.toString() + "(bytes = " + bytes + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return Double object
|
* @return Double object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object getConstantValue(ConstantPool cp) {
|
public Object getConstantValue(ConstantPool cp) {
|
||||||
return new Double(bytes);
|
return new Double(bytes);
|
||||||
}
|
}
|
||||||
|
@ -28,41 +28,49 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class ConstantFieldref extends ConstantCP {
|
public final class ConstantFieldref extends ConstantCP {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object.
|
* Initialize from another object.
|
||||||
*/
|
*/
|
||||||
public ConstantFieldref(ConstantFieldref c) {
|
public ConstantFieldref(ConstantFieldref c) {
|
||||||
super(Constants.CONSTANT_Fieldref, c.getClassIndex(), c.getNameAndTypeIndex());
|
super(Constants.CONSTANT_Fieldref, c.getClassIndex(), c
|
||||||
|
.getNameAndTypeIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize instance from file data.
|
* Initialize instance from file data.
|
||||||
*
|
*
|
||||||
* @param file input stream
|
* @param file
|
||||||
|
* input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ConstantFieldref(DataInputStream file) throws IOException {
|
ConstantFieldref(DataInputStream file) throws IOException {
|
||||||
super(Constants.CONSTANT_Fieldref, file);
|
super(Constants.CONSTANT_Fieldref, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param class_index Reference to the class containing the Field
|
* @param class_index
|
||||||
* @param name_and_type_index and the Field signature
|
* 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) {
|
public ConstantFieldref(int class_index, int name_and_type_index) {
|
||||||
super(Constants.CONSTANT_Fieldref, class_index, 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
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of Fields,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitConstantFieldref(this);
|
v.visitConstantFieldref(this);
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from the abstract
|
* This class is derived from the abstract <A
|
||||||
* <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
|
* HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class and
|
||||||
* and represents a reference to a float object.
|
* represents a reference to a float object.
|
||||||
*
|
*
|
||||||
* @version $Id: ConstantFloat.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConstantFloat.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -32,18 +32,21 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class ConstantFloat extends Constant implements ConstantObject {
|
public final class ConstantFloat extends Constant implements ConstantObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private float bytes;
|
private float bytes;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bytes Data
|
* @param bytes
|
||||||
|
* Data
|
||||||
*/
|
*/
|
||||||
public ConstantFloat(float bytes) {
|
public ConstantFloat(float bytes) {
|
||||||
super(Constants.CONSTANT_Float);
|
super(Constants.CONSTANT_Float);
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use clone() for a physical copy.
|
* references (shallow copy). Use clone() for a physical copy.
|
||||||
@ -52,42 +55,43 @@ public final class ConstantFloat extends Constant implements ConstantObject {
|
|||||||
this(c.getBytes());
|
this(c.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize instance from file data.
|
* Initialize instance from file data.
|
||||||
*
|
*
|
||||||
* @param file Input stream
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ConstantFloat(DataInputStream file) throws IOException {
|
ConstantFloat(DataInputStream file) throws IOException {
|
||||||
this(file.readFloat());
|
this(file.readFloat());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitConstantFloat(this);
|
v.visitConstantFloat(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump constant float to file stream in binary format.
|
* Dump constant float to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
file.writeByte(tag);
|
file.writeByte(tag);
|
||||||
file.writeFloat(bytes);
|
file.writeFloat(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return data, i.e., 4 bytes.
|
* @return data, i.e., 4 bytes.
|
||||||
*/
|
*/
|
||||||
@ -95,25 +99,26 @@ public final class ConstantFloat extends Constant implements ConstantObject {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bytes the raw bytes that represent this float
|
* @param bytes
|
||||||
|
* the raw bytes that represent this float
|
||||||
*/
|
*/
|
||||||
public final void setBytes(float bytes) {
|
public final void setBytes(float bytes) {
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return super.toString() + "(bytes = " + bytes + ")";
|
return super.toString() + "(bytes = " + bytes + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return Float object
|
* @return Float object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object getConstantValue(ConstantPool cp) {
|
public Object getConstantValue(ConstantPool cp) {
|
||||||
return new Float(bytes);
|
return new Float(bytes);
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from the abstract
|
* This class is derived from the abstract <A
|
||||||
* <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
|
* HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class and
|
||||||
* and represents a reference to an int object.
|
* represents a reference to an int object.
|
||||||
*
|
*
|
||||||
* @version $Id: ConstantInteger.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConstantInteger.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -32,18 +32,21 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class ConstantInteger extends Constant implements ConstantObject {
|
public final class ConstantInteger extends Constant implements ConstantObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int bytes;
|
private int bytes;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bytes Data
|
* @param bytes
|
||||||
|
* Data
|
||||||
*/
|
*/
|
||||||
public ConstantInteger(int bytes) {
|
public ConstantInteger(int bytes) {
|
||||||
super(Constants.CONSTANT_Integer);
|
super(Constants.CONSTANT_Integer);
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object.
|
* Initialize from another object.
|
||||||
*/
|
*/
|
||||||
@ -51,42 +54,43 @@ public final class ConstantInteger extends Constant implements ConstantObject {
|
|||||||
this(c.getBytes());
|
this(c.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize instance from file data.
|
* Initialize instance from file data.
|
||||||
*
|
*
|
||||||
* @param file Input stream
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ConstantInteger(DataInputStream file) throws IOException {
|
ConstantInteger(DataInputStream file) throws IOException {
|
||||||
this(file.readInt());
|
this(file.readInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitConstantInteger(this);
|
v.visitConstantInteger(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump constant integer to file stream in binary format.
|
* Dump constant integer to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
file.writeByte(tag);
|
file.writeByte(tag);
|
||||||
file.writeInt(bytes);
|
file.writeInt(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return data, i.e., 4 bytes.
|
* @return data, i.e., 4 bytes.
|
||||||
*/
|
*/
|
||||||
@ -94,25 +98,26 @@ public final class ConstantInteger extends Constant implements ConstantObject {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bytes the raw bytes that represent this integer
|
* @param bytes
|
||||||
|
* the raw bytes that represent this integer
|
||||||
*/
|
*/
|
||||||
public final void setBytes(int bytes) {
|
public final void setBytes(int bytes) {
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return super.toString() + "(bytes = " + bytes + ")";
|
return super.toString() + "(bytes = " + bytes + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return Integer object
|
* @return Integer object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object getConstantValue(ConstantPool cp) {
|
public Object getConstantValue(ConstantPool cp) {
|
||||||
return new Integer(bytes);
|
return new Integer(bytes);
|
||||||
}
|
}
|
||||||
|
@ -23,46 +23,56 @@ import org.apache.bcel.Constants;
|
|||||||
/**
|
/**
|
||||||
* This class represents a constant pool reference to an interface method.
|
* This class represents a constant pool reference to an interface method.
|
||||||
*
|
*
|
||||||
* @version $Id: ConstantInterfaceMethodref.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConstantInterfaceMethodref.java 386056 2006-03-15 11:31:56Z
|
||||||
|
* tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public final class ConstantInterfaceMethodref extends ConstantCP {
|
public final class ConstantInterfaceMethodref extends ConstantCP {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object.
|
* Initialize from another object.
|
||||||
*/
|
*/
|
||||||
public ConstantInterfaceMethodref(ConstantInterfaceMethodref c) {
|
public ConstantInterfaceMethodref(ConstantInterfaceMethodref c) {
|
||||||
super(Constants.CONSTANT_InterfaceMethodref, c.getClassIndex(), c.getNameAndTypeIndex());
|
super(Constants.CONSTANT_InterfaceMethodref, c.getClassIndex(), c
|
||||||
|
.getNameAndTypeIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize instance from file data.
|
* Initialize instance from file data.
|
||||||
*
|
*
|
||||||
* @param file input stream
|
* @param file
|
||||||
|
* input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ConstantInterfaceMethodref(DataInputStream file) throws IOException {
|
ConstantInterfaceMethodref(DataInputStream file) throws IOException {
|
||||||
super(Constants.CONSTANT_InterfaceMethodref, file);
|
super(Constants.CONSTANT_InterfaceMethodref, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param class_index Reference to the class containing the method
|
* @param class_index
|
||||||
* @param name_and_type_index and the method signature
|
* 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) {
|
public ConstantInterfaceMethodref(int class_index, int name_and_type_index) {
|
||||||
super(Constants.CONSTANT_InterfaceMethodref, class_index, 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
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitConstantInterfaceMethodref(this);
|
v.visitConstantInterfaceMethodref(this);
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from the abstract
|
* This class is derived from the abstract <A
|
||||||
* <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
|
* HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class and
|
||||||
* and represents a reference to a long object.
|
* represents a reference to a long object.
|
||||||
*
|
*
|
||||||
* @version $Id: ConstantLong.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConstantLong.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -32,18 +32,21 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class ConstantLong extends Constant implements ConstantObject {
|
public final class ConstantLong extends Constant implements ConstantObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private long bytes;
|
private long bytes;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bytes Data
|
* @param bytes
|
||||||
|
* Data
|
||||||
*/
|
*/
|
||||||
public ConstantLong(long bytes) {
|
public ConstantLong(long bytes) {
|
||||||
super(Constants.CONSTANT_Long);
|
super(Constants.CONSTANT_Long);
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object.
|
* Initialize from another object.
|
||||||
*/
|
*/
|
||||||
@ -51,42 +54,43 @@ public final class ConstantLong extends Constant implements ConstantObject {
|
|||||||
this(c.getBytes());
|
this(c.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize instance from file data.
|
* Initialize instance from file data.
|
||||||
*
|
*
|
||||||
* @param file Input stream
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ConstantLong(DataInputStream file) throws IOException {
|
ConstantLong(DataInputStream file) throws IOException {
|
||||||
this(file.readLong());
|
this(file.readLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitConstantLong(this);
|
v.visitConstantLong(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump constant long to file stream in binary format.
|
* Dump constant long to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
file.writeByte(tag);
|
file.writeByte(tag);
|
||||||
file.writeLong(bytes);
|
file.writeLong(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return data, i.e., 8 bytes.
|
* @return data, i.e., 8 bytes.
|
||||||
*/
|
*/
|
||||||
@ -94,25 +98,26 @@ public final class ConstantLong extends Constant implements ConstantObject {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bytes thr raw bytes that represent this long
|
* @param bytes
|
||||||
|
* thr raw bytes that represent this long
|
||||||
*/
|
*/
|
||||||
public final void setBytes(long bytes) {
|
public final void setBytes(long bytes) {
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return super.toString() + "(bytes = " + bytes + ")";
|
return super.toString() + "(bytes = " + bytes + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return Long object
|
* @return Long object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object getConstantValue(ConstantPool cp) {
|
public Object getConstantValue(ConstantPool cp) {
|
||||||
return new Long(bytes);
|
return new Long(bytes);
|
||||||
}
|
}
|
||||||
|
@ -28,41 +28,49 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class ConstantMethodref extends ConstantCP {
|
public final class ConstantMethodref extends ConstantCP {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object.
|
* Initialize from another object.
|
||||||
*/
|
*/
|
||||||
public ConstantMethodref(ConstantMethodref c) {
|
public ConstantMethodref(ConstantMethodref c) {
|
||||||
super(Constants.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex());
|
super(Constants.CONSTANT_Methodref, c.getClassIndex(), c
|
||||||
|
.getNameAndTypeIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize instance from file data.
|
* Initialize instance from file data.
|
||||||
*
|
*
|
||||||
* @param file input stream
|
* @param file
|
||||||
|
* input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ConstantMethodref(DataInputStream file) throws IOException {
|
ConstantMethodref(DataInputStream file) throws IOException {
|
||||||
super(Constants.CONSTANT_Methodref, file);
|
super(Constants.CONSTANT_Methodref, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param class_index Reference to the class containing the method
|
* @param class_index
|
||||||
* @param name_and_type_index and the method signature
|
* 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) {
|
public ConstantMethodref(int class_index, int name_and_type_index) {
|
||||||
super(Constants.CONSTANT_Methodref, class_index, 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
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitConstantMethodref(this);
|
v.visitConstantMethodref(this);
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,9 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from the abstract
|
* This class is derived from the abstract <A
|
||||||
* <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
|
* HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class and
|
||||||
* and represents a reference to the name and signature
|
* represents a reference to the name and signature of a field or method.
|
||||||
* of a field or method.
|
|
||||||
*
|
*
|
||||||
* @version $Id: ConstantNameAndType.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConstantNameAndType.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -33,10 +32,13 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class ConstantNameAndType extends Constant {
|
public final class ConstantNameAndType extends Constant {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int name_index; // Name of field/method
|
private int name_index; // Name of field/method
|
||||||
private int signature_index; // and its signature.
|
private int signature_index; // and its signature.
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object.
|
* Initialize from another object.
|
||||||
*/
|
*/
|
||||||
@ -44,21 +46,22 @@ public final class ConstantNameAndType extends Constant {
|
|||||||
this(c.getNameIndex(), c.getSignatureIndex());
|
this(c.getNameIndex(), c.getSignatureIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize instance from file data.
|
* Initialize instance from file data.
|
||||||
*
|
*
|
||||||
* @param file Input stream
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ConstantNameAndType(DataInputStream file) throws IOException {
|
ConstantNameAndType(DataInputStream file) throws IOException {
|
||||||
this(file.readUnsignedShort(), file.readUnsignedShort());
|
this(file.readUnsignedShort(), file.readUnsignedShort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index Name of field/method
|
* @param name_index
|
||||||
* @param signature_index and its signature
|
* Name of field/method
|
||||||
|
* @param signature_index
|
||||||
|
* and its signature
|
||||||
*/
|
*/
|
||||||
public ConstantNameAndType(int name_index, int signature_index) {
|
public ConstantNameAndType(int name_index, int signature_index) {
|
||||||
super(Constants.CONSTANT_NameAndType);
|
super(Constants.CONSTANT_NameAndType);
|
||||||
@ -66,32 +69,33 @@ public final class ConstantNameAndType extends Constant {
|
|||||||
this.signature_index = signature_index;
|
this.signature_index = signature_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitConstantNameAndType(this);
|
v.visitConstantNameAndType(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump name and signature index to file stream in binary format.
|
* Dump name and signature index to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
file.writeByte(tag);
|
file.writeByte(tag);
|
||||||
file.writeShort(name_index);
|
file.writeShort(name_index);
|
||||||
file.writeShort(signature_index);
|
file.writeShort(signature_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Name index in constant pool of field/method name.
|
* @return Name index in constant pool of field/method name.
|
||||||
*/
|
*/
|
||||||
@ -99,14 +103,13 @@ public final class ConstantNameAndType extends Constant {
|
|||||||
return name_index;
|
return name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return name
|
* @return name
|
||||||
*/
|
*/
|
||||||
public final String getName(ConstantPool cp) {
|
public final String getName(ConstantPool cp) {
|
||||||
return cp.constantToString(getNameIndex(), Constants.CONSTANT_Utf8);
|
return cp.constantToString(getNameIndex(), Constants.CONSTANT_Utf8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Index in constant pool of field/method signature.
|
* @return Index in constant pool of field/method signature.
|
||||||
*/
|
*/
|
||||||
@ -114,35 +117,36 @@ public final class ConstantNameAndType extends Constant {
|
|||||||
return signature_index;
|
return signature_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return signature
|
* @return signature
|
||||||
*/
|
*/
|
||||||
public final String getSignature(ConstantPool cp) {
|
public final String getSignature(ConstantPool cp) {
|
||||||
return cp.constantToString(getSignatureIndex(), Constants.CONSTANT_Utf8);
|
return cp
|
||||||
|
.constantToString(getSignatureIndex(), Constants.CONSTANT_Utf8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index the name index of this constant
|
* @param name_index
|
||||||
|
* the name index of this constant
|
||||||
*/
|
*/
|
||||||
public final void setNameIndex(int name_index) {
|
public final void setNameIndex(int name_index) {
|
||||||
this.name_index = name_index;
|
this.name_index = name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param signature_index the signature index in the constant pool of this type
|
* @param signature_index
|
||||||
|
* the signature index in the constant pool of this type
|
||||||
*/
|
*/
|
||||||
public final void setSignatureIndex(int signature_index) {
|
public final void setSignatureIndex(int signature_index) {
|
||||||
this.signature_index = signature_index;
|
this.signature_index = signature_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation
|
* @return String representation
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return super.toString() + "(name_index = " + name_index + ", signature_index = "
|
return super.toString() + "(name_index = " + name_index
|
||||||
+ signature_index + ")";
|
+ ", signature_index = " + signature_index + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
package org.apache.bcel.classfile;
|
package org.apache.bcel.classfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface denotes those constants that have a "natural" value,
|
* This interface denotes those constants that have a "natural" value, such as
|
||||||
* such as ConstantLong, ConstantString, etc..
|
* ConstantLong, ConstantString, etc..
|
||||||
*
|
*
|
||||||
* @version $Id: ConstantObject.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConstantObject.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -26,7 +26,8 @@ package org.apache.bcel.classfile;
|
|||||||
*/
|
*/
|
||||||
public interface ConstantObject {
|
public interface ConstantObject {
|
||||||
|
|
||||||
/** @return object representing the constant, e.g., Long for ConstantLong
|
/**
|
||||||
|
* @return object representing the constant, e.g., Long for ConstantLong
|
||||||
*/
|
*/
|
||||||
public abstract Object getConstantValue(ConstantPool cp);
|
public abstract Object getConstantValue(ConstantPool cp);
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,12 @@ import java.io.Serializable;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the constant pool, i.e., a table of constants, of
|
* This class represents the constant pool, i.e., a table of constants, of a
|
||||||
* a parsed classfile. It may contain null references, due to the JVM
|
* parsed classfile. It may contain null references, due to the JVM
|
||||||
* specification that skips an entry after an 8-byte constant (double,
|
* specification that skips an entry after an 8-byte constant (double, long)
|
||||||
* long) entry. Those interested in generating constant pools
|
* entry. Those interested in generating constant pools programatically should
|
||||||
* programatically should see <a href="../generic/ConstantPoolGen.html">
|
* see <a href="../generic/ConstantPoolGen.html"> ConstantPoolGen</a>.
|
||||||
* ConstantPoolGen</a>.
|
*
|
||||||
|
|
||||||
* @version $Id: ConstantPool.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConstantPool.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @see Constant
|
* @see Constant
|
||||||
* @see org.apache.bcel.generic.ConstantPoolGen
|
* @see org.apache.bcel.generic.ConstantPoolGen
|
||||||
@ -37,22 +36,26 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public class ConstantPool implements Cloneable, Node, Serializable {
|
public class ConstantPool implements Cloneable, Node, Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int constant_pool_count;
|
private int constant_pool_count;
|
||||||
private Constant[] constant_pool;
|
private Constant[] constant_pool;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param constant_pool Array of constants
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
public ConstantPool(Constant[] constant_pool) {
|
public ConstantPool(Constant[] constant_pool) {
|
||||||
setConstantPool(constant_pool);
|
setConstantPool(constant_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read constants from given file stream.
|
* Read constants from given file stream.
|
||||||
*
|
*
|
||||||
* @param file Input stream
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassFormatException
|
* @throws ClassFormatException
|
||||||
*/
|
*/
|
||||||
@ -60,42 +63,45 @@ public class ConstantPool implements Cloneable, Node, Serializable {
|
|||||||
byte tag;
|
byte tag;
|
||||||
constant_pool_count = file.readUnsignedShort();
|
constant_pool_count = file.readUnsignedShort();
|
||||||
constant_pool = new Constant[constant_pool_count];
|
constant_pool = new Constant[constant_pool_count];
|
||||||
/* constant_pool[0] is unused by the compiler and may be used freely
|
/*
|
||||||
* by the implementation.
|
* constant_pool[0] is unused by the compiler and may be used freely by
|
||||||
|
* the implementation.
|
||||||
*/
|
*/
|
||||||
for (int i = 1; i < constant_pool_count; i++) {
|
for (int i = 1; i < constant_pool_count; i++) {
|
||||||
constant_pool[i] = Constant.readConstant(file);
|
constant_pool[i] = Constant.readConstant(file);
|
||||||
/* Quote from the JVM specification:
|
/*
|
||||||
* "All eight byte constants take up two spots in the constant pool.
|
* Quote from the JVM specification: "All eight byte constants take
|
||||||
* If this is the n'th byte in the constant pool, then the next item
|
* up two spots in the constant pool. If this is the n'th byte in
|
||||||
* will be numbered n+2"
|
* the constant pool, then the next item will be numbered n+2"
|
||||||
*
|
*
|
||||||
* Thus we have to increment the index counter.
|
* Thus we have to increment the index counter.
|
||||||
*/
|
*/
|
||||||
tag = constant_pool[i].getTag();
|
tag = constant_pool[i].getTag();
|
||||||
if ((tag == Constants.CONSTANT_Double) || (tag == Constants.CONSTANT_Long)) {
|
if ((tag == Constants.CONSTANT_Double)
|
||||||
|
|| (tag == Constants.CONSTANT_Long)) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitConstantPool(this);
|
v.visitConstantPool(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve constant to a string representation.
|
* Resolve constant to a string representation.
|
||||||
*
|
*
|
||||||
* @param c Constant to be printed
|
* @param c
|
||||||
|
* Constant to be printed
|
||||||
* @return String representation
|
* @return String representation
|
||||||
*/
|
*/
|
||||||
public String constantToString(Constant c) throws ClassFormatException {
|
public String constantToString(Constant c) throws ClassFormatException {
|
||||||
@ -106,7 +112,8 @@ public class ConstantPool implements Cloneable, Node, Serializable {
|
|||||||
case Constants.CONSTANT_Class:
|
case Constants.CONSTANT_Class:
|
||||||
i = ((ConstantClass) c).getNameIndex();
|
i = ((ConstantClass) c).getNameIndex();
|
||||||
c = getConstant(i, Constants.CONSTANT_Utf8);
|
c = getConstant(i, Constants.CONSTANT_Utf8);
|
||||||
str = Utility.compactClassName(((ConstantUtf8) c).getBytes(), false);
|
str = Utility
|
||||||
|
.compactClassName(((ConstantUtf8) c).getBytes(), false);
|
||||||
break;
|
break;
|
||||||
case Constants.CONSTANT_String:
|
case Constants.CONSTANT_String:
|
||||||
i = ((ConstantString) c).getStringIndex();
|
i = ((ConstantString) c).getStringIndex();
|
||||||
@ -130,15 +137,16 @@ public class ConstantPool implements Cloneable, Node, Serializable {
|
|||||||
break;
|
break;
|
||||||
case Constants.CONSTANT_NameAndType:
|
case Constants.CONSTANT_NameAndType:
|
||||||
str = (constantToString(((ConstantNameAndType) c).getNameIndex(),
|
str = (constantToString(((ConstantNameAndType) c).getNameIndex(),
|
||||||
Constants.CONSTANT_Utf8)
|
Constants.CONSTANT_Utf8) + " " + constantToString(
|
||||||
+ " " + constantToString(((ConstantNameAndType) c).getSignatureIndex(),
|
((ConstantNameAndType) c).getSignatureIndex(),
|
||||||
Constants.CONSTANT_Utf8));
|
Constants.CONSTANT_Utf8));
|
||||||
break;
|
break;
|
||||||
case Constants.CONSTANT_InterfaceMethodref:
|
case Constants.CONSTANT_InterfaceMethodref:
|
||||||
case Constants.CONSTANT_Methodref:
|
case Constants.CONSTANT_Methodref:
|
||||||
case Constants.CONSTANT_Fieldref:
|
case Constants.CONSTANT_Fieldref:
|
||||||
str = (constantToString(((ConstantCP) c).getClassIndex(), Constants.CONSTANT_Class)
|
str = (constantToString(((ConstantCP) c).getClassIndex(),
|
||||||
+ "." + constantToString(((ConstantCP) c).getNameAndTypeIndex(),
|
Constants.CONSTANT_Class) + "." + constantToString(
|
||||||
|
((ConstantCP) c).getNameAndTypeIndex(),
|
||||||
Constants.CONSTANT_NameAndType));
|
Constants.CONSTANT_NameAndType));
|
||||||
break;
|
break;
|
||||||
default: // Never reached
|
default: // Never reached
|
||||||
@ -147,7 +155,6 @@ public class ConstantPool implements Cloneable, Node, Serializable {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final String escape(String str) {
|
private static final String escape(String str) {
|
||||||
int len = str.length();
|
int len = str.length();
|
||||||
StringBuffer buf = new StringBuffer(len + 5);
|
StringBuffer buf = new StringBuffer(len + 5);
|
||||||
@ -176,25 +183,27 @@ public class ConstantPool implements Cloneable, Node, Serializable {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve constant at `index' from constant pool and resolve it to
|
* Retrieve constant at `index' from constant pool and resolve it to a
|
||||||
* a string representation.
|
* string representation.
|
||||||
*
|
*
|
||||||
* @param index of constant in constant pool
|
* @param index
|
||||||
* @param tag expected type
|
* of constant in constant pool
|
||||||
|
* @param tag
|
||||||
|
* expected type
|
||||||
* @return String representation
|
* @return String representation
|
||||||
*/
|
*/
|
||||||
public String constantToString( int index, byte tag ) throws ClassFormatException {
|
public String constantToString(int index, byte tag)
|
||||||
|
throws ClassFormatException {
|
||||||
Constant c = getConstant(index, tag);
|
Constant c = getConstant(index, tag);
|
||||||
return constantToString(c);
|
return constantToString(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump constant pool to file stream in binary format.
|
* Dump constant pool to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void dump(DataOutputStream file) throws IOException {
|
public void dump(DataOutputStream file) throws IOException {
|
||||||
@ -206,47 +215,51 @@ public class ConstantPool implements Cloneable, Node, Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get constant from constant pool.
|
* Get constant from constant pool.
|
||||||
*
|
*
|
||||||
* @param index Index in constant pool
|
* @param index
|
||||||
|
* Index in constant pool
|
||||||
* @return Constant value
|
* @return Constant value
|
||||||
* @see Constant
|
* @see Constant
|
||||||
*/
|
*/
|
||||||
public Constant getConstant(int index) {
|
public Constant getConstant(int index) {
|
||||||
if (index >= constant_pool.length || index < 0) {
|
if (index >= constant_pool.length || index < 0) {
|
||||||
throw new ClassFormatException("Invalid constant pool reference: " + index
|
throw new ClassFormatException("Invalid constant pool reference: "
|
||||||
+ ". Constant pool size is: " + constant_pool.length);
|
+ index + ". Constant pool size is: "
|
||||||
|
+ constant_pool.length);
|
||||||
}
|
}
|
||||||
return constant_pool[index];
|
return constant_pool[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get constant from constant pool and check whether it has the
|
* Get constant from constant pool and check whether it has the expected
|
||||||
* expected type.
|
* type.
|
||||||
*
|
*
|
||||||
* @param index Index in constant pool
|
* @param index
|
||||||
* @param tag Tag of expected constant, i.e., its type
|
* Index in constant pool
|
||||||
|
* @param tag
|
||||||
|
* Tag of expected constant, i.e., its type
|
||||||
* @return Constant value
|
* @return Constant value
|
||||||
* @see Constant
|
* @see Constant
|
||||||
* @throws ClassFormatException
|
* @throws ClassFormatException
|
||||||
*/
|
*/
|
||||||
public Constant getConstant( int index, byte tag ) throws ClassFormatException {
|
public Constant getConstant(int index, byte tag)
|
||||||
|
throws ClassFormatException {
|
||||||
Constant c;
|
Constant c;
|
||||||
c = getConstant(index);
|
c = getConstant(index);
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
throw new ClassFormatException("Constant pool at index " + index + " is null.");
|
throw new ClassFormatException("Constant pool at index " + index
|
||||||
|
+ " is null.");
|
||||||
}
|
}
|
||||||
if (c.getTag() != tag) {
|
if (c.getTag() != tag) {
|
||||||
throw new ClassFormatException("Expected class `" + Constants.CONSTANT_NAMES[tag]
|
throw new ClassFormatException("Expected class `"
|
||||||
+ "' at index " + index + " and got " + c);
|
+ Constants.CONSTANT_NAMES[tag] + "' at index " + index
|
||||||
|
+ " and got " + c);
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Array of constants.
|
* @return Array of constants.
|
||||||
* @see Constant
|
* @see Constant
|
||||||
@ -255,29 +268,32 @@ public class ConstantPool implements Cloneable, Node, Serializable {
|
|||||||
return constant_pool;
|
return constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get string from constant pool and bypass the indirection of
|
* Get string from constant pool and bypass the indirection of
|
||||||
* `ConstantClass' and `ConstantString' objects. I.e. these classes have
|
* `ConstantClass' and `ConstantString' objects. I.e. these classes have an
|
||||||
* an index field that points to another entry of the constant pool of
|
* index field that points to another entry of the constant pool of type
|
||||||
* type `ConstantUtf8' which contains the real data.
|
* `ConstantUtf8' which contains the real data.
|
||||||
*
|
*
|
||||||
* @param index Index in constant pool
|
* @param index
|
||||||
* @param tag Tag of expected constant, either ConstantClass or ConstantString
|
* Index in constant pool
|
||||||
|
* @param tag
|
||||||
|
* Tag of expected constant, either ConstantClass or
|
||||||
|
* ConstantString
|
||||||
* @return Contents of string reference
|
* @return Contents of string reference
|
||||||
* @see ConstantClass
|
* @see ConstantClass
|
||||||
* @see ConstantString
|
* @see ConstantString
|
||||||
* @throws ClassFormatException
|
* @throws ClassFormatException
|
||||||
*/
|
*/
|
||||||
public String getConstantString( int index, byte tag ) throws ClassFormatException {
|
public String getConstantString(int index, byte tag)
|
||||||
|
throws ClassFormatException {
|
||||||
Constant c;
|
Constant c;
|
||||||
int i;
|
int i;
|
||||||
c = getConstant(index, tag);
|
c = getConstant(index, tag);
|
||||||
/* This switch() is not that elegant, since the two classes have the
|
/*
|
||||||
* same contents, they just differ in the name of the index
|
* This switch() is not that elegant, since the two classes have the
|
||||||
* field variable.
|
* same contents, they just differ in the name of the index field
|
||||||
* But we want to stick to the JVM naming conventions closely though
|
* variable. But we want to stick to the JVM naming conventions closely
|
||||||
* we could have solved these more elegantly by using the same
|
* though we could have solved these more elegantly by using the same
|
||||||
* variable name or by subclassing.
|
* variable name or by subclassing.
|
||||||
*/
|
*/
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
@ -288,14 +304,14 @@ public class ConstantPool implements Cloneable, Node, Serializable {
|
|||||||
i = ((ConstantString) c).getStringIndex();
|
i = ((ConstantString) c).getStringIndex();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("getConstantString called with illegal tag " + tag);
|
throw new RuntimeException(
|
||||||
|
"getConstantString called with illegal tag " + tag);
|
||||||
}
|
}
|
||||||
// Finally get the string from the constant pool
|
// Finally get the string from the constant pool
|
||||||
c = getConstant(i, Constants.CONSTANT_Utf8);
|
c = getConstant(i, Constants.CONSTANT_Utf8);
|
||||||
return ((ConstantUtf8) c).getBytes();
|
return ((ConstantUtf8) c).getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Length of constant pool.
|
* @return Length of constant pool.
|
||||||
*/
|
*/
|
||||||
@ -303,27 +319,27 @@ public class ConstantPool implements Cloneable, Node, Serializable {
|
|||||||
return constant_pool_count;
|
return constant_pool_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param constant Constant to set
|
* @param constant
|
||||||
|
* Constant to set
|
||||||
*/
|
*/
|
||||||
public void setConstant(int index, Constant constant) {
|
public void setConstant(int index, Constant constant) {
|
||||||
constant_pool[index] = constant;
|
constant_pool[index] = constant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param constant_pool
|
* @param constant_pool
|
||||||
*/
|
*/
|
||||||
public void setConstantPool(Constant[] constant_pool) {
|
public void setConstantPool(Constant[] constant_pool) {
|
||||||
this.constant_pool = constant_pool;
|
this.constant_pool = constant_pool;
|
||||||
constant_pool_count = (constant_pool == null) ? 0 : constant_pool.length;
|
constant_pool_count = (constant_pool == null) ? 0
|
||||||
|
: constant_pool.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
for (int i = 1; i < constant_pool_count; i++) {
|
for (int i = 1; i < constant_pool_count; i++) {
|
||||||
@ -332,7 +348,6 @@ public class ConstantPool implements Cloneable, Node, Serializable {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this constant pool
|
* @return deep copy of this constant pool
|
||||||
*/
|
*/
|
||||||
|
@ -22,9 +22,9 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from the abstract
|
* This class is derived from the abstract <A
|
||||||
* <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
|
* HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class and
|
||||||
* and represents a reference to a String object.
|
* represents a reference to a String object.
|
||||||
*
|
*
|
||||||
* @version $Id: ConstantString.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConstantString.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -32,9 +32,12 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class ConstantString extends Constant implements ConstantObject {
|
public final class ConstantString extends Constant implements ConstantObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int string_index; // Identical to ConstantClass except for this name
|
private int string_index; // Identical to ConstantClass except for this name
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object.
|
* Initialize from another object.
|
||||||
*/
|
*/
|
||||||
@ -42,51 +45,52 @@ public final class ConstantString extends Constant implements ConstantObject {
|
|||||||
this(c.getStringIndex());
|
this(c.getStringIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize instance from file data.
|
* Initialize instance from file data.
|
||||||
*
|
*
|
||||||
* @param file Input stream
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ConstantString(DataInputStream file) throws IOException {
|
ConstantString(DataInputStream file) throws IOException {
|
||||||
this(file.readUnsignedShort());
|
this(file.readUnsignedShort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string_index Index of Constant_Utf8 in constant pool
|
* @param string_index
|
||||||
|
* Index of Constant_Utf8 in constant pool
|
||||||
*/
|
*/
|
||||||
public ConstantString(int string_index) {
|
public ConstantString(int string_index) {
|
||||||
super(Constants.CONSTANT_String);
|
super(Constants.CONSTANT_String);
|
||||||
this.string_index = string_index;
|
this.string_index = string_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitConstantString(this);
|
v.visitConstantString(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump constant field reference to file stream in binary format.
|
* Dump constant field reference to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
file.writeByte(tag);
|
file.writeByte(tag);
|
||||||
file.writeShort(string_index);
|
file.writeShort(string_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Index in constant pool of the string (ConstantUtf8).
|
* @return Index in constant pool of the string (ConstantUtf8).
|
||||||
*/
|
*/
|
||||||
@ -94,32 +98,33 @@ public final class ConstantString extends Constant implements ConstantObject {
|
|||||||
return string_index;
|
return string_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string_index the index into the constant of the string value
|
* @param string_index
|
||||||
|
* the index into the constant of the string value
|
||||||
*/
|
*/
|
||||||
public final void setStringIndex(int string_index) {
|
public final void setStringIndex(int string_index) {
|
||||||
this.string_index = string_index;
|
this.string_index = string_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return super.toString() + "(string_index = " + string_index + ")";
|
return super.toString() + "(string_index = " + string_index + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return String object
|
* @return String object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object getConstantValue(ConstantPool cp) {
|
public Object getConstantValue(ConstantPool cp) {
|
||||||
Constant c = cp.getConstant(string_index, Constants.CONSTANT_Utf8);
|
Constant c = cp.getConstant(string_index, Constants.CONSTANT_Utf8);
|
||||||
return ((ConstantUtf8) c).getBytes();
|
return ((ConstantUtf8) c).getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return dereferenced string
|
* @return dereferenced string
|
||||||
*/
|
*/
|
||||||
public String getBytes(ConstantPool cp) {
|
public String getBytes(ConstantPool cp) {
|
||||||
return (String) getConstantValue(cp);
|
return (String) getConstantValue(cp);
|
||||||
|
@ -22,9 +22,9 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from the abstract
|
* This class is derived from the abstract <A
|
||||||
* <A HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class
|
* HREF="org.apache.bcel.classfile.Constant.html">Constant</A> class and
|
||||||
* and represents a reference to a Utf8 encoded string.
|
* represents a reference to a Utf8 encoded string.
|
||||||
*
|
*
|
||||||
* @version $Id: ConstantUtf8.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConstantUtf8.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -32,9 +32,12 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class ConstantUtf8 extends Constant {
|
public final class ConstantUtf8 extends Constant {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private String bytes;
|
private String bytes;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object.
|
* Initialize from another object.
|
||||||
*/
|
*/
|
||||||
@ -42,11 +45,11 @@ public final class ConstantUtf8 extends Constant {
|
|||||||
this(c.getBytes());
|
this(c.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize instance from file data.
|
* Initialize instance from file data.
|
||||||
*
|
*
|
||||||
* @param file Input stream
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ConstantUtf8(DataInputStream file) throws IOException {
|
ConstantUtf8(DataInputStream file) throws IOException {
|
||||||
@ -54,9 +57,9 @@ public final class ConstantUtf8 extends Constant {
|
|||||||
bytes = file.readUTF();
|
bytes = file.readUTF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bytes Data
|
* @param bytes
|
||||||
|
* Data
|
||||||
*/
|
*/
|
||||||
public ConstantUtf8(String bytes) {
|
public ConstantUtf8(String bytes) {
|
||||||
super(Constants.CONSTANT_Utf8);
|
super(Constants.CONSTANT_Utf8);
|
||||||
@ -66,31 +69,32 @@ public final class ConstantUtf8 extends Constant {
|
|||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitConstantUtf8(this);
|
v.visitConstantUtf8(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump String in Utf8 format to file stream.
|
* Dump String in Utf8 format to file stream.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
file.writeByte(tag);
|
file.writeByte(tag);
|
||||||
file.writeUTF(bytes);
|
file.writeUTF(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Data converted to string.
|
* @return Data converted to string.
|
||||||
*/
|
*/
|
||||||
@ -98,19 +102,20 @@ public final class ConstantUtf8 extends Constant {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bytes the raw bytes of this Utf-8
|
* @param bytes
|
||||||
|
* the raw bytes of this Utf-8
|
||||||
*/
|
*/
|
||||||
public final void setBytes(String bytes) {
|
public final void setBytes(String bytes) {
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation
|
* @return String representation
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return super.toString() + "(\"" + Utility.replace(bytes, "\n", "\\n") + "\")";
|
return super.toString() + "(\"" + Utility.replace(bytes, "\n", "\\n")
|
||||||
|
+ "\")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ import org.apache.bcel.Constants;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from <em>Attribute</em> and represents a constant
|
* This class is derived from <em>Attribute</em> and represents a constant
|
||||||
* value, i.e., a default value for initializing a class field.
|
* value, i.e., a default value for initializing a class field. This class is
|
||||||
* This class is instantiated by the <em>Attribute.readAttribute()</em> method.
|
* instantiated by the <em>Attribute.readAttribute()</em> method.
|
||||||
*
|
*
|
||||||
* @version $Id: ConstantValue.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConstantValue.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -32,37 +32,48 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class ConstantValue extends Attribute {
|
public final class ConstantValue extends Attribute {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int constantvalue_index;
|
private int constantvalue_index;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use clone() for a physical copy.
|
* references (shallow copy). Use clone() for a physical copy.
|
||||||
*/
|
*/
|
||||||
public ConstantValue(ConstantValue c) {
|
public ConstantValue(ConstantValue c) {
|
||||||
this(c.getNameIndex(), c.getLength(), c.getConstantValueIndex(), c.getConstantPool());
|
this(c.getNameIndex(), c.getLength(), c.getConstantValueIndex(), c
|
||||||
|
.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param name_index Name index in constant pool
|
*
|
||||||
* @param length Content length in bytes
|
* @param name_index
|
||||||
* @param file Input stream
|
* Name index in constant pool
|
||||||
* @param constant_pool Array of constants
|
* @param length
|
||||||
|
* Content length in bytes
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ConstantValue(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
ConstantValue(int name_index, int length, DataInputStream file,
|
||||||
throws IOException {
|
ConstantPool constant_pool) throws IOException {
|
||||||
this(name_index, length, file.readUnsignedShort(), constant_pool);
|
this(name_index, length, file.readUnsignedShort(), constant_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index Name index in constant pool
|
* @param name_index
|
||||||
* @param length Content length in bytes
|
* Name index in constant pool
|
||||||
* @param constantvalue_index Index in constant pool
|
* @param length
|
||||||
* @param constant_pool Array of constants
|
* Content length in bytes
|
||||||
|
* @param constantvalue_index
|
||||||
|
* Index in constant pool
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
public ConstantValue(int name_index, int length, int constantvalue_index,
|
public ConstantValue(int name_index, int length, int constantvalue_index,
|
||||||
ConstantPool constant_pool) {
|
ConstantPool constant_pool) {
|
||||||
@ -70,31 +81,32 @@ public final class ConstantValue extends Attribute {
|
|||||||
this.constantvalue_index = constantvalue_index;
|
this.constantvalue_index = constantvalue_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitConstantValue(this);
|
v.visitConstantValue(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump constant value attribute to file stream on binary format.
|
* Dump constant value attribute to file stream on binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
super.dump(file);
|
super.dump(file);
|
||||||
file.writeShort(constantvalue_index);
|
file.writeShort(constantvalue_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Index in constant pool of constant value.
|
* @return Index in constant pool of constant value.
|
||||||
*/
|
*/
|
||||||
@ -102,18 +114,18 @@ public final class ConstantValue extends Attribute {
|
|||||||
return constantvalue_index;
|
return constantvalue_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param constantvalue_index the index info the constant pool of this constant value
|
* @param constantvalue_index
|
||||||
|
* the index info the constant pool of this constant value
|
||||||
*/
|
*/
|
||||||
public final void setConstantValueIndex(int constantvalue_index) {
|
public final void setConstantValueIndex(int constantvalue_index) {
|
||||||
this.constantvalue_index = constantvalue_index;
|
this.constantvalue_index = constantvalue_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation of constant value.
|
* @return String representation of constant value.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
Constant c = constant_pool.getConstant(constantvalue_index);
|
Constant c = constant_pool.getConstant(constantvalue_index);
|
||||||
String buf;
|
String buf;
|
||||||
@ -135,7 +147,8 @@ public final class ConstantValue extends Attribute {
|
|||||||
case Constants.CONSTANT_String:
|
case Constants.CONSTANT_String:
|
||||||
i = ((ConstantString) c).getStringIndex();
|
i = ((ConstantString) c).getStringIndex();
|
||||||
c = constant_pool.getConstant(i, Constants.CONSTANT_Utf8);
|
c = constant_pool.getConstant(i, Constants.CONSTANT_Utf8);
|
||||||
buf = "\"" + Utility.convertString(((ConstantUtf8) c).getBytes()) + "\"";
|
buf = "\"" + Utility.convertString(((ConstantUtf8) c).getBytes())
|
||||||
|
+ "\"";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Type of ConstValue invalid: " + c);
|
throw new IllegalStateException("Type of ConstValue invalid: " + c);
|
||||||
@ -143,10 +156,10 @@ public final class ConstantValue extends Attribute {
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this attribute
|
* @return deep copy of this attribute
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Attribute copy(ConstantPool _constant_pool) {
|
public Attribute copy(ConstantPool _constant_pool) {
|
||||||
ConstantValue c = (ConstantValue) clone();
|
ConstantValue c = (ConstantValue) clone();
|
||||||
c.constant_pool = _constant_pool;
|
c.constant_pool = _constant_pool;
|
||||||
|
@ -23,8 +23,8 @@ import org.apache.bcel.Constants;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from <em>Attribute</em> and denotes that this is a
|
* This class is derived from <em>Attribute</em> and denotes that this is a
|
||||||
* deprecated method.
|
* deprecated method. It is instantiated from the
|
||||||
* It is instantiated from the <em>Attribute.readAttribute()</em> method.
|
* <em>Attribute.readAttribute()</em> method.
|
||||||
*
|
*
|
||||||
* @version $Id: Deprecated.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: Deprecated.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -32,9 +32,12 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class Deprecated extends Attribute {
|
public final class Deprecated extends Attribute {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private byte[] bytes;
|
private byte[] bytes;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use clone() for a physical copy.
|
* references (shallow copy). Use clone() for a physical copy.
|
||||||
@ -43,29 +46,37 @@ public final class Deprecated extends Attribute {
|
|||||||
this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
|
this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index Index in constant pool to CONSTANT_Utf8
|
* @param name_index
|
||||||
* @param length Content length in bytes
|
* Index in constant pool to CONSTANT_Utf8
|
||||||
* @param bytes Attribute contents
|
* @param length
|
||||||
* @param constant_pool Array of constants
|
* Content length in bytes
|
||||||
|
* @param bytes
|
||||||
|
* Attribute contents
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
public Deprecated(int name_index, int length, byte[] bytes, ConstantPool constant_pool) {
|
public Deprecated(int name_index, int length, byte[] bytes,
|
||||||
|
ConstantPool constant_pool) {
|
||||||
super(Constants.ATTR_DEPRECATED, name_index, length, constant_pool);
|
super(Constants.ATTR_DEPRECATED, name_index, length, constant_pool);
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param name_index Index in constant pool to CONSTANT_Utf8
|
*
|
||||||
* @param length Content length in bytes
|
* @param name_index
|
||||||
* @param file Input stream
|
* Index in constant pool to CONSTANT_Utf8
|
||||||
* @param constant_pool Array of constants
|
* @param length
|
||||||
|
* Content length in bytes
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
Deprecated(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
Deprecated(int name_index, int length, DataInputStream file,
|
||||||
throws IOException {
|
ConstantPool constant_pool) throws IOException {
|
||||||
this(name_index, length, (byte[]) null, constant_pool);
|
this(name_index, length, (byte[]) null, constant_pool);
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
bytes = new byte[length];
|
bytes = new byte[length];
|
||||||
@ -74,25 +85,27 @@ public final class Deprecated extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitDeprecated(this);
|
v.visitDeprecated(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump source file attribute to file stream in binary format.
|
* Dump source file attribute to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
super.dump(file);
|
super.dump(file);
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
@ -100,7 +113,6 @@ public final class Deprecated extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return data bytes.
|
* @return data bytes.
|
||||||
*/
|
*/
|
||||||
@ -108,26 +120,26 @@ public final class Deprecated extends Attribute {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bytes the raw bytes that represents this byte array
|
* @param bytes
|
||||||
|
* the raw bytes that represents this byte array
|
||||||
*/
|
*/
|
||||||
public final void setBytes(byte[] bytes) {
|
public final void setBytes(byte[] bytes) {
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return attribute name
|
* @return attribute name
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return Constants.ATTRIBUTE_NAMES[Constants.ATTR_DEPRECATED];
|
return Constants.ATTRIBUTE_NAMES[Constants.ATTR_DEPRECATED];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this attribute
|
* @return deep copy of this attribute
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Attribute copy(ConstantPool _constant_pool) {
|
public Attribute copy(ConstantPool _constant_pool) {
|
||||||
Deprecated c = (Deprecated) clone();
|
Deprecated c = (Deprecated) clone();
|
||||||
if (bytes != null) {
|
if (bytes != null) {
|
||||||
|
@ -19,10 +19,9 @@ package org.apache.bcel.classfile;
|
|||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Traverses a JavaClass with another Visitor object 'piggy-backed'
|
* Traverses a JavaClass with another Visitor object 'piggy-backed' that is
|
||||||
* that is applied to all components of a JavaClass object. I.e. this
|
* applied to all components of a JavaClass object. I.e. this class supplies the
|
||||||
* class supplies the traversal strategy, other classes can make use
|
* traversal strategy, other classes can make use of it.
|
||||||
* of it.
|
|
||||||
*
|
*
|
||||||
* @version $Id: DescendingVisitor.java 388707 2006-03-25 05:40:28Z tcurdt $
|
* @version $Id: DescendingVisitor.java 388707 2006-03-25 05:40:28Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -31,18 +30,18 @@ public class DescendingVisitor implements Visitor {
|
|||||||
|
|
||||||
private JavaClass clazz;
|
private JavaClass clazz;
|
||||||
private Visitor visitor;
|
private Visitor visitor;
|
||||||
private Stack stack = new Stack();
|
private Stack<Cloneable> stack = new Stack<Cloneable>();
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return container of current entitity, i.e., predecessor during traversal
|
* @return container of current entitity, i.e., predecessor during traversal
|
||||||
*/
|
*/
|
||||||
public Object predecessor() {
|
public Object predecessor() {
|
||||||
return predecessor(0);
|
return predecessor(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param level nesting level, i.e., 0 returns the direct predecessor
|
* @param level
|
||||||
|
* nesting level, i.e., 0 returns the direct predecessor
|
||||||
* @return container of current entitity, i.e., predecessor during traversal
|
* @return container of current entitity, i.e., predecessor during traversal
|
||||||
*/
|
*/
|
||||||
public Object predecessor(int level) {
|
public Object predecessor(int level) {
|
||||||
@ -54,24 +53,24 @@ public class DescendingVisitor implements Visitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return current object
|
* @return current object
|
||||||
*/
|
*/
|
||||||
public Object current() {
|
public Object current() {
|
||||||
return stack.peek();
|
return stack.peek();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param clazz Class to traverse
|
* @param clazz
|
||||||
* @param visitor visitor object to apply to all components
|
* Class to traverse
|
||||||
|
* @param visitor
|
||||||
|
* visitor object to apply to all components
|
||||||
*/
|
*/
|
||||||
public DescendingVisitor(JavaClass clazz, Visitor visitor) {
|
public DescendingVisitor(JavaClass clazz, Visitor visitor) {
|
||||||
this.clazz = clazz;
|
this.clazz = clazz;
|
||||||
this.visitor = visitor;
|
this.visitor = visitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start traversal.
|
* Start traversal.
|
||||||
*/
|
*/
|
||||||
@ -79,7 +78,7 @@ public class DescendingVisitor implements Visitor {
|
|||||||
clazz.accept(this);
|
clazz.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitJavaClass(JavaClass _clazz) {
|
public void visitJavaClass(JavaClass _clazz) {
|
||||||
stack.push(_clazz);
|
stack.push(_clazz);
|
||||||
_clazz.accept(visitor);
|
_clazz.accept(visitor);
|
||||||
@ -99,7 +98,7 @@ public class DescendingVisitor implements Visitor {
|
|||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitField(Field field) {
|
public void visitField(Field field) {
|
||||||
stack.push(field);
|
stack.push(field);
|
||||||
field.accept(visitor);
|
field.accept(visitor);
|
||||||
@ -110,14 +109,14 @@ public class DescendingVisitor implements Visitor {
|
|||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantValue(ConstantValue cv) {
|
public void visitConstantValue(ConstantValue cv) {
|
||||||
stack.push(cv);
|
stack.push(cv);
|
||||||
cv.accept(visitor);
|
cv.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitMethod(Method method) {
|
public void visitMethod(Method method) {
|
||||||
stack.push(method);
|
stack.push(method);
|
||||||
method.accept(visitor);
|
method.accept(visitor);
|
||||||
@ -128,14 +127,14 @@ public class DescendingVisitor implements Visitor {
|
|||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitExceptionTable(ExceptionTable table) {
|
public void visitExceptionTable(ExceptionTable table) {
|
||||||
stack.push(table);
|
stack.push(table);
|
||||||
table.accept(visitor);
|
table.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitCode(Code code) {
|
public void visitCode(Code code) {
|
||||||
stack.push(code);
|
stack.push(code);
|
||||||
code.accept(visitor);
|
code.accept(visitor);
|
||||||
@ -150,14 +149,14 @@ public class DescendingVisitor implements Visitor {
|
|||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitCodeException(CodeException ce) {
|
public void visitCodeException(CodeException ce) {
|
||||||
stack.push(ce);
|
stack.push(ce);
|
||||||
ce.accept(visitor);
|
ce.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitLineNumberTable(LineNumberTable table) {
|
public void visitLineNumberTable(LineNumberTable table) {
|
||||||
stack.push(table);
|
stack.push(table);
|
||||||
table.accept(visitor);
|
table.accept(visitor);
|
||||||
@ -168,14 +167,14 @@ public class DescendingVisitor implements Visitor {
|
|||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitLineNumber(LineNumber number) {
|
public void visitLineNumber(LineNumber number) {
|
||||||
stack.push(number);
|
stack.push(number);
|
||||||
number.accept(visitor);
|
number.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitLocalVariableTable(LocalVariableTable table) {
|
public void visitLocalVariableTable(LocalVariableTable table) {
|
||||||
stack.push(table);
|
stack.push(table);
|
||||||
table.accept(visitor);
|
table.accept(visitor);
|
||||||
@ -186,7 +185,7 @@ public class DescendingVisitor implements Visitor {
|
|||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitStackMap(StackMap table) {
|
public void visitStackMap(StackMap table) {
|
||||||
stack.push(table);
|
stack.push(table);
|
||||||
table.accept(visitor);
|
table.accept(visitor);
|
||||||
@ -197,21 +196,21 @@ public class DescendingVisitor implements Visitor {
|
|||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitStackMapEntry(StackMapEntry var) {
|
public void visitStackMapEntry(StackMapEntry var) {
|
||||||
stack.push(var);
|
stack.push(var);
|
||||||
var.accept(visitor);
|
var.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitLocalVariable(LocalVariable var) {
|
public void visitLocalVariable(LocalVariable var) {
|
||||||
stack.push(var);
|
stack.push(var);
|
||||||
var.accept(visitor);
|
var.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantPool(ConstantPool cp) {
|
public void visitConstantPool(ConstantPool cp) {
|
||||||
stack.push(cp);
|
stack.push(cp);
|
||||||
cp.accept(visitor);
|
cp.accept(visitor);
|
||||||
@ -224,84 +223,85 @@ public class DescendingVisitor implements Visitor {
|
|||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantClass(ConstantClass constant) {
|
public void visitConstantClass(ConstantClass constant) {
|
||||||
stack.push(constant);
|
stack.push(constant);
|
||||||
constant.accept(visitor);
|
constant.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantDouble(ConstantDouble constant) {
|
public void visitConstantDouble(ConstantDouble constant) {
|
||||||
stack.push(constant);
|
stack.push(constant);
|
||||||
constant.accept(visitor);
|
constant.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantFieldref(ConstantFieldref constant) {
|
public void visitConstantFieldref(ConstantFieldref constant) {
|
||||||
stack.push(constant);
|
stack.push(constant);
|
||||||
constant.accept(visitor);
|
constant.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantFloat(ConstantFloat constant) {
|
public void visitConstantFloat(ConstantFloat constant) {
|
||||||
stack.push(constant);
|
stack.push(constant);
|
||||||
constant.accept(visitor);
|
constant.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantInteger(ConstantInteger constant) {
|
public void visitConstantInteger(ConstantInteger constant) {
|
||||||
stack.push(constant);
|
stack.push(constant);
|
||||||
constant.accept(visitor);
|
constant.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantInterfaceMethodref( ConstantInterfaceMethodref constant ) {
|
public void visitConstantInterfaceMethodref(
|
||||||
|
ConstantInterfaceMethodref constant) {
|
||||||
stack.push(constant);
|
stack.push(constant);
|
||||||
constant.accept(visitor);
|
constant.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantLong(ConstantLong constant) {
|
public void visitConstantLong(ConstantLong constant) {
|
||||||
stack.push(constant);
|
stack.push(constant);
|
||||||
constant.accept(visitor);
|
constant.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantMethodref(ConstantMethodref constant) {
|
public void visitConstantMethodref(ConstantMethodref constant) {
|
||||||
stack.push(constant);
|
stack.push(constant);
|
||||||
constant.accept(visitor);
|
constant.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantNameAndType(ConstantNameAndType constant) {
|
public void visitConstantNameAndType(ConstantNameAndType constant) {
|
||||||
stack.push(constant);
|
stack.push(constant);
|
||||||
constant.accept(visitor);
|
constant.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantString(ConstantString constant) {
|
public void visitConstantString(ConstantString constant) {
|
||||||
stack.push(constant);
|
stack.push(constant);
|
||||||
constant.accept(visitor);
|
constant.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantUtf8(ConstantUtf8 constant) {
|
public void visitConstantUtf8(ConstantUtf8 constant) {
|
||||||
stack.push(constant);
|
stack.push(constant);
|
||||||
constant.accept(visitor);
|
constant.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitInnerClasses(InnerClasses ic) {
|
public void visitInnerClasses(InnerClasses ic) {
|
||||||
stack.push(ic);
|
stack.push(ic);
|
||||||
ic.accept(visitor);
|
ic.accept(visitor);
|
||||||
@ -312,42 +312,42 @@ public class DescendingVisitor implements Visitor {
|
|||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitInnerClass(InnerClass inner) {
|
public void visitInnerClass(InnerClass inner) {
|
||||||
stack.push(inner);
|
stack.push(inner);
|
||||||
inner.accept(visitor);
|
inner.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitDeprecated(Deprecated attribute) {
|
public void visitDeprecated(Deprecated attribute) {
|
||||||
stack.push(attribute);
|
stack.push(attribute);
|
||||||
attribute.accept(visitor);
|
attribute.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitSignature(Signature attribute) {
|
public void visitSignature(Signature attribute) {
|
||||||
stack.push(attribute);
|
stack.push(attribute);
|
||||||
attribute.accept(visitor);
|
attribute.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitSourceFile(SourceFile attribute) {
|
public void visitSourceFile(SourceFile attribute) {
|
||||||
stack.push(attribute);
|
stack.push(attribute);
|
||||||
attribute.accept(visitor);
|
attribute.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitSynthetic(Synthetic attribute) {
|
public void visitSynthetic(Synthetic attribute) {
|
||||||
stack.push(attribute);
|
stack.push(attribute);
|
||||||
attribute.accept(visitor);
|
attribute.accept(visitor);
|
||||||
stack.pop();
|
stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitUnknown(Unknown attribute) {
|
public void visitUnknown(Unknown attribute) {
|
||||||
stack.push(attribute);
|
stack.push(attribute);
|
||||||
attribute.accept(visitor);
|
attribute.accept(visitor);
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
package org.apache.bcel.classfile;
|
package org.apache.bcel.classfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visitor with empty method bodies, can be extended and used in conjunction with the
|
* Visitor with empty method bodies, can be extended and used in conjunction
|
||||||
* DescendingVisitor class, e.g.
|
* with the DescendingVisitor class, e.g.
|
||||||
*
|
*
|
||||||
* By courtesy of David Spencer.
|
* By courtesy of David Spencer.
|
||||||
*
|
*
|
||||||
@ -31,131 +31,131 @@ public class EmptyVisitor implements Visitor {
|
|||||||
protected EmptyVisitor() {
|
protected EmptyVisitor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitCode(Code obj) {
|
public void visitCode(Code obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitCodeException(CodeException obj) {
|
public void visitCodeException(CodeException obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantClass(ConstantClass obj) {
|
public void visitConstantClass(ConstantClass obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantDouble(ConstantDouble obj) {
|
public void visitConstantDouble(ConstantDouble obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantFieldref(ConstantFieldref obj) {
|
public void visitConstantFieldref(ConstantFieldref obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantFloat(ConstantFloat obj) {
|
public void visitConstantFloat(ConstantFloat obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantInteger(ConstantInteger obj) {
|
public void visitConstantInteger(ConstantInteger obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj) {
|
public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantLong(ConstantLong obj) {
|
public void visitConstantLong(ConstantLong obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantMethodref(ConstantMethodref obj) {
|
public void visitConstantMethodref(ConstantMethodref obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantNameAndType(ConstantNameAndType obj) {
|
public void visitConstantNameAndType(ConstantNameAndType obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantPool(ConstantPool obj) {
|
public void visitConstantPool(ConstantPool obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantString(ConstantString obj) {
|
public void visitConstantString(ConstantString obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantUtf8(ConstantUtf8 obj) {
|
public void visitConstantUtf8(ConstantUtf8 obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitConstantValue(ConstantValue obj) {
|
public void visitConstantValue(ConstantValue obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitDeprecated(Deprecated obj) {
|
public void visitDeprecated(Deprecated obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitExceptionTable(ExceptionTable obj) {
|
public void visitExceptionTable(ExceptionTable obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitField(Field obj) {
|
public void visitField(Field obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitInnerClass(InnerClass obj) {
|
public void visitInnerClass(InnerClass obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitInnerClasses(InnerClasses obj) {
|
public void visitInnerClasses(InnerClasses obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitJavaClass(JavaClass obj) {
|
public void visitJavaClass(JavaClass obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitLineNumber(LineNumber obj) {
|
public void visitLineNumber(LineNumber obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitLineNumberTable(LineNumberTable obj) {
|
public void visitLineNumberTable(LineNumberTable obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitLocalVariable(LocalVariable obj) {
|
public void visitLocalVariable(LocalVariable obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitLocalVariableTable(LocalVariableTable obj) {
|
public void visitLocalVariableTable(LocalVariableTable obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitMethod(Method obj) {
|
public void visitMethod(Method obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitSignature(Signature obj) {
|
public void visitSignature(Signature obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitSourceFile(SourceFile obj) {
|
public void visitSourceFile(SourceFile obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitSynthetic(Synthetic obj) {
|
public void visitSynthetic(Synthetic obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitUnknown(Unknown obj) {
|
public void visitUnknown(Unknown obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitStackMap(StackMap obj) {
|
public void visitStackMap(StackMap obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void visitStackMapEntry(StackMapEntry obj) {
|
public void visitStackMapEntry(StackMapEntry obj) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,11 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the table of exceptions that are thrown by a
|
* This class represents the table of exceptions that are thrown by a method.
|
||||||
* method. This attribute may be used once per method. The name of
|
* This attribute may be used once per method. The name of this class is
|
||||||
* this class is <em>ExceptionTable</em> for historical reasons; The
|
* <em>ExceptionTable</em> for historical reasons; The Java Virtual Machine
|
||||||
* Java Virtual Machine Specification, Second Edition defines this
|
* Specification, Second Edition defines this attribute using the name
|
||||||
* attribute using the name <em>Exceptions</em> (which is inconsistent
|
* <em>Exceptions</em> (which is inconsistent with the other classes).
|
||||||
* with the other classes).
|
|
||||||
*
|
*
|
||||||
* @version $Id: ExceptionTable.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ExceptionTable.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -35,42 +34,53 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class ExceptionTable extends Attribute {
|
public final class ExceptionTable extends Attribute {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int number_of_exceptions; // Table of indices into
|
private int number_of_exceptions; // Table of indices into
|
||||||
private int[] exception_index_table; // constant pool
|
private int[] exception_index_table; // constant pool
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use copy() for a physical copy.
|
* references (shallow copy). Use copy() for a physical copy.
|
||||||
*/
|
*/
|
||||||
public ExceptionTable(ExceptionTable c) {
|
public ExceptionTable(ExceptionTable c) {
|
||||||
this(c.getNameIndex(), c.getLength(), c.getExceptionIndexTable(), c.getConstantPool());
|
this(c.getNameIndex(), c.getLength(), c.getExceptionIndexTable(), c
|
||||||
|
.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index Index in constant pool
|
* @param name_index
|
||||||
* @param length Content length in bytes
|
* Index in constant pool
|
||||||
* @param exception_index_table Table of indices in constant pool
|
* @param length
|
||||||
* @param constant_pool Array of constants
|
* Content length in bytes
|
||||||
|
* @param exception_index_table
|
||||||
|
* Table of indices in constant pool
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
public ExceptionTable(int name_index, int length, int[] exception_index_table,
|
public ExceptionTable(int name_index, int length,
|
||||||
ConstantPool constant_pool) {
|
int[] exception_index_table, ConstantPool constant_pool) {
|
||||||
super(Constants.ATTR_EXCEPTIONS, name_index, length, constant_pool);
|
super(Constants.ATTR_EXCEPTIONS, name_index, length, constant_pool);
|
||||||
setExceptionIndexTable(exception_index_table);
|
setExceptionIndexTable(exception_index_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param name_index Index in constant pool
|
*
|
||||||
* @param length Content length in bytes
|
* @param name_index
|
||||||
* @param file Input stream
|
* Index in constant pool
|
||||||
* @param constant_pool Array of constants
|
* @param length
|
||||||
|
* Content length in bytes
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
ExceptionTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
ExceptionTable(int name_index, int length, DataInputStream file,
|
||||||
throws IOException {
|
ConstantPool constant_pool) throws IOException {
|
||||||
this(name_index, length, (int[]) null, constant_pool);
|
this(name_index, length, (int[]) null, constant_pool);
|
||||||
number_of_exceptions = file.readUnsignedShort();
|
number_of_exceptions = file.readUnsignedShort();
|
||||||
exception_index_table = new int[number_of_exceptions];
|
exception_index_table = new int[number_of_exceptions];
|
||||||
@ -79,25 +89,27 @@ public final class ExceptionTable extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitExceptionTable(this);
|
v.visitExceptionTable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump exceptions attribute to file stream in binary format.
|
* Dump exceptions attribute to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
super.dump(file);
|
super.dump(file);
|
||||||
file.writeShort(number_of_exceptions);
|
file.writeShort(number_of_exceptions);
|
||||||
@ -106,7 +118,6 @@ public final class ExceptionTable extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Array of indices into constant pool of thrown exceptions.
|
* @return Array of indices into constant pool of thrown exceptions.
|
||||||
*/
|
*/
|
||||||
@ -114,7 +125,6 @@ public final class ExceptionTable extends Attribute {
|
|||||||
return exception_index_table;
|
return exception_index_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Length of exception table.
|
* @return Length of exception table.
|
||||||
*/
|
*/
|
||||||
@ -122,33 +132,34 @@ public final class ExceptionTable extends Attribute {
|
|||||||
return number_of_exceptions;
|
return number_of_exceptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return class names of thrown exceptions
|
* @return class names of thrown exceptions
|
||||||
*/
|
*/
|
||||||
public final String[] getExceptionNames() {
|
public final String[] getExceptionNames() {
|
||||||
String[] names = new String[number_of_exceptions];
|
String[] names = new String[number_of_exceptions];
|
||||||
for (int i = 0; i < number_of_exceptions; i++) {
|
for (int i = 0; i < number_of_exceptions; i++) {
|
||||||
names[i] = constant_pool.getConstantString(exception_index_table[i],
|
names[i] = constant_pool.getConstantString(
|
||||||
Constants.CONSTANT_Class).replace('/', '.');
|
exception_index_table[i], Constants.CONSTANT_Class)
|
||||||
|
.replace('/', '.');
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param exception_index_table the list of exception indexes
|
* @param exception_index_table
|
||||||
* Also redefines number_of_exceptions according to table length.
|
* the list of exception indexes Also redefines
|
||||||
|
* number_of_exceptions according to table length.
|
||||||
*/
|
*/
|
||||||
public final void setExceptionIndexTable(int[] exception_index_table) {
|
public final void setExceptionIndexTable(int[] exception_index_table) {
|
||||||
this.exception_index_table = exception_index_table;
|
this.exception_index_table = exception_index_table;
|
||||||
number_of_exceptions = (exception_index_table == null) ? 0 : exception_index_table.length;
|
number_of_exceptions = (exception_index_table == null) ? 0
|
||||||
|
: exception_index_table.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation, i.e., a list of thrown exceptions.
|
* @return String representation, i.e., a list of thrown exceptions.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
StringBuffer buf = new StringBuffer("");
|
StringBuffer buf = new StringBuffer("");
|
||||||
String str;
|
String str;
|
||||||
@ -163,16 +174,16 @@ public final class ExceptionTable extends Attribute {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this attribute
|
* @return deep copy of this attribute
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Attribute copy(ConstantPool _constant_pool) {
|
public Attribute copy(ConstantPool _constant_pool) {
|
||||||
ExceptionTable c = (ExceptionTable) clone();
|
ExceptionTable c = (ExceptionTable) clone();
|
||||||
if (exception_index_table != null) {
|
if (exception_index_table != null) {
|
||||||
c.exception_index_table = new int[exception_index_table.length];
|
c.exception_index_table = new int[exception_index_table.length];
|
||||||
System.arraycopy(exception_index_table, 0, c.exception_index_table, 0,
|
System.arraycopy(exception_index_table, 0, c.exception_index_table,
|
||||||
exception_index_table.length);
|
0, exception_index_table.length);
|
||||||
}
|
}
|
||||||
c.constant_pool = _constant_pool;
|
c.constant_pool = _constant_pool;
|
||||||
return c;
|
return c;
|
||||||
|
@ -23,16 +23,21 @@ import org.apache.bcel.generic.Type;
|
|||||||
import org.apache.bcel.util.BCELComparator;
|
import org.apache.bcel.util.BCELComparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the field info structure, i.e., the representation
|
* This class represents the field info structure, i.e., the representation for
|
||||||
* for a variable in the class. See JVM specification for details.
|
* a variable in the class. See JVM specification for details.
|
||||||
*
|
*
|
||||||
* @version $Id: Field.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: Field.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public final class Field extends FieldOrMethod {
|
public final class Field extends FieldOrMethod {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private static BCELComparator _cmp = new BCELComparator() {
|
private static BCELComparator _cmp = new BCELComparator() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object o1, Object o2) {
|
public boolean equals(Object o1, Object o2) {
|
||||||
Field THIS = (Field) o1;
|
Field THIS = (Field) o1;
|
||||||
Field THAT = (Field) o2;
|
Field THAT = (Field) o2;
|
||||||
@ -40,14 +45,13 @@ public final class Field extends FieldOrMethod {
|
|||||||
&& THIS.getSignature().equals(THAT.getSignature());
|
&& THIS.getSignature().equals(THAT.getSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int hashCode(Object o) {
|
public int hashCode(Object o) {
|
||||||
Field THIS = (Field) o;
|
Field THIS = (Field) o;
|
||||||
return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
|
return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use clone() for a physical copy.
|
* references (shallow copy). Use clone() for a physical copy.
|
||||||
@ -56,42 +60,48 @@ public final class Field extends FieldOrMethod {
|
|||||||
super(c);
|
super(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param file Input stream
|
*
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
*/
|
*/
|
||||||
Field(DataInputStream file, ConstantPool constant_pool) throws IOException,
|
Field(DataInputStream file, ConstantPool constant_pool) throws IOException,
|
||||||
ClassFormatException {
|
ClassFormatException {
|
||||||
super(file, constant_pool);
|
super(file, constant_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param access_flags Access rights of field
|
* @param access_flags
|
||||||
* @param name_index Points to field name in constant pool
|
* Access rights of field
|
||||||
* @param signature_index Points to encoded signature
|
* @param name_index
|
||||||
* @param attributes Collection of attributes
|
* Points to field name in constant pool
|
||||||
* @param constant_pool Array of constants
|
* @param signature_index
|
||||||
|
* Points to encoded signature
|
||||||
|
* @param attributes
|
||||||
|
* Collection of attributes
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
public Field(int access_flags, int name_index, int signature_index, Attribute[] attributes,
|
public Field(int access_flags, int name_index, int signature_index,
|
||||||
ConstantPool constant_pool) {
|
Attribute[] attributes, ConstantPool constant_pool) {
|
||||||
super(access_flags, name_index, signature_index, attributes, constant_pool);
|
super(access_flags, name_index, signature_index, attributes,
|
||||||
|
constant_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitField(this);
|
v.visitField(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return constant value associated with this field (may be null)
|
* @return constant value associated with this field (may be null)
|
||||||
*/
|
*/
|
||||||
@ -104,13 +114,13 @@ public final class Field extends FieldOrMethod {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return string representation close to declaration format,
|
* Return string representation close to declaration format, `public static
|
||||||
* `public static final short MAX = 100', e.g..
|
* final short MAX = 100', e.g..
|
||||||
*
|
*
|
||||||
* @return String representation of field, including the signature.
|
* @return String representation of field, including the signature.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
String name, signature, access; // Short cuts to constant pool
|
String name, signature, access; // Short cuts to constant pool
|
||||||
// Get names from constant pool
|
// Get names from constant pool
|
||||||
@ -133,7 +143,6 @@ public final class Field extends FieldOrMethod {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this field
|
* @return deep copy of this field
|
||||||
*/
|
*/
|
||||||
@ -141,7 +150,6 @@ public final class Field extends FieldOrMethod {
|
|||||||
return (Field) copy_(_constant_pool);
|
return (Field) copy_(_constant_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return type of field
|
* @return type of field
|
||||||
*/
|
*/
|
||||||
@ -149,7 +157,6 @@ public final class Field extends FieldOrMethod {
|
|||||||
return Type.getReturnType(getSignature());
|
return Type.getReturnType(getSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Comparison strategy object
|
* @return Comparison strategy object
|
||||||
*/
|
*/
|
||||||
@ -157,33 +164,33 @@ public final class Field extends FieldOrMethod {
|
|||||||
return _cmp;
|
return _cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param comparator Comparison strategy object
|
* @param comparator
|
||||||
|
* Comparison strategy object
|
||||||
*/
|
*/
|
||||||
public static void setComparator(BCELComparator comparator) {
|
public static void setComparator(BCELComparator comparator) {
|
||||||
_cmp = comparator;
|
_cmp = comparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value as defined by given BCELComparator strategy.
|
* Return value as defined by given BCELComparator strategy. By default two
|
||||||
* By default two Field objects are said to be equal when
|
* Field objects are said to be equal when their names and signatures are
|
||||||
* their names and signatures are equal.
|
* equal.
|
||||||
*
|
*
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return _cmp.equals(this, obj);
|
return _cmp.equals(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value as defined by given BCELComparator strategy.
|
* Return value as defined by given BCELComparator strategy. By default
|
||||||
* By default return the hashcode of the field's name XOR signature.
|
* return the hashcode of the field's name XOR signature.
|
||||||
*
|
*
|
||||||
* @see java.lang.Object#hashCode()
|
* @see java.lang.Object#hashCode()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return _cmp.hashCode(this);
|
return _cmp.hashCode(this);
|
||||||
}
|
}
|
||||||
|
@ -27,39 +27,43 @@ import org.apache.bcel.Constants;
|
|||||||
* @version $Id: FieldOrMethod.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: FieldOrMethod.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @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,
|
||||||
|
Node {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
protected int name_index; // Points to field name in constant pool
|
protected int name_index; // Points to field name in constant pool
|
||||||
protected int signature_index; // Points to encoded signature
|
protected int signature_index; // Points to encoded signature
|
||||||
protected int attributes_count; // No. of attributes
|
protected int attributes_count; // No. of attributes
|
||||||
protected Attribute[] attributes; // Collection of attributes
|
protected Attribute[] attributes; // Collection of attributes
|
||||||
protected ConstantPool constant_pool;
|
protected ConstantPool constant_pool;
|
||||||
|
|
||||||
|
|
||||||
FieldOrMethod() {
|
FieldOrMethod() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use clone() for a physical copy.
|
* references (shallow copy). Use clone() for a physical copy.
|
||||||
*/
|
*/
|
||||||
protected FieldOrMethod(FieldOrMethod c) {
|
protected FieldOrMethod(FieldOrMethod c) {
|
||||||
this(c.getAccessFlags(), c.getNameIndex(), c.getSignatureIndex(), c.getAttributes(), c
|
this(c.getAccessFlags(), c.getNameIndex(), c.getSignatureIndex(), c
|
||||||
.getConstantPool());
|
.getAttributes(), c.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param file Input stream
|
*
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassFormatException
|
* @throws ClassFormatException
|
||||||
*/
|
*/
|
||||||
protected FieldOrMethod(DataInputStream file, ConstantPool constant_pool) throws IOException,
|
protected FieldOrMethod(DataInputStream file, ConstantPool constant_pool)
|
||||||
ClassFormatException {
|
throws IOException, ClassFormatException {
|
||||||
this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), null,
|
this(file.readUnsignedShort(), file.readUnsignedShort(), file
|
||||||
constant_pool);
|
.readUnsignedShort(), null, constant_pool);
|
||||||
attributes_count = file.readUnsignedShort();
|
attributes_count = file.readUnsignedShort();
|
||||||
attributes = new Attribute[attributes_count];
|
attributes = new Attribute[attributes_count];
|
||||||
for (int i = 0; i < attributes_count; i++) {
|
for (int i = 0; i < attributes_count; i++) {
|
||||||
@ -67,16 +71,21 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param access_flags Access rights of method
|
* @param access_flags
|
||||||
* @param name_index Points to field name in constant pool
|
* Access rights of method
|
||||||
* @param signature_index Points to encoded signature
|
* @param name_index
|
||||||
* @param attributes Collection of attributes
|
* Points to field name in constant pool
|
||||||
* @param constant_pool Array of constants
|
* @param signature_index
|
||||||
|
* Points to encoded signature
|
||||||
|
* @param attributes
|
||||||
|
* Collection of attributes
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
protected FieldOrMethod(int access_flags, int name_index, int signature_index,
|
protected FieldOrMethod(int access_flags, int name_index,
|
||||||
Attribute[] attributes, ConstantPool constant_pool) {
|
int signature_index, Attribute[] attributes,
|
||||||
|
ConstantPool constant_pool) {
|
||||||
this.access_flags = access_flags;
|
this.access_flags = access_flags;
|
||||||
this.name_index = name_index;
|
this.name_index = name_index;
|
||||||
this.signature_index = signature_index;
|
this.signature_index = signature_index;
|
||||||
@ -84,11 +93,11 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No
|
|||||||
setAttributes(attributes);
|
setAttributes(attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump object to file stream on binary format.
|
* Dump object to file stream on binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
@ -101,7 +110,6 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection of object attributes.
|
* @return Collection of object attributes.
|
||||||
*/
|
*/
|
||||||
@ -109,16 +117,15 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No
|
|||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param attributes Collection of object attributes.
|
* @param attributes
|
||||||
|
* Collection of object attributes.
|
||||||
*/
|
*/
|
||||||
public final void setAttributes(Attribute[] attributes) {
|
public final void setAttributes(Attribute[] attributes) {
|
||||||
this.attributes = attributes;
|
this.attributes = attributes;
|
||||||
attributes_count = (attributes == null) ? 0 : attributes.length;
|
attributes_count = (attributes == null) ? 0 : attributes.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Constant pool used by this object.
|
* @return Constant pool used by this object.
|
||||||
*/
|
*/
|
||||||
@ -126,15 +133,14 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No
|
|||||||
return constant_pool;
|
return constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param constant_pool Constant pool to be used for this object.
|
* @param constant_pool
|
||||||
|
* Constant pool to be used for this object.
|
||||||
*/
|
*/
|
||||||
public final void setConstantPool(ConstantPool constant_pool) {
|
public final void setConstantPool(ConstantPool constant_pool) {
|
||||||
this.constant_pool = constant_pool;
|
this.constant_pool = constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Index in constant pool of object's name.
|
* @return Index in constant pool of object's name.
|
||||||
*/
|
*/
|
||||||
@ -142,15 +148,14 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No
|
|||||||
return name_index;
|
return name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index Index in constant pool of object's name.
|
* @param name_index
|
||||||
|
* Index in constant pool of object's name.
|
||||||
*/
|
*/
|
||||||
public final void setNameIndex(int name_index) {
|
public final void setNameIndex(int name_index) {
|
||||||
this.name_index = name_index;
|
this.name_index = name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Index in constant pool of field signature.
|
* @return Index in constant pool of field signature.
|
||||||
*/
|
*/
|
||||||
@ -158,35 +163,34 @@ public abstract class FieldOrMethod extends AccessFlags implements Cloneable, No
|
|||||||
return signature_index;
|
return signature_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param signature_index Index in constant pool of field signature.
|
* @param signature_index
|
||||||
|
* Index in constant pool of field signature.
|
||||||
*/
|
*/
|
||||||
public final void setSignatureIndex(int signature_index) {
|
public final void setSignatureIndex(int signature_index) {
|
||||||
this.signature_index = signature_index;
|
this.signature_index = signature_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Name of object, i.e., method name or field name
|
* @return Name of object, i.e., method name or field name
|
||||||
*/
|
*/
|
||||||
public final String getName() {
|
public final String getName() {
|
||||||
ConstantUtf8 c;
|
ConstantUtf8 c;
|
||||||
c = (ConstantUtf8) constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8);
|
c = (ConstantUtf8) constant_pool.getConstant(name_index,
|
||||||
|
Constants.CONSTANT_Utf8);
|
||||||
return c.getBytes();
|
return c.getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation of object's type signature (java style)
|
* @return String representation of object's type signature (java style)
|
||||||
*/
|
*/
|
||||||
public final String getSignature() {
|
public final String getSignature() {
|
||||||
ConstantUtf8 c;
|
ConstantUtf8 c;
|
||||||
c = (ConstantUtf8) constant_pool.getConstant(signature_index, Constants.CONSTANT_Utf8);
|
c = (ConstantUtf8) constant_pool.getConstant(signature_index,
|
||||||
|
Constants.CONSTANT_Utf8);
|
||||||
return c.getBytes();
|
return c.getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this field
|
* @return deep copy of this field
|
||||||
*/
|
*/
|
||||||
|
@ -23,9 +23,8 @@ import java.io.Serializable;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a inner class attribute, i.e., the class
|
* This class represents a inner class attribute, i.e., the class indices of the
|
||||||
* indices of the inner and outer classes, the name and the attributes
|
* inner and outer classes, the name and the attributes of the inner class.
|
||||||
* of the inner class.
|
|
||||||
*
|
*
|
||||||
* @version $Id: InnerClass.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: InnerClass.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -33,63 +32,71 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class InnerClass implements Cloneable, Node, Serializable {
|
public final class InnerClass implements Cloneable, Node, Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int inner_class_index;
|
private int inner_class_index;
|
||||||
private int outer_class_index;
|
private int outer_class_index;
|
||||||
private int inner_name_index;
|
private int inner_name_index;
|
||||||
private int inner_access_flags;
|
private int inner_access_flags;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object.
|
* Initialize from another object.
|
||||||
*/
|
*/
|
||||||
public InnerClass(InnerClass c) {
|
public InnerClass(InnerClass c) {
|
||||||
this(c.getInnerClassIndex(), c.getOuterClassIndex(), c.getInnerNameIndex(), c
|
this(c.getInnerClassIndex(), c.getOuterClassIndex(), c
|
||||||
.getInnerAccessFlags());
|
.getInnerNameIndex(), c.getInnerAccessFlags());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param file Input stream
|
*
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
InnerClass(DataInputStream file) throws IOException {
|
InnerClass(DataInputStream file) throws IOException {
|
||||||
this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file
|
this(file.readUnsignedShort(), file.readUnsignedShort(), file
|
||||||
.readUnsignedShort());
|
.readUnsignedShort(), file.readUnsignedShort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param inner_class_index Class index in constant pool of inner class
|
* @param inner_class_index
|
||||||
* @param outer_class_index Class index in constant pool of outer class
|
* Class index in constant pool of inner class
|
||||||
* @param inner_name_index Name index in constant pool of inner class
|
* @param outer_class_index
|
||||||
* @param inner_access_flags Access flags of inner class
|
* Class index in constant pool of outer class
|
||||||
|
* @param inner_name_index
|
||||||
|
* Name index in constant pool of inner class
|
||||||
|
* @param inner_access_flags
|
||||||
|
* Access flags of inner class
|
||||||
*/
|
*/
|
||||||
public InnerClass(int inner_class_index, int outer_class_index, int inner_name_index,
|
public InnerClass(int inner_class_index, int outer_class_index,
|
||||||
int inner_access_flags) {
|
int inner_name_index, int inner_access_flags) {
|
||||||
this.inner_class_index = inner_class_index;
|
this.inner_class_index = inner_class_index;
|
||||||
this.outer_class_index = outer_class_index;
|
this.outer_class_index = outer_class_index;
|
||||||
this.inner_name_index = inner_name_index;
|
this.inner_name_index = inner_name_index;
|
||||||
this.inner_access_flags = inner_access_flags;
|
this.inner_access_flags = inner_access_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitInnerClass(this);
|
v.visitInnerClass(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump inner class attribute to file stream in binary format.
|
* Dump inner class attribute to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
@ -99,7 +106,6 @@ public final class InnerClass implements Cloneable, Node, Serializable {
|
|||||||
file.writeShort(inner_access_flags);
|
file.writeShort(inner_access_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return access flags of inner class.
|
* @return access flags of inner class.
|
||||||
*/
|
*/
|
||||||
@ -107,7 +113,6 @@ public final class InnerClass implements Cloneable, Node, Serializable {
|
|||||||
return inner_access_flags;
|
return inner_access_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return class index of inner class.
|
* @return class index of inner class.
|
||||||
*/
|
*/
|
||||||
@ -115,7 +120,6 @@ public final class InnerClass implements Cloneable, Node, Serializable {
|
|||||||
return inner_class_index;
|
return inner_class_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return name index of inner class.
|
* @return name index of inner class.
|
||||||
*/
|
*/
|
||||||
@ -123,7 +127,6 @@ public final class InnerClass implements Cloneable, Node, Serializable {
|
|||||||
return inner_name_index;
|
return inner_name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return class index of outer class.
|
* @return class index of outer class.
|
||||||
*/
|
*/
|
||||||
@ -131,48 +134,47 @@ public final class InnerClass implements Cloneable, Node, Serializable {
|
|||||||
return outer_class_index;
|
return outer_class_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param inner_access_flags access flags for this inner class
|
* @param inner_access_flags
|
||||||
|
* access flags for this inner class
|
||||||
*/
|
*/
|
||||||
public final void setInnerAccessFlags(int inner_access_flags) {
|
public final void setInnerAccessFlags(int inner_access_flags) {
|
||||||
this.inner_access_flags = inner_access_flags;
|
this.inner_access_flags = inner_access_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param inner_class_index index into the constant pool for this class
|
* @param inner_class_index
|
||||||
|
* index into the constant pool for this class
|
||||||
*/
|
*/
|
||||||
public final void setInnerClassIndex(int inner_class_index) {
|
public final void setInnerClassIndex(int inner_class_index) {
|
||||||
this.inner_class_index = inner_class_index;
|
this.inner_class_index = inner_class_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param inner_name_index index into the constant pool for this class's name
|
* @param inner_name_index
|
||||||
|
* index into the constant pool for this class's name
|
||||||
*/
|
*/
|
||||||
public final void setInnerNameIndex(int inner_name_index) {
|
public final void setInnerNameIndex(int inner_name_index) {
|
||||||
this.inner_name_index = inner_name_index;
|
this.inner_name_index = inner_name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param outer_class_index index into the constant pool for the owning class
|
* @param outer_class_index
|
||||||
|
* index into the constant pool for the owning class
|
||||||
*/
|
*/
|
||||||
public final void setOuterClassIndex(int outer_class_index) {
|
public final void setOuterClassIndex(int outer_class_index) {
|
||||||
this.outer_class_index = outer_class_index;
|
this.outer_class_index = outer_class_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return "InnerClass(" + inner_class_index + ", " + outer_class_index + ", "
|
return "InnerClass(" + inner_class_index + ", " + outer_class_index
|
||||||
+ inner_name_index + ", " + inner_access_flags + ")";
|
+ ", " + inner_name_index + ", " + inner_access_flags + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Resolved string representation
|
* @return Resolved string representation
|
||||||
*/
|
*/
|
||||||
@ -182,25 +184,24 @@ public final class InnerClass implements Cloneable, Node, Serializable {
|
|||||||
Constants.CONSTANT_Class);
|
Constants.CONSTANT_Class);
|
||||||
inner_class_name = Utility.compactClassName(inner_class_name);
|
inner_class_name = Utility.compactClassName(inner_class_name);
|
||||||
if (outer_class_index != 0) {
|
if (outer_class_index != 0) {
|
||||||
outer_class_name = constant_pool.getConstantString(outer_class_index,
|
outer_class_name = constant_pool.getConstantString(
|
||||||
Constants.CONSTANT_Class);
|
outer_class_index, Constants.CONSTANT_Class);
|
||||||
outer_class_name = Utility.compactClassName(outer_class_name);
|
outer_class_name = Utility.compactClassName(outer_class_name);
|
||||||
} else {
|
} else {
|
||||||
outer_class_name = "<not a member>";
|
outer_class_name = "<not a member>";
|
||||||
}
|
}
|
||||||
if (inner_name_index != 0) {
|
if (inner_name_index != 0) {
|
||||||
inner_name = ((ConstantUtf8) constant_pool.getConstant(inner_name_index,
|
inner_name = ((ConstantUtf8) constant_pool.getConstant(
|
||||||
Constants.CONSTANT_Utf8)).getBytes();
|
inner_name_index, Constants.CONSTANT_Utf8)).getBytes();
|
||||||
} else {
|
} else {
|
||||||
inner_name = "<anonymous>";
|
inner_name = "<anonymous>";
|
||||||
}
|
}
|
||||||
access = Utility.accessToString(inner_access_flags, true);
|
access = Utility.accessToString(inner_access_flags, true);
|
||||||
access = access.equals("") ? "" : (access + " ");
|
access = access.equals("") ? "" : (access + " ");
|
||||||
return "InnerClass:" + access + inner_class_name + "(\"" + outer_class_name + "\", \""
|
return "InnerClass:" + access + inner_class_name + "(\""
|
||||||
+ inner_name + "\")";
|
+ outer_class_name + "\", \"" + inner_name + "\")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this object
|
* @return deep copy of this object
|
||||||
*/
|
*/
|
||||||
|
@ -22,10 +22,9 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from <em>Attribute</em> and denotes that this class
|
* This class is derived from <em>Attribute</em> and denotes that this class is
|
||||||
* is an Inner class of another.
|
* an Inner class of another. to the source file of this class. It is
|
||||||
* to the source file of this class.
|
* instantiated from the <em>Attribute.readAttribute()</em> method.
|
||||||
* It is instantiated from the <em>Attribute.readAttribute()</em> method.
|
|
||||||
*
|
*
|
||||||
* @version $Id: InnerClasses.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: InnerClasses.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -33,24 +32,31 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class InnerClasses extends Attribute {
|
public final class InnerClasses extends Attribute {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private InnerClass[] inner_classes;
|
private InnerClass[] inner_classes;
|
||||||
private int number_of_classes;
|
private int number_of_classes;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use clone() for a physical copy.
|
* references (shallow copy). Use clone() for a physical copy.
|
||||||
*/
|
*/
|
||||||
public InnerClasses(InnerClasses c) {
|
public InnerClasses(InnerClasses c) {
|
||||||
this(c.getNameIndex(), c.getLength(), c.getInnerClasses(), c.getConstantPool());
|
this(c.getNameIndex(), c.getLength(), c.getInnerClasses(), c
|
||||||
|
.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index Index in constant pool to CONSTANT_Utf8
|
* @param name_index
|
||||||
* @param length Content length in bytes
|
* Index in constant pool to CONSTANT_Utf8
|
||||||
* @param inner_classes array of inner classes attributes
|
* @param length
|
||||||
* @param constant_pool Array of constants
|
* Content length in bytes
|
||||||
|
* @param inner_classes
|
||||||
|
* array of inner classes attributes
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
public InnerClasses(int name_index, int length, InnerClass[] inner_classes,
|
public InnerClasses(int name_index, int length, InnerClass[] inner_classes,
|
||||||
ConstantPool constant_pool) {
|
ConstantPool constant_pool) {
|
||||||
@ -58,18 +64,21 @@ public final class InnerClasses extends Attribute {
|
|||||||
setInnerClasses(inner_classes);
|
setInnerClasses(inner_classes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
*
|
*
|
||||||
* @param name_index Index in constant pool to CONSTANT_Utf8
|
* @param name_index
|
||||||
* @param length Content length in bytes
|
* Index in constant pool to CONSTANT_Utf8
|
||||||
* @param file Input stream
|
* @param length
|
||||||
* @param constant_pool Array of constants
|
* Content length in bytes
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
InnerClasses(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
InnerClasses(int name_index, int length, DataInputStream file,
|
||||||
throws IOException {
|
ConstantPool constant_pool) throws IOException {
|
||||||
this(name_index, length, (InnerClass[]) null, constant_pool);
|
this(name_index, length, (InnerClass[]) null, constant_pool);
|
||||||
number_of_classes = file.readUnsignedShort();
|
number_of_classes = file.readUnsignedShort();
|
||||||
inner_classes = new InnerClass[number_of_classes];
|
inner_classes = new InnerClass[number_of_classes];
|
||||||
@ -78,25 +87,27 @@ public final class InnerClasses extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitInnerClasses(this);
|
v.visitInnerClasses(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump source file attribute to file stream in binary format.
|
* Dump source file attribute to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
super.dump(file);
|
super.dump(file);
|
||||||
file.writeShort(number_of_classes);
|
file.writeShort(number_of_classes);
|
||||||
@ -105,7 +116,6 @@ public final class InnerClasses extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array of inner class "records"
|
* @return array of inner class "records"
|
||||||
*/
|
*/
|
||||||
@ -113,19 +123,19 @@ public final class InnerClasses extends Attribute {
|
|||||||
return inner_classes;
|
return inner_classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param inner_classes the array of inner classes
|
* @param inner_classes
|
||||||
|
* the array of inner classes
|
||||||
*/
|
*/
|
||||||
public final void setInnerClasses(InnerClass[] inner_classes) {
|
public final void setInnerClasses(InnerClass[] inner_classes) {
|
||||||
this.inner_classes = inner_classes;
|
this.inner_classes = inner_classes;
|
||||||
number_of_classes = (inner_classes == null) ? 0 : inner_classes.length;
|
number_of_classes = (inner_classes == null) ? 0 : inner_classes.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
for (int i = 0; i < number_of_classes; i++) {
|
for (int i = 0; i < number_of_classes; i++) {
|
||||||
@ -134,10 +144,10 @@ public final class InnerClasses extends Attribute {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this attribute
|
* @return deep copy of this attribute
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Attribute copy(ConstantPool _constant_pool) {
|
public Attribute copy(ConstantPool _constant_pool) {
|
||||||
InnerClasses c = (InnerClasses) clone();
|
InnerClasses c = (InnerClasses) clone();
|
||||||
c.inner_classes = new InnerClass[number_of_classes];
|
c.inner_classes = new InnerClass[number_of_classes];
|
||||||
|
@ -35,18 +35,19 @@ import org.apache.bcel.util.ClassQueue;
|
|||||||
import org.apache.bcel.util.SyntheticRepository;
|
import org.apache.bcel.util.SyntheticRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Java class, i.e., the data structures, constant pool,
|
* Represents a Java class, i.e., the data structures, constant pool, fields,
|
||||||
* fields, methods and commands contained in a Java .class file.
|
* methods and commands contained in a Java .class file. See <a
|
||||||
* See <a href="ftp://java.sun.com/docs/specs/">JVM specification</a> for details.
|
* href="ftp://java.sun.com/docs/specs/">JVM specification</a> for details. The
|
||||||
* The intent of this class is to represent a parsed or otherwise existing
|
* intent of this class is to represent a parsed or otherwise existing class
|
||||||
* class file. Those interested in programatically generating classes
|
* file. Those interested in programatically generating classes should see the
|
||||||
* should see the <a href="../generic/ClassGen.html">ClassGen</a> class.
|
* <a href="../generic/ClassGen.html">ClassGen</a> class.
|
||||||
|
*
|
||||||
* @version $Id: JavaClass.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: JavaClass.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @see org.apache.bcel.generic.ClassGen
|
* @see org.apache.bcel.generic.ClassGen
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class JavaClass extends AccessFlags implements Cloneable, Node, Comparable<Object> {
|
public class JavaClass extends AccessFlags implements Cloneable, Node,
|
||||||
|
Comparable<Object> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -74,48 +75,60 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
static char sep = '/'; // directory separator
|
static char sep = '/'; // directory separator
|
||||||
private static BCELComparator _cmp = new BCELComparator() {
|
private static BCELComparator _cmp = new BCELComparator() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object o1, Object o2) {
|
public boolean equals(Object o1, Object o2) {
|
||||||
JavaClass THIS = (JavaClass) o1;
|
JavaClass THIS = (JavaClass) o1;
|
||||||
JavaClass THAT = (JavaClass) o2;
|
JavaClass THAT = (JavaClass) o2;
|
||||||
return THIS.getClassName().equals(THAT.getClassName());
|
return THIS.getClassName().equals(THAT.getClassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int hashCode(Object o) {
|
public int hashCode(Object o) {
|
||||||
JavaClass THIS = (JavaClass) o;
|
JavaClass THIS = (JavaClass) o;
|
||||||
return THIS.getClassName().hashCode();
|
return THIS.getClassName().hashCode();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* In cases where we go ahead and create something,
|
* In cases where we go ahead and create something, use the default
|
||||||
* use the default SyntheticRepository, because we
|
* SyntheticRepository, because we don't know any better.
|
||||||
* don't know any better.
|
|
||||||
*/
|
*/
|
||||||
private transient org.apache.bcel.util.Repository repository = SyntheticRepository
|
private transient org.apache.bcel.util.Repository repository = SyntheticRepository
|
||||||
.getInstance();
|
.getInstance();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor gets all contents as arguments.
|
* Constructor gets all contents as arguments.
|
||||||
*
|
*
|
||||||
* @param class_name_index Index into constant pool referencing a
|
* @param class_name_index
|
||||||
* ConstantClass that represents this class.
|
* Index into constant pool referencing a ConstantClass that
|
||||||
* @param superclass_name_index Index into constant pool referencing a
|
* represents this class.
|
||||||
* ConstantClass that represents this class's superclass.
|
* @param superclass_name_index
|
||||||
* @param file_name File name
|
* Index into constant pool referencing a ConstantClass that
|
||||||
* @param major Major compiler version
|
* represents this class's superclass.
|
||||||
* @param minor Minor compiler version
|
* @param file_name
|
||||||
* @param access_flags Access rights defined by bit flags
|
* File name
|
||||||
* @param constant_pool Array of constants
|
* @param major
|
||||||
* @param interfaces Implemented interfaces
|
* Major compiler version
|
||||||
* @param fields Class fields
|
* @param minor
|
||||||
* @param methods Class methods
|
* Minor compiler version
|
||||||
* @param attributes Class attributes
|
* @param access_flags
|
||||||
* @param source Read from file or generated in memory?
|
* Access rights defined by bit flags
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
|
* @param interfaces
|
||||||
|
* Implemented interfaces
|
||||||
|
* @param fields
|
||||||
|
* Class fields
|
||||||
|
* @param methods
|
||||||
|
* Class methods
|
||||||
|
* @param attributes
|
||||||
|
* Class attributes
|
||||||
|
* @param source
|
||||||
|
* Read from file or generated in memory?
|
||||||
*/
|
*/
|
||||||
public JavaClass(int class_name_index, int superclass_name_index, String file_name, int major,
|
public JavaClass(int class_name_index, int superclass_name_index,
|
||||||
int minor, int access_flags, ConstantPool constant_pool, int[] interfaces,
|
String file_name, int major, int minor, int access_flags,
|
||||||
Field[] fields, Method[] methods, Attribute[] attributes, byte source) {
|
ConstantPool constant_pool, int[] interfaces, Field[] fields,
|
||||||
|
Method[] methods, Attribute[] attributes, byte source) {
|
||||||
if (interfaces == null) {
|
if (interfaces == null) {
|
||||||
interfaces = new int[0];
|
interfaces = new int[0];
|
||||||
}
|
}
|
||||||
@ -143,15 +156,18 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
// Get source file name if available
|
// Get source file name if available
|
||||||
for (int i = 0; i < attributes.length; i++) {
|
for (int i = 0; i < attributes.length; i++) {
|
||||||
if (attributes[i] instanceof SourceFile) {
|
if (attributes[i] instanceof SourceFile) {
|
||||||
source_file_name = ((SourceFile) attributes[i]).getSourceFileName();
|
source_file_name = ((SourceFile) attributes[i])
|
||||||
|
.getSourceFileName();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* According to the specification the following entries must be of type
|
/*
|
||||||
|
* According to the specification the following entries must be of type
|
||||||
* `ConstantClass' but we check that anyway via the
|
* `ConstantClass' but we check that anyway via the
|
||||||
* `ConstPool.getConstant' method.
|
* `ConstPool.getConstant' method.
|
||||||
*/
|
*/
|
||||||
class_name = constant_pool.getConstantString(class_name_index, Constants.CONSTANT_Class);
|
class_name = constant_pool.getConstantString(class_name_index,
|
||||||
|
Constants.CONSTANT_Class);
|
||||||
class_name = Utility.compactClassName(class_name, false);
|
class_name = Utility.compactClassName(class_name, false);
|
||||||
int index = class_name.lastIndexOf('.');
|
int index = class_name.lastIndexOf('.');
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
@ -161,56 +177,70 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
}
|
}
|
||||||
if (superclass_name_index > 0) {
|
if (superclass_name_index > 0) {
|
||||||
// May be zero -> class is java.lang.Object
|
// May be zero -> class is java.lang.Object
|
||||||
superclass_name = constant_pool.getConstantString(superclass_name_index,
|
superclass_name = constant_pool.getConstantString(
|
||||||
Constants.CONSTANT_Class);
|
superclass_name_index, Constants.CONSTANT_Class);
|
||||||
superclass_name = Utility.compactClassName(superclass_name, false);
|
superclass_name = Utility.compactClassName(superclass_name, false);
|
||||||
} else {
|
} else {
|
||||||
superclass_name = "java.lang.Object";
|
superclass_name = "java.lang.Object";
|
||||||
}
|
}
|
||||||
interface_names = new String[interfaces.length];
|
interface_names = new String[interfaces.length];
|
||||||
for (int i = 0; i < interfaces.length; i++) {
|
for (int i = 0; i < interfaces.length; i++) {
|
||||||
String str = constant_pool.getConstantString(interfaces[i], Constants.CONSTANT_Class);
|
String str = constant_pool.getConstantString(interfaces[i],
|
||||||
|
Constants.CONSTANT_Class);
|
||||||
interface_names[i] = Utility.compactClassName(str, false);
|
interface_names[i] = Utility.compactClassName(str, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor gets all contents as arguments.
|
* Constructor gets all contents as arguments.
|
||||||
*
|
*
|
||||||
* @param class_name_index Class name
|
* @param class_name_index
|
||||||
* @param superclass_name_index Superclass name
|
* Class name
|
||||||
* @param file_name File name
|
* @param superclass_name_index
|
||||||
* @param major Major compiler version
|
* Superclass name
|
||||||
* @param minor Minor compiler version
|
* @param file_name
|
||||||
* @param access_flags Access rights defined by bit flags
|
* File name
|
||||||
* @param constant_pool Array of constants
|
* @param major
|
||||||
* @param interfaces Implemented interfaces
|
* Major compiler version
|
||||||
* @param fields Class fields
|
* @param minor
|
||||||
* @param methods Class methods
|
* Minor compiler version
|
||||||
* @param attributes Class attributes
|
* @param access_flags
|
||||||
|
* Access rights defined by bit flags
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
|
* @param interfaces
|
||||||
|
* Implemented interfaces
|
||||||
|
* @param fields
|
||||||
|
* Class fields
|
||||||
|
* @param methods
|
||||||
|
* Class methods
|
||||||
|
* @param attributes
|
||||||
|
* Class attributes
|
||||||
*/
|
*/
|
||||||
public JavaClass(int class_name_index, int superclass_name_index, String file_name, int major,
|
public JavaClass(int class_name_index, int superclass_name_index,
|
||||||
int minor, int access_flags, ConstantPool constant_pool, int[] interfaces,
|
String file_name, int major, int minor, int access_flags,
|
||||||
Field[] fields, Method[] methods, Attribute[] attributes) {
|
ConstantPool constant_pool, int[] interfaces, Field[] fields,
|
||||||
this(class_name_index, superclass_name_index, file_name, major, minor, access_flags,
|
Method[] methods, Attribute[] attributes) {
|
||||||
constant_pool, interfaces, fields, methods, attributes, HEAP);
|
this(class_name_index, superclass_name_index, file_name, major, minor,
|
||||||
|
access_flags, constant_pool, interfaces, fields, methods,
|
||||||
|
attributes, HEAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitJavaClass(this);
|
v.visitJavaClass(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
/* Print debug information depending on `JavaClass.debug'
|
* Print debug information depending on `JavaClass.debug'
|
||||||
*/
|
*/
|
||||||
static final void Debug(String str) {
|
static final void Debug(String str) {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
@ -218,11 +248,11 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump class to a file.
|
* Dump class to a file.
|
||||||
*
|
*
|
||||||
* @param file Output file
|
* @param file
|
||||||
|
* Output file
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void dump(File file) throws IOException {
|
public void dump(File file) throws IOException {
|
||||||
@ -242,18 +272,17 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump class to a file named file_name.
|
* Dump class to a file named file_name.
|
||||||
*
|
*
|
||||||
* @param _file_name Output file name
|
* @param _file_name
|
||||||
|
* Output file name
|
||||||
* @exception IOException
|
* @exception IOException
|
||||||
*/
|
*/
|
||||||
public void dump(String _file_name) throws IOException {
|
public void dump(String _file_name) throws IOException {
|
||||||
dump(new File(_file_name));
|
dump(new File(_file_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return class in binary format
|
* @return class in binary format
|
||||||
*/
|
*/
|
||||||
@ -274,22 +303,22 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return s.toByteArray();
|
return s.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump Java class to output stream in binary format.
|
* Dump Java class to output stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output stream
|
* @param file
|
||||||
|
* Output stream
|
||||||
* @exception IOException
|
* @exception IOException
|
||||||
*/
|
*/
|
||||||
public void dump(OutputStream file) throws IOException {
|
public void dump(OutputStream file) throws IOException {
|
||||||
dump(new DataOutputStream(file));
|
dump(new DataOutputStream(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump Java class to output stream in binary format.
|
* Dump Java class to output stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output stream
|
* @param file
|
||||||
|
* Output stream
|
||||||
* @exception IOException
|
* @exception IOException
|
||||||
*/
|
*/
|
||||||
public void dump(DataOutputStream file) throws IOException {
|
public void dump(DataOutputStream file) throws IOException {
|
||||||
@ -323,7 +352,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
file.flush();
|
file.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Attributes of the class.
|
* @return Attributes of the class.
|
||||||
*/
|
*/
|
||||||
@ -331,7 +359,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return attributes;
|
return attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Class name.
|
* @return Class name.
|
||||||
*/
|
*/
|
||||||
@ -339,7 +366,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return class_name;
|
return class_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Package name.
|
* @return Package name.
|
||||||
*/
|
*/
|
||||||
@ -347,7 +373,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return package_name;
|
return package_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Class name index.
|
* @return Class name index.
|
||||||
*/
|
*/
|
||||||
@ -355,7 +380,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return class_name_index;
|
return class_name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Constant pool.
|
* @return Constant pool.
|
||||||
*/
|
*/
|
||||||
@ -363,17 +387,15 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return constant_pool;
|
return constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Fields, i.e., variables of the class. Like the JVM spec
|
* @return Fields, i.e., variables of the class. Like the JVM spec mandates
|
||||||
* mandates for the classfile format, these fields are those specific to
|
* for the classfile format, these fields are those specific to this
|
||||||
* this class, and not those of the superclass or superinterfaces.
|
* class, and not those of the superclass or superinterfaces.
|
||||||
*/
|
*/
|
||||||
public Field[] getFields() {
|
public Field[] getFields() {
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return File name of class, aka SourceFile attribute value
|
* @return File name of class, aka SourceFile attribute value
|
||||||
*/
|
*/
|
||||||
@ -381,7 +403,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return file_name;
|
return file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Names of implemented interfaces.
|
* @return Names of implemented interfaces.
|
||||||
*/
|
*/
|
||||||
@ -389,7 +410,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return interface_names;
|
return interface_names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Indices in constant pool of implemented interfaces.
|
* @return Indices in constant pool of implemented interfaces.
|
||||||
*/
|
*/
|
||||||
@ -397,7 +417,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return interfaces;
|
return interfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Major number of class file version.
|
* @return Major number of class file version.
|
||||||
*/
|
*/
|
||||||
@ -405,7 +424,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return major;
|
return major;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Methods of the class.
|
* @return Methods of the class.
|
||||||
*/
|
*/
|
||||||
@ -413,7 +431,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return methods;
|
return methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A org.apache.bcel.classfile.Method corresponding to
|
* @return A org.apache.bcel.classfile.Method corresponding to
|
||||||
* java.lang.reflect.Method if any
|
* java.lang.reflect.Method if any
|
||||||
@ -421,7 +438,8 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
public Method getMethod(java.lang.reflect.Method m) {
|
public Method getMethod(java.lang.reflect.Method m) {
|
||||||
for (int i = 0; i < methods.length; i++) {
|
for (int i = 0; i < methods.length; i++) {
|
||||||
Method method = methods[i];
|
Method method = methods[i];
|
||||||
if (m.getName().equals(method.getName()) && (m.getModifiers() == method.getModifiers())
|
if (m.getName().equals(method.getName())
|
||||||
|
&& (m.getModifiers() == method.getModifiers())
|
||||||
&& Type.getSignature(m).equals(method.getSignature())) {
|
&& Type.getSignature(m).equals(method.getSignature())) {
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
@ -429,7 +447,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Minor number of class file version.
|
* @return Minor number of class file version.
|
||||||
*/
|
*/
|
||||||
@ -437,7 +454,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return minor;
|
return minor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return sbsolute path to file where this class was read from
|
* @return sbsolute path to file where this class was read from
|
||||||
*/
|
*/
|
||||||
@ -445,7 +461,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return source_file_name;
|
return source_file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Superclass name.
|
* @return Superclass name.
|
||||||
*/
|
*/
|
||||||
@ -453,7 +468,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return superclass_name;
|
return superclass_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Class name index.
|
* @return Class name index.
|
||||||
*/
|
*/
|
||||||
@ -474,47 +488,46 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param attributes .
|
* @param attributes
|
||||||
|
* .
|
||||||
*/
|
*/
|
||||||
public void setAttributes(Attribute[] attributes) {
|
public void setAttributes(Attribute[] attributes) {
|
||||||
this.attributes = attributes;
|
this.attributes = attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param class_name .
|
* @param class_name
|
||||||
|
* .
|
||||||
*/
|
*/
|
||||||
public void setClassName(String class_name) {
|
public void setClassName(String class_name) {
|
||||||
this.class_name = class_name;
|
this.class_name = class_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param class_name_index .
|
* @param class_name_index
|
||||||
|
* .
|
||||||
*/
|
*/
|
||||||
public void setClassNameIndex(int class_name_index) {
|
public void setClassNameIndex(int class_name_index) {
|
||||||
this.class_name_index = class_name_index;
|
this.class_name_index = class_name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param constant_pool .
|
* @param constant_pool
|
||||||
|
* .
|
||||||
*/
|
*/
|
||||||
public void setConstantPool(ConstantPool constant_pool) {
|
public void setConstantPool(ConstantPool constant_pool) {
|
||||||
this.constant_pool = constant_pool;
|
this.constant_pool = constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param fields .
|
* @param fields
|
||||||
|
* .
|
||||||
*/
|
*/
|
||||||
public void setFields(Field[] fields) {
|
public void setFields(Field[] fields) {
|
||||||
this.fields = fields;
|
this.fields = fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set File name of class, aka SourceFile attribute value
|
* Set File name of class, aka SourceFile attribute value
|
||||||
*/
|
*/
|
||||||
@ -522,47 +535,46 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
this.file_name = file_name;
|
this.file_name = file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param interface_names .
|
* @param interface_names
|
||||||
|
* .
|
||||||
*/
|
*/
|
||||||
public void setInterfaceNames(String[] interface_names) {
|
public void setInterfaceNames(String[] interface_names) {
|
||||||
this.interface_names = interface_names;
|
this.interface_names = interface_names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param interfaces .
|
* @param interfaces
|
||||||
|
* .
|
||||||
*/
|
*/
|
||||||
public void setInterfaces(int[] interfaces) {
|
public void setInterfaces(int[] interfaces) {
|
||||||
this.interfaces = interfaces;
|
this.interfaces = interfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param major .
|
* @param major
|
||||||
|
* .
|
||||||
*/
|
*/
|
||||||
public void setMajor(int major) {
|
public void setMajor(int major) {
|
||||||
this.major = major;
|
this.major = major;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param methods .
|
* @param methods
|
||||||
|
* .
|
||||||
*/
|
*/
|
||||||
public void setMethods(Method[] methods) {
|
public void setMethods(Method[] methods) {
|
||||||
this.methods = methods;
|
this.methods = methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param minor .
|
* @param minor
|
||||||
|
* .
|
||||||
*/
|
*/
|
||||||
public void setMinor(int minor) {
|
public void setMinor(int minor) {
|
||||||
this.minor = minor;
|
this.minor = minor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set absolute path to file this class was read from.
|
* Set absolute path to file this class was read from.
|
||||||
*/
|
*/
|
||||||
@ -570,33 +582,34 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
this.source_file_name = source_file_name;
|
this.source_file_name = source_file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param superclass_name .
|
* @param superclass_name
|
||||||
|
* .
|
||||||
*/
|
*/
|
||||||
public void setSuperclassName(String superclass_name) {
|
public void setSuperclassName(String superclass_name) {
|
||||||
this.superclass_name = superclass_name;
|
this.superclass_name = superclass_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param superclass_name_index .
|
* @param superclass_name_index
|
||||||
|
* .
|
||||||
*/
|
*/
|
||||||
public void setSuperclassNameIndex(int superclass_name_index) {
|
public void setSuperclassNameIndex(int superclass_name_index) {
|
||||||
this.superclass_name_index = superclass_name_index;
|
this.superclass_name_index = superclass_name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representing class contents.
|
* @return String representing class contents.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String access = Utility.accessToString(access_flags, true);
|
String access = Utility.accessToString(access_flags, true);
|
||||||
access = access.equals("") ? "" : (access + " ");
|
access = access.equals("") ? "" : (access + " ");
|
||||||
StringBuffer buf = new StringBuffer(128);
|
StringBuffer buf = new StringBuffer(128);
|
||||||
buf.append(access).append(Utility.classOrInterface(access_flags)).append(" ").append(
|
buf.append(access).append(Utility.classOrInterface(access_flags))
|
||||||
class_name).append(" extends ").append(
|
.append(" ").append(class_name).append(" extends ")
|
||||||
Utility.compactClassName(superclass_name, false)).append('\n');
|
.append(Utility.compactClassName(superclass_name, false))
|
||||||
|
.append('\n');
|
||||||
int size = interfaces.length;
|
int size = interfaces.length;
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
buf.append("implements\t\t");
|
buf.append("implements\t\t");
|
||||||
@ -610,9 +623,11 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
}
|
}
|
||||||
buf.append("filename\t\t").append(file_name).append('\n');
|
buf.append("filename\t\t").append(file_name).append('\n');
|
||||||
buf.append("compiled from\t\t").append(source_file_name).append('\n');
|
buf.append("compiled from\t\t").append(source_file_name).append('\n');
|
||||||
buf.append("compiler version\t").append(major).append(".").append(minor).append('\n');
|
buf.append("compiler version\t").append(major).append(".")
|
||||||
|
.append(minor).append('\n');
|
||||||
buf.append("access flags\t\t").append(access_flags).append('\n');
|
buf.append("access flags\t\t").append(access_flags).append('\n');
|
||||||
buf.append("constant pool\t\t").append(constant_pool.getLength()).append(" entries\n");
|
buf.append("constant pool\t\t").append(constant_pool.getLength())
|
||||||
|
.append(" entries\n");
|
||||||
buf.append("ACC_SUPER flag\t\t").append(isSuper()).append("\n");
|
buf.append("ACC_SUPER flag\t\t").append(isSuper()).append("\n");
|
||||||
if (attributes.length > 0) {
|
if (attributes.length > 0) {
|
||||||
buf.append("\nAttribute(s):\n");
|
buf.append("\nAttribute(s):\n");
|
||||||
@ -635,7 +650,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final String indent(Object obj) {
|
private static final String indent(Object obj) {
|
||||||
StringTokenizer tok = new StringTokenizer(obj.toString(), "\n");
|
StringTokenizer tok = new StringTokenizer(obj.toString(), "\n");
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
@ -645,7 +659,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this class
|
* @return deep copy of this class
|
||||||
*/
|
*/
|
||||||
@ -654,8 +667,8 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
try {
|
try {
|
||||||
c = (JavaClass) clone();
|
c = (JavaClass) clone();
|
||||||
c.constant_pool = constant_pool.copy();
|
c.constant_pool = constant_pool.copy();
|
||||||
c.interfaces = (int[]) interfaces.clone();
|
c.interfaces = interfaces.clone();
|
||||||
c.interface_names = (String[]) interface_names.clone();
|
c.interface_names = interface_names.clone();
|
||||||
c.fields = new Field[fields.length];
|
c.fields = new Field[fields.length];
|
||||||
for (int i = 0; i < fields.length; i++) {
|
for (int i = 0; i < fields.length; i++) {
|
||||||
c.fields[i] = fields[i].copy(c.constant_pool);
|
c.fields[i] = fields[i].copy(c.constant_pool);
|
||||||
@ -673,50 +686,48 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isSuper() {
|
public final boolean isSuper() {
|
||||||
return (access_flags & Constants.ACC_SUPER) != 0;
|
return (access_flags & Constants.ACC_SUPER) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean isClass() {
|
public final boolean isClass() {
|
||||||
return (access_flags & Constants.ACC_INTERFACE) == 0;
|
return (access_flags & Constants.ACC_INTERFACE) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return returns either HEAP (generated), FILE, or ZIP
|
* @return returns either HEAP (generated), FILE, or ZIP
|
||||||
*/
|
*/
|
||||||
public final byte getSource() {
|
public final byte getSource() {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************* New repository functionality *********************/
|
/********************* New repository functionality *********************/
|
||||||
/**
|
/**
|
||||||
* Gets the ClassRepository which holds its definition. By default
|
* Gets the ClassRepository which holds its definition. By default this is
|
||||||
* this is the same as SyntheticRepository.getInstance();
|
* the same as SyntheticRepository.getInstance();
|
||||||
*/
|
*/
|
||||||
public org.apache.bcel.util.Repository getRepository() {
|
public org.apache.bcel.util.Repository getRepository() {
|
||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the ClassRepository which loaded the JavaClass.
|
* Sets the ClassRepository which loaded the JavaClass. Should be called
|
||||||
* Should be called immediately after parsing is done.
|
* immediately after parsing is done.
|
||||||
*/
|
*/
|
||||||
public void setRepository(org.apache.bcel.util.Repository repository) {
|
public void setRepository(org.apache.bcel.util.Repository repository) {
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Equivalent to runtime "instanceof" operator.
|
* Equivalent to runtime "instanceof" operator.
|
||||||
*
|
*
|
||||||
* @return true if this JavaClass is derived from the super class
|
* @return true if this JavaClass is derived from the super class
|
||||||
* @throws ClassNotFoundException if superclasses or superinterfaces
|
* @throws ClassNotFoundException
|
||||||
* of this object can't be found
|
* if superclasses or superinterfaces of this object can't be
|
||||||
|
* found
|
||||||
*/
|
*/
|
||||||
public final boolean instanceOf( JavaClass super_class ) throws ClassNotFoundException {
|
public final boolean instanceOf(JavaClass super_class)
|
||||||
|
throws ClassNotFoundException {
|
||||||
if (this.equals(super_class)) {
|
if (this.equals(super_class)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -732,15 +743,17 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true, if this class is an implementation of interface inter
|
* @return true, if this class is an implementation of interface inter
|
||||||
* @throws ClassNotFoundException if superclasses or superinterfaces
|
* @throws ClassNotFoundException
|
||||||
* of this class can't be found
|
* if superclasses or superinterfaces of this class can't be
|
||||||
|
* found
|
||||||
*/
|
*/
|
||||||
public boolean implementationOf( JavaClass inter ) throws ClassNotFoundException {
|
public boolean implementationOf(JavaClass inter)
|
||||||
|
throws ClassNotFoundException {
|
||||||
if (!inter.isInterface()) {
|
if (!inter.isInterface()) {
|
||||||
throw new IllegalArgumentException(inter.getClassName() + " is no interface");
|
throw new IllegalArgumentException(inter.getClassName()
|
||||||
|
+ " is no interface");
|
||||||
}
|
}
|
||||||
if (this.equals(inter)) {
|
if (this.equals(inter)) {
|
||||||
return true;
|
return true;
|
||||||
@ -754,11 +767,11 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the superclass for this JavaClass object, or null if this
|
* @return the superclass for this JavaClass object, or null if this is
|
||||||
* is java.lang.Object
|
* java.lang.Object
|
||||||
* @throws ClassNotFoundException if the superclass can't be found
|
* @throws ClassNotFoundException
|
||||||
|
* if the superclass can't be found
|
||||||
*/
|
*/
|
||||||
public JavaClass getSuperClass() throws ClassNotFoundException {
|
public JavaClass getSuperClass() throws ClassNotFoundException {
|
||||||
if ("java.lang.Object".equals(getClassName())) {
|
if ("java.lang.Object".equals(getClassName())) {
|
||||||
@ -767,22 +780,22 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return repository.loadClass(getSuperclassName());
|
return repository.loadClass(getSuperclassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return list of super classes of this class in ascending order, i.e.,
|
* @return list of super classes of this class in ascending order, i.e.,
|
||||||
* java.lang.Object is always the last element
|
* java.lang.Object is always the last element
|
||||||
* @throws ClassNotFoundException if any of the superclasses can't be found
|
* @throws ClassNotFoundException
|
||||||
|
* if any of the superclasses can't be found
|
||||||
*/
|
*/
|
||||||
public JavaClass[] getSuperClasses() throws ClassNotFoundException {
|
public JavaClass[] getSuperClasses() throws ClassNotFoundException {
|
||||||
JavaClass clazz = this;
|
JavaClass clazz = this;
|
||||||
List<JavaClass> allSuperClasses = new ArrayList<JavaClass>();
|
List<JavaClass> allSuperClasses = new ArrayList<JavaClass>();
|
||||||
for (clazz = clazz.getSuperClass(); clazz != null; clazz = clazz.getSuperClass()) {
|
for (clazz = clazz.getSuperClass(); clazz != null; clazz = clazz
|
||||||
|
.getSuperClass()) {
|
||||||
allSuperClasses.add(clazz);
|
allSuperClasses.add(clazz);
|
||||||
}
|
}
|
||||||
return (JavaClass[]) allSuperClasses.toArray(new JavaClass[allSuperClasses.size()]);
|
return allSuperClasses.toArray(new JavaClass[allSuperClasses.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get interfaces directly implemented by this JavaClass.
|
* Get interfaces directly implemented by this JavaClass.
|
||||||
*/
|
*/
|
||||||
@ -795,7 +808,6 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return classes;
|
return classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all interfaces implemented by this JavaClass (transitively).
|
* Get all interfaces implemented by this JavaClass (transitively).
|
||||||
*/
|
*/
|
||||||
@ -818,10 +830,9 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
queue.enqueue(_interfaces[i]);
|
queue.enqueue(_interfaces[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (JavaClass[]) allInterfaces.toArray(new JavaClass[allInterfaces.size()]);
|
return allInterfaces.toArray(new JavaClass[allInterfaces.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Comparison strategy object
|
* @return Comparison strategy object
|
||||||
*/
|
*/
|
||||||
@ -829,42 +840,41 @@ public class JavaClass extends AccessFlags implements Cloneable, Node, Comparabl
|
|||||||
return _cmp;
|
return _cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param comparator Comparison strategy object
|
* @param comparator
|
||||||
|
* Comparison strategy object
|
||||||
*/
|
*/
|
||||||
public static void setComparator(BCELComparator comparator) {
|
public static void setComparator(BCELComparator comparator) {
|
||||||
_cmp = comparator;
|
_cmp = comparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value as defined by given BCELComparator strategy.
|
* Return value as defined by given BCELComparator strategy. By default two
|
||||||
* By default two JavaClass objects are said to be equal when
|
* JavaClass objects are said to be equal when their class names are equal.
|
||||||
* their class names are equal.
|
|
||||||
*
|
*
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return _cmp.equals(this, obj);
|
return _cmp.equals(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the natural ordering of two JavaClasses.
|
* Return the natural ordering of two JavaClasses. This ordering is based on
|
||||||
* This ordering is based on the class name
|
* the class name
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int compareTo(Object obj) {
|
public int compareTo(Object obj) {
|
||||||
return getClassName().compareTo(((JavaClass) obj).getClassName());
|
return getClassName().compareTo(((JavaClass) obj).getClassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value as defined by given BCELComparator strategy.
|
* Return value as defined by given BCELComparator strategy. By default
|
||||||
* By default return the hashcode of the class name.
|
* return the hashcode of the class name.
|
||||||
*
|
*
|
||||||
* @see java.lang.Object#hashCode()
|
* @see java.lang.Object#hashCode()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return _cmp.hashCode(this);
|
return _cmp.hashCode(this);
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ import java.io.Serializable;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a (PC offset, line number) pair, i.e., a line number in
|
* This class represents a (PC offset, line number) pair, i.e., a line number in
|
||||||
* the source that corresponds to a relative address in the byte code. This
|
* the source that corresponds to a relative address in the byte code. This is
|
||||||
* is used for debugging purposes.
|
* used for debugging purposes.
|
||||||
*
|
*
|
||||||
* @version $Id: LineNumber.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: LineNumber.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -32,10 +32,13 @@ import java.io.Serializable;
|
|||||||
*/
|
*/
|
||||||
public final class LineNumber implements Cloneable, Node, Serializable {
|
public final class LineNumber implements Cloneable, Node, Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int start_pc; // Program Counter (PC) corresponds to line
|
private int start_pc; // Program Counter (PC) corresponds to line
|
||||||
private int line_number; // number in source file
|
private int line_number; // number in source file
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object.
|
* Initialize from another object.
|
||||||
*/
|
*/
|
||||||
@ -43,43 +46,46 @@ public final class LineNumber implements Cloneable, Node, Serializable {
|
|||||||
this(c.getStartPC(), c.getLineNumber());
|
this(c.getStartPC(), c.getLineNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param file Input stream
|
*
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
LineNumber(DataInputStream file) throws IOException {
|
LineNumber(DataInputStream file) throws IOException {
|
||||||
this(file.readUnsignedShort(), file.readUnsignedShort());
|
this(file.readUnsignedShort(), file.readUnsignedShort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param start_pc Program Counter (PC) corresponds to
|
* @param start_pc
|
||||||
* @param line_number line number in source file
|
* Program Counter (PC) corresponds to
|
||||||
|
* @param line_number
|
||||||
|
* line number in source file
|
||||||
*/
|
*/
|
||||||
public LineNumber(int start_pc, int line_number) {
|
public LineNumber(int start_pc, int line_number) {
|
||||||
this.start_pc = start_pc;
|
this.start_pc = start_pc;
|
||||||
this.line_number = line_number;
|
this.line_number = line_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitLineNumber(this);
|
v.visitLineNumber(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump line number/pc pair to file stream in binary format.
|
* Dump line number/pc pair to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
@ -87,7 +93,6 @@ public final class LineNumber implements Cloneable, Node, Serializable {
|
|||||||
file.writeShort(line_number);
|
file.writeShort(line_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Corresponding source line
|
* @return Corresponding source line
|
||||||
*/
|
*/
|
||||||
@ -95,7 +100,6 @@ public final class LineNumber implements Cloneable, Node, Serializable {
|
|||||||
return line_number;
|
return line_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return PC in code
|
* @return PC in code
|
||||||
*/
|
*/
|
||||||
@ -103,31 +107,30 @@ public final class LineNumber implements Cloneable, Node, Serializable {
|
|||||||
return start_pc;
|
return start_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param line_number the source line number
|
* @param line_number
|
||||||
|
* the source line number
|
||||||
*/
|
*/
|
||||||
public final void setLineNumber(int line_number) {
|
public final void setLineNumber(int line_number) {
|
||||||
this.line_number = line_number;
|
this.line_number = line_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param start_pc the pc for this line number
|
* @param start_pc
|
||||||
|
* the pc for this line number
|
||||||
*/
|
*/
|
||||||
public final void setStartPC(int start_pc) {
|
public final void setStartPC(int start_pc) {
|
||||||
this.start_pc = start_pc;
|
this.start_pc = start_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation
|
* @return String representation
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return "LineNumber(" + start_pc + ", " + line_number + ")";
|
return "LineNumber(" + start_pc + ", " + line_number + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this object
|
* @return deep copy of this object
|
||||||
*/
|
*/
|
||||||
|
@ -22,9 +22,9 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a table of line numbers for debugging
|
* This class represents a table of line numbers for debugging purposes. This
|
||||||
* purposes. This attribute is used by the <em>Code</em> attribute. It
|
* attribute is used by the <em>Code</em> attribute. It contains pairs of PCs
|
||||||
* contains pairs of PCs and line numbers.
|
* and line numbers.
|
||||||
*
|
*
|
||||||
* @version $Id: LineNumberTable.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: LineNumberTable.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -33,42 +33,53 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class LineNumberTable extends Attribute {
|
public final class LineNumberTable extends Attribute {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int line_number_table_length;
|
private int line_number_table_length;
|
||||||
private LineNumber[] line_number_table; // Table of line/numbers pairs
|
private LineNumber[] line_number_table; // Table of line/numbers pairs
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use copy() for a physical copy.
|
* references (shallow copy). Use copy() for a physical copy.
|
||||||
*/
|
*/
|
||||||
public LineNumberTable(LineNumberTable c) {
|
public LineNumberTable(LineNumberTable c) {
|
||||||
this(c.getNameIndex(), c.getLength(), c.getLineNumberTable(), c.getConstantPool());
|
this(c.getNameIndex(), c.getLength(), c.getLineNumberTable(), c
|
||||||
|
.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @param name_index Index of name
|
* @param name_index Index of name
|
||||||
|
*
|
||||||
* @param length Content length in bytes
|
* @param length Content length in bytes
|
||||||
|
*
|
||||||
* @param line_number_table Table of line/numbers pairs
|
* @param line_number_table Table of line/numbers pairs
|
||||||
|
*
|
||||||
* @param constant_pool Array of constants
|
* @param constant_pool Array of constants
|
||||||
*/
|
*/
|
||||||
public LineNumberTable(int name_index, int length, LineNumber[] line_number_table,
|
public LineNumberTable(int name_index, int length,
|
||||||
ConstantPool constant_pool) {
|
LineNumber[] line_number_table, ConstantPool constant_pool) {
|
||||||
super(Constants.ATTR_LINE_NUMBER_TABLE, name_index, length, constant_pool);
|
super(Constants.ATTR_LINE_NUMBER_TABLE, name_index, length,
|
||||||
|
constant_pool);
|
||||||
setLineNumberTable(line_number_table);
|
setLineNumberTable(line_number_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param name_index Index of name
|
*
|
||||||
* @param length Content length in bytes
|
* @param name_index
|
||||||
* @param file Input stream
|
* Index of name
|
||||||
* @param constant_pool Array of constants
|
* @param length
|
||||||
|
* Content length in bytes
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
LineNumberTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
LineNumberTable(int name_index, int length, DataInputStream file,
|
||||||
throws IOException {
|
ConstantPool constant_pool) throws IOException {
|
||||||
this(name_index, length, (LineNumber[]) null, constant_pool);
|
this(name_index, length, (LineNumber[]) null, constant_pool);
|
||||||
line_number_table_length = (file.readUnsignedShort());
|
line_number_table_length = (file.readUnsignedShort());
|
||||||
line_number_table = new LineNumber[line_number_table_length];
|
line_number_table = new LineNumber[line_number_table_length];
|
||||||
@ -77,25 +88,27 @@ public final class LineNumberTable extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitLineNumberTable(this);
|
v.visitLineNumberTable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump line number table attribute to file stream in binary format.
|
* Dump line number table attribute to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
super.dump(file);
|
super.dump(file);
|
||||||
file.writeShort(line_number_table_length);
|
file.writeShort(line_number_table_length);
|
||||||
@ -104,7 +117,6 @@ public final class LineNumberTable extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Array of (pc offset, line number) pairs.
|
* @return Array of (pc offset, line number) pairs.
|
||||||
*/
|
*/
|
||||||
@ -112,19 +124,20 @@ public final class LineNumberTable extends Attribute {
|
|||||||
return line_number_table;
|
return line_number_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param line_number_table the line number entries for this table
|
* @param line_number_table
|
||||||
|
* the line number entries for this table
|
||||||
*/
|
*/
|
||||||
public final void setLineNumberTable(LineNumber[] line_number_table) {
|
public final void setLineNumberTable(LineNumber[] line_number_table) {
|
||||||
this.line_number_table = line_number_table;
|
this.line_number_table = line_number_table;
|
||||||
line_number_table_length = (line_number_table == null) ? 0 : line_number_table.length;
|
line_number_table_length = (line_number_table == null) ? 0
|
||||||
|
: line_number_table.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
StringBuffer line = new StringBuffer();
|
StringBuffer line = new StringBuffer();
|
||||||
@ -144,11 +157,11 @@ public final class LineNumberTable extends Attribute {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map byte code positions to source code lines.
|
* Map byte code positions to source code lines.
|
||||||
*
|
*
|
||||||
* @param pos byte code offset
|
* @param pos
|
||||||
|
* byte code offset
|
||||||
* @return corresponding line in source code
|
* @return corresponding line in source code
|
||||||
*/
|
*/
|
||||||
public int getSourceLine(int pos) {
|
public int getSourceLine(int pos) {
|
||||||
@ -157,7 +170,8 @@ public final class LineNumberTable extends Attribute {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int min_index = -1, min = -1;
|
int min_index = -1, min = -1;
|
||||||
/* Do a binary search since the array is ordered.
|
/*
|
||||||
|
* Do a binary search since the array is ordered.
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
int i = (l + r) / 2;
|
int i = (l + r) / 2;
|
||||||
@ -169,16 +183,18 @@ public final class LineNumberTable extends Attribute {
|
|||||||
} else {
|
} else {
|
||||||
l = i + 1;
|
l = i + 1;
|
||||||
}
|
}
|
||||||
/* If exact match can't be found (which is the most common case)
|
/*
|
||||||
* return the line number that corresponds to the greatest index less
|
* If exact match can't be found (which is the most common case)
|
||||||
* than pos.
|
* return the line number that corresponds to the greatest index
|
||||||
|
* less than pos.
|
||||||
*/
|
*/
|
||||||
if (j < pos && j > min) {
|
if (j < pos && j > min) {
|
||||||
min = j;
|
min = j;
|
||||||
min_index = i;
|
min_index = i;
|
||||||
}
|
}
|
||||||
} while (l <= r);
|
} while (l <= r);
|
||||||
/* It's possible that we did not find any valid entry for the bytecode
|
/*
|
||||||
|
* It's possible that we did not find any valid entry for the bytecode
|
||||||
* offset we were looking for.
|
* offset we were looking for.
|
||||||
*/
|
*/
|
||||||
if (min_index < 0) {
|
if (min_index < 0) {
|
||||||
@ -187,10 +203,10 @@ public final class LineNumberTable extends Attribute {
|
|||||||
return line_number_table[min_index].getLineNumber();
|
return line_number_table[min_index].getLineNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this attribute
|
* @return deep copy of this attribute
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Attribute copy(ConstantPool _constant_pool) {
|
public Attribute copy(ConstantPool _constant_pool) {
|
||||||
LineNumberTable c = (LineNumberTable) clone();
|
LineNumberTable c = (LineNumberTable) clone();
|
||||||
c.line_number_table = new LineNumber[line_number_table_length];
|
c.line_number_table = new LineNumber[line_number_table_length];
|
||||||
@ -201,7 +217,6 @@ public final class LineNumberTable extends Attribute {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final int getTableLength() {
|
public final int getTableLength() {
|
||||||
return line_number_table_length;
|
return line_number_table_length;
|
||||||
}
|
}
|
||||||
|
@ -30,49 +30,62 @@ import org.apache.bcel.Constants;
|
|||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
* @see LocalVariableTable
|
* @see LocalVariableTable
|
||||||
*/
|
*/
|
||||||
public final class LocalVariable implements Constants, Cloneable, Node, Serializable {
|
public final class LocalVariable implements Constants, Cloneable, Node,
|
||||||
|
Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int start_pc; // Range in which the variable is valid
|
private int start_pc; // Range in which the variable is valid
|
||||||
private int length;
|
private int length;
|
||||||
private int name_index; // Index in constant pool of variable name
|
private int name_index; // Index in constant pool of variable name
|
||||||
private int signature_index; // Index of variable signature
|
private int signature_index; // Index of variable signature
|
||||||
private int index; /* Variable is `index'th local variable on
|
private int index; /*
|
||||||
* this method's frame.
|
* Variable is `index'th local variable on this method's
|
||||||
|
* frame.
|
||||||
*/
|
*/
|
||||||
private ConstantPool constant_pool;
|
private ConstantPool constant_pool;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use copy() for a physical copy.
|
* references (shallow copy). Use copy() for a physical copy.
|
||||||
*/
|
*/
|
||||||
public LocalVariable(LocalVariable c) {
|
public LocalVariable(LocalVariable c) {
|
||||||
this(c.getStartPC(), c.getLength(), c.getNameIndex(), c.getSignatureIndex(), c.getIndex(),
|
this(c.getStartPC(), c.getLength(), c.getNameIndex(), c
|
||||||
c.getConstantPool());
|
.getSignatureIndex(), c.getIndex(), c.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param file Input stream
|
*
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
LocalVariable(DataInputStream file, ConstantPool constant_pool) throws IOException {
|
LocalVariable(DataInputStream file, ConstantPool constant_pool)
|
||||||
this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file
|
throws IOException {
|
||||||
.readUnsignedShort(), file.readUnsignedShort(), constant_pool);
|
this(file.readUnsignedShort(), file.readUnsignedShort(), file
|
||||||
|
.readUnsignedShort(), file.readUnsignedShort(), file
|
||||||
|
.readUnsignedShort(), constant_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param start_pc Range in which the variable
|
* @param start_pc
|
||||||
* @param length ... is valid
|
* Range in which the variable
|
||||||
* @param name_index Index in constant pool of variable name
|
* @param length
|
||||||
* @param signature_index Index of variable's signature
|
* ... is valid
|
||||||
* @param index Variable is `index'th local variable on the method's frame
|
* @param name_index
|
||||||
* @param constant_pool Array of constants
|
* Index in constant pool of variable name
|
||||||
|
* @param signature_index
|
||||||
|
* Index of variable's signature
|
||||||
|
* @param index
|
||||||
|
* Variable is `index'th local variable on the method's frame
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
public LocalVariable(int start_pc, int length, int name_index, int signature_index, int index,
|
public LocalVariable(int start_pc, int length, int name_index,
|
||||||
ConstantPool constant_pool) {
|
int signature_index, int index, ConstantPool constant_pool) {
|
||||||
this.start_pc = start_pc;
|
this.start_pc = start_pc;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.name_index = name_index;
|
this.name_index = name_index;
|
||||||
@ -81,23 +94,24 @@ public final class LocalVariable implements Constants, Cloneable, Node, Serializ
|
|||||||
this.constant_pool = constant_pool;
|
this.constant_pool = constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitLocalVariable(this);
|
v.visitLocalVariable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump local variable to file stream in binary format.
|
* Dump local variable to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
@ -108,7 +122,6 @@ public final class LocalVariable implements Constants, Cloneable, Node, Serializ
|
|||||||
file.writeShort(index);
|
file.writeShort(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Constant pool used by this object.
|
* @return Constant pool used by this object.
|
||||||
*/
|
*/
|
||||||
@ -116,7 +129,6 @@ public final class LocalVariable implements Constants, Cloneable, Node, Serializ
|
|||||||
return constant_pool;
|
return constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Variable is valid within getStartPC() .. getStartPC()+getLength()
|
* @return Variable is valid within getStartPC() .. getStartPC()+getLength()
|
||||||
*/
|
*/
|
||||||
@ -124,7 +136,6 @@ public final class LocalVariable implements Constants, Cloneable, Node, Serializ
|
|||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Variable name.
|
* @return Variable name.
|
||||||
*/
|
*/
|
||||||
@ -134,7 +145,6 @@ public final class LocalVariable implements Constants, Cloneable, Node, Serializ
|
|||||||
return c.getBytes();
|
return c.getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Index in constant pool of variable name.
|
* @return Index in constant pool of variable name.
|
||||||
*/
|
*/
|
||||||
@ -142,17 +152,16 @@ public final class LocalVariable implements Constants, Cloneable, Node, Serializ
|
|||||||
return name_index;
|
return name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Signature.
|
* @return Signature.
|
||||||
*/
|
*/
|
||||||
public final String getSignature() {
|
public final String getSignature() {
|
||||||
ConstantUtf8 c;
|
ConstantUtf8 c;
|
||||||
c = (ConstantUtf8) constant_pool.getConstant(signature_index, CONSTANT_Utf8);
|
c = (ConstantUtf8) constant_pool.getConstant(signature_index,
|
||||||
|
CONSTANT_Utf8);
|
||||||
return c.getBytes();
|
return c.getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Index in constant pool of variable signature.
|
* @return Index in constant pool of variable signature.
|
||||||
*/
|
*/
|
||||||
@ -160,7 +169,6 @@ public final class LocalVariable implements Constants, Cloneable, Node, Serializ
|
|||||||
return signature_index;
|
return signature_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return index of register where variable is stored
|
* @return index of register where variable is stored
|
||||||
*/
|
*/
|
||||||
@ -168,7 +176,6 @@ public final class LocalVariable implements Constants, Cloneable, Node, Serializ
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Start of range where he variable is valid
|
* @return Start of range where he variable is valid
|
||||||
*/
|
*/
|
||||||
@ -176,65 +183,66 @@ public final class LocalVariable implements Constants, Cloneable, Node, Serializ
|
|||||||
return start_pc;
|
return start_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param constant_pool Constant pool to be used for this object.
|
* @param constant_pool
|
||||||
|
* Constant pool to be used for this object.
|
||||||
*/
|
*/
|
||||||
public final void setConstantPool(ConstantPool constant_pool) {
|
public final void setConstantPool(ConstantPool constant_pool) {
|
||||||
this.constant_pool = constant_pool;
|
this.constant_pool = constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param length the length of this local variable
|
* @param length
|
||||||
|
* the length of this local variable
|
||||||
*/
|
*/
|
||||||
public final void setLength(int length) {
|
public final void setLength(int length) {
|
||||||
this.length = length;
|
this.length = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index the index into the constant pool for the name of this variable
|
* @param name_index
|
||||||
|
* the index into the constant pool for the name of this variable
|
||||||
*/
|
*/
|
||||||
public final void setNameIndex(int name_index) {
|
public final void setNameIndex(int name_index) {
|
||||||
this.name_index = name_index;
|
this.name_index = name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param signature_index the index into the constant pool for the signature of this variable
|
* @param signature_index
|
||||||
|
* the index into the constant pool for the signature of this
|
||||||
|
* variable
|
||||||
*/
|
*/
|
||||||
public final void setSignatureIndex(int signature_index) {
|
public final void setSignatureIndex(int signature_index) {
|
||||||
this.signature_index = signature_index;
|
this.signature_index = signature_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param index the index in the local variable table of this variable
|
* @param index
|
||||||
|
* the index in the local variable table of this variable
|
||||||
*/
|
*/
|
||||||
public final void setIndex(int index) {
|
public final void setIndex(int index) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param start_pc Specify range where the local variable is valid.
|
* @param start_pc
|
||||||
|
* Specify range where the local variable is valid.
|
||||||
*/
|
*/
|
||||||
public final void setStartPC(int start_pc) {
|
public final void setStartPC(int start_pc) {
|
||||||
this.start_pc = start_pc;
|
this.start_pc = start_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string representation.
|
* @return string representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
String name = getName(), signature = Utility.signatureToString(getSignature());
|
String name = getName(), signature = Utility
|
||||||
return "LocalVariable(start_pc = " + start_pc + ", length = " + length + ", index = "
|
.signatureToString(getSignature());
|
||||||
+ index + ":" + signature + " " + name + ")";
|
return "LocalVariable(start_pc = " + start_pc + ", length = " + length
|
||||||
|
+ ", index = " + index + ":" + signature + " " + name + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this object
|
* @return deep copy of this object
|
||||||
*/
|
*/
|
||||||
|
@ -22,8 +22,8 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents colection of local variables in a
|
* This class represents colection of local variables in a method. This
|
||||||
* method. This attribute is contained in the <em>Code</em> attribute.
|
* attribute is contained in the <em>Code</em> attribute.
|
||||||
*
|
*
|
||||||
* @version $Id: LocalVariableTable.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: LocalVariableTable.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -32,42 +32,54 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public class LocalVariableTable extends Attribute {
|
public class LocalVariableTable extends Attribute {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int local_variable_table_length; // Table of local
|
private int local_variable_table_length; // Table of local
|
||||||
private LocalVariable[] local_variable_table; // variables
|
private LocalVariable[] local_variable_table; // variables
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use copy() for a physical copy.
|
* references (shallow copy). Use copy() for a physical copy.
|
||||||
*/
|
*/
|
||||||
public LocalVariableTable(LocalVariableTable c) {
|
public LocalVariableTable(LocalVariableTable c) {
|
||||||
this(c.getNameIndex(), c.getLength(), c.getLocalVariableTable(), c.getConstantPool());
|
this(c.getNameIndex(), c.getLength(), c.getLocalVariableTable(), c
|
||||||
|
.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index Index in constant pool to `LocalVariableTable'
|
* @param name_index
|
||||||
* @param length Content length in bytes
|
* Index in constant pool to `LocalVariableTable'
|
||||||
* @param local_variable_table Table of local variables
|
* @param length
|
||||||
* @param constant_pool Array of constants
|
* Content length in bytes
|
||||||
|
* @param local_variable_table
|
||||||
|
* Table of local variables
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
public LocalVariableTable(int name_index, int length, LocalVariable[] local_variable_table,
|
public LocalVariableTable(int name_index, int length,
|
||||||
ConstantPool constant_pool) {
|
LocalVariable[] local_variable_table, ConstantPool constant_pool) {
|
||||||
super(Constants.ATTR_LOCAL_VARIABLE_TABLE, name_index, length, constant_pool);
|
super(Constants.ATTR_LOCAL_VARIABLE_TABLE, name_index, length,
|
||||||
|
constant_pool);
|
||||||
setLocalVariableTable(local_variable_table);
|
setLocalVariableTable(local_variable_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param name_index Index in constant pool
|
*
|
||||||
* @param length Content length in bytes
|
* @param name_index
|
||||||
* @param file Input stream
|
* Index in constant pool
|
||||||
* @param constant_pool Array of constants
|
* @param length
|
||||||
|
* Content length in bytes
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
LocalVariableTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
LocalVariableTable(int name_index, int length, DataInputStream file,
|
||||||
throws IOException {
|
ConstantPool constant_pool) throws IOException {
|
||||||
this(name_index, length, (LocalVariable[]) null, constant_pool);
|
this(name_index, length, (LocalVariable[]) null, constant_pool);
|
||||||
local_variable_table_length = (file.readUnsignedShort());
|
local_variable_table_length = (file.readUnsignedShort());
|
||||||
local_variable_table = new LocalVariable[local_variable_table_length];
|
local_variable_table = new LocalVariable[local_variable_table_length];
|
||||||
@ -76,25 +88,27 @@ public class LocalVariableTable extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitLocalVariableTable(this);
|
v.visitLocalVariableTable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump local variable table attribute to file stream in binary format.
|
* Dump local variable table attribute to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
super.dump(file);
|
super.dump(file);
|
||||||
file.writeShort(local_variable_table_length);
|
file.writeShort(local_variable_table_length);
|
||||||
@ -103,7 +117,6 @@ public class LocalVariableTable extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Array of local variables of method.
|
* @return Array of local variables of method.
|
||||||
*/
|
*/
|
||||||
@ -111,16 +124,15 @@ public class LocalVariableTable extends Attribute {
|
|||||||
return local_variable_table;
|
return local_variable_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return first matching variable using index
|
* @return first matching variable using index
|
||||||
*
|
*
|
||||||
* @param index the variable slot
|
* @param index
|
||||||
|
* the variable slot
|
||||||
*
|
*
|
||||||
* @return the first LocalVariable that matches the slot or null if not found
|
* @return the first LocalVariable that matches the slot or null if not
|
||||||
|
* found
|
||||||
*
|
*
|
||||||
* @deprecated since 5.2 because multiple variables can share the
|
|
||||||
* same slot, use getLocalVariable(int index, int pc) instead.
|
|
||||||
*/
|
*/
|
||||||
public final LocalVariable getLocalVariable(int index) {
|
public final LocalVariable getLocalVariable(int index) {
|
||||||
for (int i = 0; i < local_variable_table_length; i++) {
|
for (int i = 0; i < local_variable_table_length; i++) {
|
||||||
@ -131,12 +143,14 @@ public class LocalVariableTable extends Attribute {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return matching variable using index when variable is used at supplied pc
|
* @return matching variable using index when variable is used at supplied
|
||||||
|
* pc
|
||||||
*
|
*
|
||||||
* @param index the variable slot
|
* @param index
|
||||||
* @param pc the current pc that this variable is alive
|
* the variable slot
|
||||||
|
* @param pc
|
||||||
|
* the current pc that this variable is alive
|
||||||
*
|
*
|
||||||
* @return the LocalVariable that matches or null if not found
|
* @return the LocalVariable that matches or null if not found
|
||||||
*/
|
*/
|
||||||
@ -153,18 +167,16 @@ public class LocalVariableTable extends Attribute {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void setLocalVariableTable(LocalVariable[] local_variable_table) {
|
public final void setLocalVariableTable(LocalVariable[] local_variable_table) {
|
||||||
this.local_variable_table = local_variable_table;
|
this.local_variable_table = local_variable_table;
|
||||||
local_variable_table_length = (local_variable_table == null)
|
local_variable_table_length = (local_variable_table == null) ? 0
|
||||||
? 0
|
|
||||||
: local_variable_table.length;
|
: local_variable_table.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
StringBuffer buf = new StringBuffer("");
|
StringBuffer buf = new StringBuffer("");
|
||||||
for (int i = 0; i < local_variable_table_length; i++) {
|
for (int i = 0; i < local_variable_table_length; i++) {
|
||||||
@ -176,10 +188,10 @@ public class LocalVariableTable extends Attribute {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this attribute
|
* @return deep copy of this attribute
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Attribute copy(ConstantPool _constant_pool) {
|
public Attribute copy(ConstantPool _constant_pool) {
|
||||||
LocalVariableTable c = (LocalVariableTable) clone();
|
LocalVariableTable c = (LocalVariableTable) clone();
|
||||||
c.local_variable_table = new LocalVariable[local_variable_table_length];
|
c.local_variable_table = new LocalVariable[local_variable_table_length];
|
||||||
@ -190,7 +202,6 @@ public class LocalVariableTable extends Attribute {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final int getTableLength() {
|
public final int getTableLength() {
|
||||||
return local_variable_table_length;
|
return local_variable_table_length;
|
||||||
}
|
}
|
||||||
|
@ -23,17 +23,22 @@ import org.apache.bcel.generic.Type;
|
|||||||
import org.apache.bcel.util.BCELComparator;
|
import org.apache.bcel.util.BCELComparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the method info structure, i.e., the representation
|
* This class represents the method info structure, i.e., the representation for
|
||||||
* for a method in the class. See JVM specification for details.
|
* a method in the class. See JVM specification for details. A method has access
|
||||||
* A method has access flags, a name, a signature and a number of attributes.
|
* flags, a name, a signature and a number of attributes.
|
||||||
*
|
*
|
||||||
* @version $Id: Method.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: Method.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public final class Method extends FieldOrMethod {
|
public final class Method extends FieldOrMethod {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private static BCELComparator _cmp = new BCELComparator() {
|
private static BCELComparator _cmp = new BCELComparator() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object o1, Object o2) {
|
public boolean equals(Object o1, Object o2) {
|
||||||
Method THIS = (Method) o1;
|
Method THIS = (Method) o1;
|
||||||
Method THAT = (Method) o2;
|
Method THAT = (Method) o2;
|
||||||
@ -41,14 +46,13 @@ public final class Method extends FieldOrMethod {
|
|||||||
&& THIS.getSignature().equals(THAT.getSignature());
|
&& THIS.getSignature().equals(THAT.getSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int hashCode(Object o) {
|
public int hashCode(Object o) {
|
||||||
Method THIS = (Method) o;
|
Method THIS = (Method) o;
|
||||||
return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
|
return THIS.getSignature().hashCode() ^ THIS.getName().hashCode();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor, all attributes have to be defined via `setXXX'
|
* Empty constructor, all attributes have to be defined via `setXXX'
|
||||||
* methods. Use at your own risk.
|
* methods. Use at your own risk.
|
||||||
@ -56,7 +60,6 @@ public final class Method extends FieldOrMethod {
|
|||||||
public Method() {
|
public Method() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use clone() for a physical copy.
|
* references (shallow copy). Use clone() for a physical copy.
|
||||||
@ -65,44 +68,50 @@ public final class Method extends FieldOrMethod {
|
|||||||
super(c);
|
super(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param file Input stream
|
*
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ClassFormatException
|
* @throws ClassFormatException
|
||||||
*/
|
*/
|
||||||
Method(DataInputStream file, ConstantPool constant_pool) throws IOException,
|
Method(DataInputStream file, ConstantPool constant_pool)
|
||||||
ClassFormatException {
|
throws IOException, ClassFormatException {
|
||||||
super(file, constant_pool);
|
super(file, constant_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param access_flags Access rights of method
|
* @param access_flags
|
||||||
* @param name_index Points to field name in constant pool
|
* Access rights of method
|
||||||
* @param signature_index Points to encoded signature
|
* @param name_index
|
||||||
* @param attributes Collection of attributes
|
* Points to field name in constant pool
|
||||||
* @param constant_pool Array of constants
|
* @param signature_index
|
||||||
|
* Points to encoded signature
|
||||||
|
* @param attributes
|
||||||
|
* Collection of attributes
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
public Method(int access_flags, int name_index, int signature_index, Attribute[] attributes,
|
public Method(int access_flags, int name_index, int signature_index,
|
||||||
ConstantPool constant_pool) {
|
Attribute[] attributes, ConstantPool constant_pool) {
|
||||||
super(access_flags, name_index, signature_index, attributes, constant_pool);
|
super(access_flags, name_index, signature_index, attributes,
|
||||||
|
constant_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitMethod(this);
|
v.visitMethod(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Code attribute of method, if any
|
* @return Code attribute of method, if any
|
||||||
*/
|
*/
|
||||||
@ -115,7 +124,6 @@ public final class Method extends FieldOrMethod {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return ExceptionTable attribute of method, if any, i.e., list all
|
* @return ExceptionTable attribute of method, if any, i.e., list all
|
||||||
* exceptions the method may throw not exception handlers!
|
* exceptions the method may throw not exception handlers!
|
||||||
@ -129,9 +137,9 @@ public final class Method extends FieldOrMethod {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return LocalVariableTable of code attribute if any, i.e. the call is forwarded
|
* @return LocalVariableTable of code attribute if any, i.e. the call is
|
||||||
* to the Code atribute.
|
* forwarded to the Code atribute.
|
||||||
*/
|
*/
|
||||||
public final LocalVariableTable getLocalVariableTable() {
|
public final LocalVariableTable getLocalVariableTable() {
|
||||||
Code code = getCode();
|
Code code = getCode();
|
||||||
@ -141,9 +149,9 @@ public final class Method extends FieldOrMethod {
|
|||||||
return code.getLocalVariableTable();
|
return code.getLocalVariableTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return LineNumberTable of code attribute if any, i.e. the call is forwarded
|
* @return LineNumberTable of code attribute if any, i.e. the call is
|
||||||
* to the Code atribute.
|
* forwarded to the Code atribute.
|
||||||
*/
|
*/
|
||||||
public final LineNumberTable getLineNumberTable() {
|
public final LineNumberTable getLineNumberTable() {
|
||||||
Code code = getCode();
|
Code code = getCode();
|
||||||
@ -153,25 +161,27 @@ public final class Method extends FieldOrMethod {
|
|||||||
return code.getLineNumberTable();
|
return code.getLineNumberTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return string representation close to declaration format,
|
* Return string representation close to declaration format, `public static
|
||||||
* `public static void main(String[] args) throws IOException', e.g.
|
* void main(String[] args) throws IOException', e.g.
|
||||||
*
|
*
|
||||||
* @return String representation of the method.
|
* @return String representation of the method.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
ConstantUtf8 c;
|
ConstantUtf8 c;
|
||||||
String name, signature, access; // Short cuts to constant pool
|
String name, signature, access; // Short cuts to constant pool
|
||||||
StringBuffer buf;
|
StringBuffer buf;
|
||||||
access = Utility.accessToString(access_flags);
|
access = Utility.accessToString(access_flags);
|
||||||
// Get name and signature from constant pool
|
// Get name and signature from constant pool
|
||||||
c = (ConstantUtf8) constant_pool.getConstant(signature_index, Constants.CONSTANT_Utf8);
|
c = (ConstantUtf8) constant_pool.getConstant(signature_index,
|
||||||
|
Constants.CONSTANT_Utf8);
|
||||||
signature = c.getBytes();
|
signature = c.getBytes();
|
||||||
c = (ConstantUtf8) constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8);
|
c = (ConstantUtf8) constant_pool.getConstant(name_index,
|
||||||
|
Constants.CONSTANT_Utf8);
|
||||||
name = c.getBytes();
|
name = c.getBytes();
|
||||||
signature = Utility.methodSignatureToString(signature, name, access, true,
|
signature = Utility.methodSignatureToString(signature, name, access,
|
||||||
getLocalVariableTable());
|
true, getLocalVariableTable());
|
||||||
buf = new StringBuffer(signature);
|
buf = new StringBuffer(signature);
|
||||||
for (int i = 0; i < attributes_count; i++) {
|
for (int i = 0; i < attributes_count; i++) {
|
||||||
Attribute a = attributes[i];
|
Attribute a = attributes[i];
|
||||||
@ -189,7 +199,6 @@ public final class Method extends FieldOrMethod {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this method
|
* @return deep copy of this method
|
||||||
*/
|
*/
|
||||||
@ -197,7 +206,6 @@ public final class Method extends FieldOrMethod {
|
|||||||
return (Method) copy_(_constant_pool);
|
return (Method) copy_(_constant_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return return type of method
|
* @return return type of method
|
||||||
*/
|
*/
|
||||||
@ -205,7 +213,6 @@ public final class Method extends FieldOrMethod {
|
|||||||
return Type.getReturnType(getSignature());
|
return Type.getReturnType(getSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array of method argument types
|
* @return array of method argument types
|
||||||
*/
|
*/
|
||||||
@ -213,7 +220,6 @@ public final class Method extends FieldOrMethod {
|
|||||||
return Type.getArgumentTypes(getSignature());
|
return Type.getArgumentTypes(getSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Comparison strategy object
|
* @return Comparison strategy object
|
||||||
*/
|
*/
|
||||||
@ -221,33 +227,33 @@ public final class Method extends FieldOrMethod {
|
|||||||
return _cmp;
|
return _cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param comparator Comparison strategy object
|
* @param comparator
|
||||||
|
* Comparison strategy object
|
||||||
*/
|
*/
|
||||||
public static void setComparator(BCELComparator comparator) {
|
public static void setComparator(BCELComparator comparator) {
|
||||||
_cmp = comparator;
|
_cmp = comparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value as defined by given BCELComparator strategy.
|
* Return value as defined by given BCELComparator strategy. By default two
|
||||||
* By default two method objects are said to be equal when
|
* method objects are said to be equal when their names and signatures are
|
||||||
* their names and signatures are equal.
|
* equal.
|
||||||
*
|
*
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return _cmp.equals(this, obj);
|
return _cmp.equals(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value as defined by given BCELComparator strategy.
|
* Return value as defined by given BCELComparator strategy. By default
|
||||||
* By default return the hashcode of the method's name XOR signature.
|
* return the hashcode of the method's name XOR signature.
|
||||||
*
|
*
|
||||||
* @see java.lang.Object#hashCode()
|
* @see java.lang.Object#hashCode()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return _cmp.hashCode(this);
|
return _cmp.hashCode(this);
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from <em>Attribute</em> and represents a reference
|
* This class is derived from <em>Attribute</em> and represents a reference to a
|
||||||
* to a PMG attribute.
|
* PMG attribute.
|
||||||
*
|
*
|
||||||
* @version $Id: PMGClass.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: PMGClass.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -31,73 +31,86 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class PMGClass extends Attribute {
|
public final class PMGClass extends Attribute {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int pmg_class_index, pmg_index;
|
private int pmg_class_index, pmg_index;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use clone() for a physical copy.
|
* references (shallow copy). Use clone() for a physical copy.
|
||||||
*/
|
*/
|
||||||
public PMGClass(PMGClass c) {
|
public PMGClass(PMGClass c) {
|
||||||
this(c.getNameIndex(), c.getLength(), c.getPMGIndex(), c.getPMGClassIndex(), c
|
this(c.getNameIndex(), c.getLength(), c.getPMGIndex(), c
|
||||||
.getConstantPool());
|
.getPMGClassIndex(), c.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param name_index Index in constant pool to CONSTANT_Utf8
|
*
|
||||||
* @param length Content length in bytes
|
* @param name_index
|
||||||
* @param file Input stream
|
* Index in constant pool to CONSTANT_Utf8
|
||||||
* @param constant_pool Array of constants
|
* @param length
|
||||||
|
* Content length in bytes
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
PMGClass(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
PMGClass(int name_index, int length, DataInputStream file,
|
||||||
throws IOException {
|
ConstantPool constant_pool) throws IOException {
|
||||||
this(name_index, length, file.readUnsignedShort(), file.readUnsignedShort(), constant_pool);
|
this(name_index, length, file.readUnsignedShort(), file
|
||||||
|
.readUnsignedShort(), constant_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index Index in constant pool to CONSTANT_Utf8
|
* @param name_index
|
||||||
* @param length Content length in bytes
|
* Index in constant pool to CONSTANT_Utf8
|
||||||
* @param pmg_index index in constant pool for source file name
|
* @param length
|
||||||
* @param pmg_class_index Index in constant pool to CONSTANT_Utf8
|
* Content length in bytes
|
||||||
* @param constant_pool Array of constants
|
* @param pmg_index
|
||||||
|
* index in constant pool for source file name
|
||||||
|
* @param pmg_class_index
|
||||||
|
* Index in constant pool to CONSTANT_Utf8
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
public PMGClass(int name_index, int length, int pmg_index, int pmg_class_index,
|
public PMGClass(int name_index, int length, int pmg_index,
|
||||||
ConstantPool constant_pool) {
|
int pmg_class_index, ConstantPool constant_pool) {
|
||||||
super(Constants.ATTR_PMG, name_index, length, constant_pool);
|
super(Constants.ATTR_PMG, name_index, length, constant_pool);
|
||||||
this.pmg_index = pmg_index;
|
this.pmg_index = pmg_index;
|
||||||
this.pmg_class_index = pmg_class_index;
|
this.pmg_class_index = pmg_class_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
System.err.println("Visiting non-standard PMGClass object");
|
System.err.println("Visiting non-standard PMGClass object");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump source file attribute to file stream in binary format.
|
* Dump source file attribute to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
super.dump(file);
|
super.dump(file);
|
||||||
file.writeShort(pmg_index);
|
file.writeShort(pmg_index);
|
||||||
file.writeShort(pmg_class_index);
|
file.writeShort(pmg_class_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Index in constant pool of source file name.
|
* @return Index in constant pool of source file name.
|
||||||
*/
|
*/
|
||||||
@ -105,7 +118,6 @@ public final class PMGClass extends Attribute {
|
|||||||
return pmg_class_index;
|
return pmg_class_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param pmg_class_index
|
* @param pmg_class_index
|
||||||
*/
|
*/
|
||||||
@ -113,7 +125,6 @@ public final class PMGClass extends Attribute {
|
|||||||
this.pmg_class_index = pmg_class_index;
|
this.pmg_class_index = pmg_class_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Index in constant pool of source file name.
|
* @return Index in constant pool of source file name.
|
||||||
*/
|
*/
|
||||||
@ -121,7 +132,6 @@ public final class PMGClass extends Attribute {
|
|||||||
return pmg_index;
|
return pmg_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param pmg_index
|
* @param pmg_index
|
||||||
*/
|
*/
|
||||||
@ -129,7 +139,6 @@ public final class PMGClass extends Attribute {
|
|||||||
this.pmg_index = pmg_index;
|
this.pmg_index = pmg_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return PMG name.
|
* @return PMG name.
|
||||||
*/
|
*/
|
||||||
@ -139,28 +148,27 @@ public final class PMGClass extends Attribute {
|
|||||||
return c.getBytes();
|
return c.getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return PMG class name.
|
* @return PMG class name.
|
||||||
*/
|
*/
|
||||||
public final String getPMGClassName() {
|
public final String getPMGClassName() {
|
||||||
ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(pmg_class_index,
|
ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(
|
||||||
Constants.CONSTANT_Utf8);
|
pmg_class_index, Constants.CONSTANT_Utf8);
|
||||||
return c.getBytes();
|
return c.getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation
|
* @return String representation
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return "PMGClass(" + getPMGName() + ", " + getPMGClassName() + ")";
|
return "PMGClass(" + getPMGName() + ", " + getPMGClassName() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this attribute
|
* @return deep copy of this attribute
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Attribute copy(ConstantPool _constant_pool) {
|
public Attribute copy(ConstantPool _constant_pool) {
|
||||||
return (PMGClass) clone();
|
return (PMGClass) clone();
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from <em>Attribute</em> and represents a reference
|
* This class is derived from <em>Attribute</em> and represents a reference to a
|
||||||
* to a GJ attribute.
|
* GJ attribute.
|
||||||
*
|
*
|
||||||
* @version $Id: Signature.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: Signature.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -32,69 +32,82 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class Signature extends Attribute {
|
public final class Signature extends Attribute {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int signature_index;
|
private int signature_index;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use clone() for a physical copy.
|
* references (shallow copy). Use clone() for a physical copy.
|
||||||
*/
|
*/
|
||||||
public Signature(Signature c) {
|
public Signature(Signature c) {
|
||||||
this(c.getNameIndex(), c.getLength(), c.getSignatureIndex(), c.getConstantPool());
|
this(c.getNameIndex(), c.getLength(), c.getSignatureIndex(), c
|
||||||
|
.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param name_index Index in constant pool to CONSTANT_Utf8
|
*
|
||||||
* @param length Content length in bytes
|
* @param name_index
|
||||||
* @param file Input stream
|
* Index in constant pool to CONSTANT_Utf8
|
||||||
* @param constant_pool Array of constants
|
* @param length
|
||||||
|
* Content length in bytes
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
Signature(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
Signature(int name_index, int length, DataInputStream file,
|
||||||
throws IOException {
|
ConstantPool constant_pool) throws IOException {
|
||||||
this(name_index, length, file.readUnsignedShort(), constant_pool);
|
this(name_index, length, file.readUnsignedShort(), constant_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index Index in constant pool to CONSTANT_Utf8
|
* @param name_index
|
||||||
* @param length Content length in bytes
|
* Index in constant pool to CONSTANT_Utf8
|
||||||
* @param signature_index Index in constant pool to CONSTANT_Utf8
|
* @param length
|
||||||
* @param constant_pool Array of constants
|
* Content length in bytes
|
||||||
|
* @param signature_index
|
||||||
|
* Index in constant pool to CONSTANT_Utf8
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
public Signature(int name_index, int length, int signature_index, ConstantPool constant_pool) {
|
public Signature(int name_index, int length, int signature_index,
|
||||||
|
ConstantPool constant_pool) {
|
||||||
super(Constants.ATTR_SIGNATURE, name_index, length, constant_pool);
|
super(Constants.ATTR_SIGNATURE, name_index, length, constant_pool);
|
||||||
this.signature_index = signature_index;
|
this.signature_index = signature_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
// System.err.println("Visiting non-standard Signature object");
|
// System.err.println("Visiting non-standard Signature object");
|
||||||
v.visitSignature(this);
|
v.visitSignature(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump source file attribute to file stream in binary format.
|
* Dump source file attribute to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
super.dump(file);
|
super.dump(file);
|
||||||
file.writeShort(signature_index);
|
file.writeShort(signature_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Index in constant pool of source file name.
|
* @return Index in constant pool of source file name.
|
||||||
*/
|
*/
|
||||||
@ -102,49 +115,37 @@ public final class Signature extends Attribute {
|
|||||||
return signature_index;
|
return signature_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param signature_index the index info the constant pool of this signature
|
* @param signature_index
|
||||||
|
* the index info the constant pool of this signature
|
||||||
*/
|
*/
|
||||||
public final void setSignatureIndex(int signature_index) {
|
public final void setSignatureIndex(int signature_index) {
|
||||||
this.signature_index = signature_index;
|
this.signature_index = signature_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return GJ signature.
|
* @return GJ signature.
|
||||||
*/
|
*/
|
||||||
public final String getSignature() {
|
public final String getSignature() {
|
||||||
ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(signature_index,
|
ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(
|
||||||
Constants.CONSTANT_Utf8);
|
signature_index, Constants.CONSTANT_Utf8);
|
||||||
return c.getBytes();
|
return c.getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends ByteArrayInputStream to make 'unreading' chars possible.
|
* Extends ByteArrayInputStream to make 'unreading' chars possible.
|
||||||
*/
|
*/
|
||||||
private static final class MyByteArrayInputStream extends ByteArrayInputStream {
|
private static final class MyByteArrayInputStream extends
|
||||||
|
ByteArrayInputStream {
|
||||||
|
|
||||||
MyByteArrayInputStream(String data) {
|
MyByteArrayInputStream(String data) {
|
||||||
super(data.getBytes());
|
super(data.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final int mark() {
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
final String getData() {
|
final String getData() {
|
||||||
return new String(buf);
|
return new String(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final void reset( int p ) {
|
|
||||||
pos = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
final void unread() {
|
final void unread() {
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
pos--;
|
pos--;
|
||||||
@ -152,13 +153,12 @@ public final class Signature extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static boolean identStart(int ch) {
|
private static boolean identStart(int ch) {
|
||||||
return ch == 'T' || ch == 'L';
|
return ch == 'T' || ch == 'L';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final void matchIdent(MyByteArrayInputStream in,
|
||||||
private static final void matchIdent( MyByteArrayInputStream in, StringBuffer buf ) {
|
StringBuffer buf) {
|
||||||
int ch;
|
int ch;
|
||||||
if ((ch = in.read()) == -1) {
|
if ((ch = in.read()) == -1) {
|
||||||
throw new RuntimeException("Illegal signature: " + in.getData()
|
throw new RuntimeException("Illegal signature: " + in.getData()
|
||||||
@ -192,7 +192,8 @@ public final class Signature extends Attribute {
|
|||||||
buf2.append((char) ch);
|
buf2.append((char) ch);
|
||||||
ch = in.read();
|
ch = in.read();
|
||||||
// System.out.println("within ident:"+ (char)ch);
|
// System.out.println("within ident:"+ (char)ch);
|
||||||
} while ((ch != -1) && (Character.isJavaIdentifierPart((char) ch) || (ch == '/')));
|
} while ((ch != -1)
|
||||||
|
&& (Character.isJavaIdentifierPart((char) ch) || (ch == '/')));
|
||||||
buf.append(buf2.toString().replace('/', '.'));
|
buf.append(buf2.toString().replace('/', '.'));
|
||||||
// System.out.println("regular return ident:"+ (char)ch + ":" + buf2);
|
// System.out.println("regular return ident:"+ (char)ch + ":" + buf2);
|
||||||
if (ch != -1) {
|
if (ch != -1) {
|
||||||
@ -200,8 +201,8 @@ public final class Signature extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final void matchGJIdent(MyByteArrayInputStream in,
|
||||||
private static final void matchGJIdent( MyByteArrayInputStream in, StringBuffer buf ) {
|
StringBuffer buf) {
|
||||||
int ch;
|
int ch;
|
||||||
matchIdent(in, buf);
|
matchIdent(in, buf);
|
||||||
ch = in.read();
|
ch = in.read();
|
||||||
@ -209,10 +210,11 @@ public final class Signature extends Attribute {
|
|||||||
// System.out.println("Enter <");
|
// System.out.println("Enter <");
|
||||||
buf.append((char) ch);
|
buf.append((char) ch);
|
||||||
matchGJIdent(in, buf);
|
matchGJIdent(in, buf);
|
||||||
while (((ch = in.read()) != '>') && (ch != ')')) { // List of parameters
|
while (((ch = in.read()) != '>') && (ch != ')')) { // List of
|
||||||
|
// parameters
|
||||||
if (ch == -1) {
|
if (ch == -1) {
|
||||||
throw new RuntimeException("Illegal signature: " + in.getData()
|
throw new RuntimeException("Illegal signature: "
|
||||||
+ " reaching EOF");
|
+ in.getData() + " reaching EOF");
|
||||||
}
|
}
|
||||||
// System.out.println("Still no >");
|
// System.out.println("Still no >");
|
||||||
buf.append(", ");
|
buf.append(", ");
|
||||||
@ -232,11 +234,11 @@ public final class Signature extends Attribute {
|
|||||||
in.unread();
|
in.unread();
|
||||||
return;
|
return;
|
||||||
} else if (ch != ';') {
|
} else if (ch != ';') {
|
||||||
throw new RuntimeException("Illegal signature: " + in.getData() + " read " + (char) ch);
|
throw new RuntimeException("Illegal signature: " + in.getData()
|
||||||
|
+ " read " + (char) ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String translate(String s) {
|
public static String translate(String s) {
|
||||||
// System.out.println("Sig:" + s);
|
// System.out.println("Sig:" + s);
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
@ -244,29 +246,27 @@ public final class Signature extends Attribute {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final boolean isFormalParameterList(String s) {
|
public static final boolean isFormalParameterList(String s) {
|
||||||
return s.startsWith("<") && (s.indexOf(':') > 0);
|
return s.startsWith("<") && (s.indexOf(':') > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final boolean isActualParameterList(String s) {
|
public static final boolean isActualParameterList(String s) {
|
||||||
return s.startsWith("L") && s.endsWith(">;");
|
return s.startsWith("L") && s.endsWith(">;");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation
|
* @return String representation
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
String s = getSignature();
|
String s = getSignature();
|
||||||
return "Signature(" + s + ")";
|
return "Signature(" + s + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this attribute
|
* @return deep copy of this attribute
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Attribute copy(ConstantPool _constant_pool) {
|
public Attribute copy(ConstantPool _constant_pool) {
|
||||||
return (Signature) clone();
|
return (Signature) clone();
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,10 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from <em>Attribute</em> and represents a reference
|
* This class is derived from <em>Attribute</em> and represents a reference to
|
||||||
* to the source file of this class. At most one SourceFile attribute
|
* the source file of this class. At most one SourceFile attribute should appear
|
||||||
* should appear per classfile. The intention of this class is that it is
|
* per classfile. The intention of this class is that it is instantiated from
|
||||||
* instantiated from the <em>Attribute.readAttribute()</em> method.
|
* the <em>Attribute.readAttribute()</em> method.
|
||||||
*
|
*
|
||||||
* @version $Id: SourceFile.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: SourceFile.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -33,75 +33,87 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class SourceFile extends Attribute {
|
public final class SourceFile extends Attribute {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int sourcefile_index;
|
private int sourcefile_index;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use clone() for a physical copy.
|
* references (shallow copy). Use clone() for a physical copy.
|
||||||
*/
|
*/
|
||||||
public SourceFile(SourceFile c) {
|
public SourceFile(SourceFile c) {
|
||||||
this(c.getNameIndex(), c.getLength(), c.getSourceFileIndex(), c.getConstantPool());
|
this(c.getNameIndex(), c.getLength(), c.getSourceFileIndex(), c
|
||||||
|
.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param name_index Index in constant pool to CONSTANT_Utf8
|
*
|
||||||
* @param length Content length in bytes
|
* @param name_index
|
||||||
* @param file Input stream
|
* Index in constant pool to CONSTANT_Utf8
|
||||||
* @param constant_pool Array of constants
|
* @param length
|
||||||
|
* Content length in bytes
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
SourceFile(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
SourceFile(int name_index, int length, DataInputStream file,
|
||||||
throws IOException {
|
ConstantPool constant_pool) throws IOException {
|
||||||
this(name_index, length, file.readUnsignedShort(), constant_pool);
|
this(name_index, length, file.readUnsignedShort(), constant_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index Index in constant pool to CONSTANT_Utf8, which
|
* @param name_index
|
||||||
* should represent the string "SourceFile".
|
* Index in constant pool to CONSTANT_Utf8, which should
|
||||||
* @param length Content length in bytes, the value should be 2.
|
* represent the string "SourceFile".
|
||||||
* @param constant_pool The constant pool that this attribute is
|
* @param length
|
||||||
* associated with.
|
* Content length in bytes, the value should be 2.
|
||||||
* @param sourcefile_index Index in constant pool to CONSTANT_Utf8. This
|
* @param constant_pool
|
||||||
* string will be interpreted as the name of the file from which this
|
* The constant pool that this attribute is associated with.
|
||||||
* class was compiled. It will not be interpreted as indicating the name
|
* @param sourcefile_index
|
||||||
* of the directory contqining the file or an absolute path; this
|
* Index in constant pool to CONSTANT_Utf8. This string will be
|
||||||
* information has to be supplied the consumer of this attribute - in
|
* interpreted as the name of the file from which this class was
|
||||||
* many cases, the JVM.
|
* compiled. It will not be interpreted as indicating the name of
|
||||||
|
* the directory contqining the file or an absolute path; this
|
||||||
|
* information has to be supplied the consumer of this attribute
|
||||||
|
* - in many cases, the JVM.
|
||||||
*/
|
*/
|
||||||
public SourceFile(int name_index, int length, int sourcefile_index, ConstantPool constant_pool) {
|
public SourceFile(int name_index, int length, int sourcefile_index,
|
||||||
|
ConstantPool constant_pool) {
|
||||||
super(Constants.ATTR_SOURCE_FILE, name_index, length, constant_pool);
|
super(Constants.ATTR_SOURCE_FILE, name_index, length, constant_pool);
|
||||||
this.sourcefile_index = sourcefile_index;
|
this.sourcefile_index = sourcefile_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitSourceFile(this);
|
v.visitSourceFile(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump source file attribute to file stream in binary format.
|
* Dump source file attribute to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
super.dump(file);
|
super.dump(file);
|
||||||
file.writeShort(sourcefile_index);
|
file.writeShort(sourcefile_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Index in constant pool of source file name.
|
* @return Index in constant pool of source file name.
|
||||||
*/
|
*/
|
||||||
@ -109,7 +121,6 @@ public final class SourceFile extends Attribute {
|
|||||||
return sourcefile_index;
|
return sourcefile_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param sourcefile_index
|
* @param sourcefile_index
|
||||||
*/
|
*/
|
||||||
@ -117,28 +128,27 @@ public final class SourceFile extends Attribute {
|
|||||||
this.sourcefile_index = sourcefile_index;
|
this.sourcefile_index = sourcefile_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Source file name.
|
* @return Source file name.
|
||||||
*/
|
*/
|
||||||
public final String getSourceFileName() {
|
public final String getSourceFileName() {
|
||||||
ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(sourcefile_index,
|
ConstantUtf8 c = (ConstantUtf8) constant_pool.getConstant(
|
||||||
Constants.CONSTANT_Utf8);
|
sourcefile_index, Constants.CONSTANT_Utf8);
|
||||||
return c.getBytes();
|
return c.getBytes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation
|
* @return String representation
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return "SourceFile(" + getSourceFileName() + ")";
|
return "SourceFile(" + getSourceFileName() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this attribute
|
* @return deep copy of this attribute
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Attribute copy(ConstantPool _constant_pool) {
|
public Attribute copy(ConstantPool _constant_pool) {
|
||||||
return (SourceFile) clone();
|
return (SourceFile) clone();
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,11 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a stack map attribute used for
|
* This class represents a stack map attribute used for preverification of Java
|
||||||
* preverification of Java classes for the <a
|
* classes for the <a href="http://java.sun.com/j2me/"> Java 2 Micro Edition</a>
|
||||||
* href="http://java.sun.com/j2me/"> Java 2 Micro Edition</a>
|
|
||||||
* (J2ME). This attribute is used by the <a
|
* (J2ME). This attribute is used by the <a
|
||||||
* href="http://java.sun.com/products/cldc/">KVM</a> and contained
|
* href="http://java.sun.com/products/cldc/">KVM</a> and contained within the
|
||||||
* within the Code attribute of a method. See CLDC specification
|
* Code attribute of a method. See CLDC specification 5.3.1.2
|
||||||
* 5.3.1.2
|
|
||||||
*
|
*
|
||||||
* @version $Id: StackMap.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: StackMap.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -38,32 +36,43 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class StackMap extends Attribute implements Node {
|
public final class StackMap extends Attribute implements Node {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int map_length;
|
private int map_length;
|
||||||
private StackMapEntry[] map; // Table of stack map entries
|
private StackMapEntry[] map; // Table of stack map entries
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @param name_index Index of name
|
* @param name_index Index of name
|
||||||
|
*
|
||||||
* @param length Content length in bytes
|
* @param length Content length in bytes
|
||||||
|
*
|
||||||
* @param map Table of stack map entries
|
* @param map Table of stack map entries
|
||||||
|
*
|
||||||
* @param constant_pool Array of constants
|
* @param constant_pool Array of constants
|
||||||
*/
|
*/
|
||||||
public StackMap(int name_index, int length, StackMapEntry[] map, ConstantPool constant_pool) {
|
public StackMap(int name_index, int length, StackMapEntry[] map,
|
||||||
|
ConstantPool constant_pool) {
|
||||||
super(Constants.ATTR_STACK_MAP, name_index, length, constant_pool);
|
super(Constants.ATTR_STACK_MAP, name_index, length, constant_pool);
|
||||||
setStackMap(map);
|
setStackMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param name_index Index of name
|
*
|
||||||
* @param length Content length in bytes
|
* @param name_index
|
||||||
* @param file Input stream
|
* Index of name
|
||||||
* @param constant_pool Array of constants
|
* @param length
|
||||||
|
* Content length in bytes
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
StackMap(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
StackMap(int name_index, int length, DataInputStream file,
|
||||||
throws IOException {
|
ConstantPool constant_pool) throws IOException {
|
||||||
this(name_index, length, (StackMapEntry[]) null, constant_pool);
|
this(name_index, length, (StackMapEntry[]) null, constant_pool);
|
||||||
map_length = file.readUnsignedShort();
|
map_length = file.readUnsignedShort();
|
||||||
map = new StackMapEntry[map_length];
|
map = new StackMapEntry[map_length];
|
||||||
@ -72,13 +81,14 @@ public final class StackMap extends Attribute implements Node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump line number table attribute to file stream in binary format.
|
* Dump line number table attribute to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
super.dump(file);
|
super.dump(file);
|
||||||
file.writeShort(map_length);
|
file.writeShort(map_length);
|
||||||
@ -87,7 +97,6 @@ public final class StackMap extends Attribute implements Node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Array of stack map entries
|
* @return Array of stack map entries
|
||||||
*/
|
*/
|
||||||
@ -95,19 +104,19 @@ public final class StackMap extends Attribute implements Node {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param map Array of stack map entries
|
* @param map
|
||||||
|
* Array of stack map entries
|
||||||
*/
|
*/
|
||||||
public final void setStackMap(StackMapEntry[] map) {
|
public final void setStackMap(StackMapEntry[] map) {
|
||||||
this.map = map;
|
this.map = map;
|
||||||
map_length = (map == null) ? 0 : map.length;
|
map_length = (map == null) ? 0 : map.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
StringBuffer buf = new StringBuffer("StackMap(");
|
StringBuffer buf = new StringBuffer("StackMap(");
|
||||||
for (int i = 0; i < map_length; i++) {
|
for (int i = 0; i < map_length; i++) {
|
||||||
@ -120,10 +129,10 @@ public final class StackMap extends Attribute implements Node {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this attribute
|
* @return deep copy of this attribute
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Attribute copy(ConstantPool _constant_pool) {
|
public Attribute copy(ConstantPool _constant_pool) {
|
||||||
StackMap c = (StackMap) clone();
|
StackMap c = (StackMap) clone();
|
||||||
c.map = new StackMapEntry[map_length];
|
c.map = new StackMapEntry[map_length];
|
||||||
@ -134,19 +143,19 @@ public final class StackMap extends Attribute implements Node {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitStackMap(this);
|
v.visitStackMap(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final int getMapLength() {
|
public final int getMapLength() {
|
||||||
return map_length;
|
return map_length;
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,9 @@ import java.io.DataOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a stack map entry recording the types of
|
* This class represents a stack map entry recording the types of local
|
||||||
* local variables and the the of stack items at a given byte code offset.
|
* variables and the the of stack items at a given byte code offset. See CLDC
|
||||||
* See CLDC specification 5.3.1.2
|
* specification 5.3.1.2
|
||||||
*
|
*
|
||||||
* @version $Id: StackMapEntry.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: StackMapEntry.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -39,13 +39,15 @@ public final class StackMapEntry implements Cloneable {
|
|||||||
private StackMapType[] types_of_stack_items;
|
private StackMapType[] types_of_stack_items;
|
||||||
private ConstantPool constant_pool;
|
private ConstantPool constant_pool;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param file Input stream
|
*
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
StackMapEntry(DataInputStream file, ConstantPool constant_pool) throws IOException {
|
StackMapEntry(DataInputStream file, ConstantPool constant_pool)
|
||||||
|
throws IOException {
|
||||||
this(file.readShort(), file.readShort(), null, -1, null, constant_pool);
|
this(file.readShort(), file.readShort(), null, -1, null, constant_pool);
|
||||||
types_of_locals = new StackMapType[number_of_locals];
|
types_of_locals = new StackMapType[number_of_locals];
|
||||||
for (int i = 0; i < number_of_locals; i++) {
|
for (int i = 0; i < number_of_locals; i++) {
|
||||||
@ -58,7 +60,6 @@ public final class StackMapEntry implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public StackMapEntry(int byte_code_offset, int number_of_locals,
|
public StackMapEntry(int byte_code_offset, int number_of_locals,
|
||||||
StackMapType[] types_of_locals, int number_of_stack_items,
|
StackMapType[] types_of_locals, int number_of_stack_items,
|
||||||
StackMapType[] types_of_stack_items, ConstantPool constant_pool) {
|
StackMapType[] types_of_stack_items, ConstantPool constant_pool) {
|
||||||
@ -70,11 +71,11 @@ public final class StackMapEntry implements Cloneable {
|
|||||||
this.constant_pool = constant_pool;
|
this.constant_pool = constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump stack map entry
|
* Dump stack map entry
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
@ -89,10 +90,10 @@ public final class StackMapEntry implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
StringBuffer buf = new StringBuffer(64);
|
StringBuffer buf = new StringBuffer(64);
|
||||||
buf.append("(offset=").append(byte_code_offset);
|
buf.append("(offset=").append(byte_code_offset);
|
||||||
@ -120,57 +121,46 @@ public final class StackMapEntry implements Cloneable {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setByteCodeOffset(int b) {
|
public void setByteCodeOffset(int b) {
|
||||||
byte_code_offset = b;
|
byte_code_offset = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getByteCodeOffset() {
|
public int getByteCodeOffset() {
|
||||||
return byte_code_offset;
|
return byte_code_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setNumberOfLocals(int n) {
|
public void setNumberOfLocals(int n) {
|
||||||
number_of_locals = n;
|
number_of_locals = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getNumberOfLocals() {
|
public int getNumberOfLocals() {
|
||||||
return number_of_locals;
|
return number_of_locals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setTypesOfLocals(StackMapType[] t) {
|
public void setTypesOfLocals(StackMapType[] t) {
|
||||||
types_of_locals = t;
|
types_of_locals = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public StackMapType[] getTypesOfLocals() {
|
public StackMapType[] getTypesOfLocals() {
|
||||||
return types_of_locals;
|
return types_of_locals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setNumberOfStackItems(int n) {
|
public void setNumberOfStackItems(int n) {
|
||||||
number_of_stack_items = n;
|
number_of_stack_items = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getNumberOfStackItems() {
|
public int getNumberOfStackItems() {
|
||||||
return number_of_stack_items;
|
return number_of_stack_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setTypesOfStackItems(StackMapType[] t) {
|
public void setTypesOfStackItems(StackMapType[] t) {
|
||||||
types_of_stack_items = t;
|
types_of_stack_items = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public StackMapType[] getTypesOfStackItems() {
|
public StackMapType[] getTypesOfStackItems() {
|
||||||
return types_of_stack_items;
|
return types_of_stack_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this object
|
* @return deep copy of this object
|
||||||
*/
|
*/
|
||||||
@ -182,19 +172,18 @@ public final class StackMapEntry implements Cloneable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitStackMapEntry(this);
|
v.visitStackMapEntry(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Constant pool used by this object.
|
* @return Constant pool used by this object.
|
||||||
*/
|
*/
|
||||||
@ -202,9 +191,9 @@ public final class StackMapEntry implements Cloneable {
|
|||||||
return constant_pool;
|
return constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param constant_pool Constant pool to be used for this object.
|
* @param constant_pool
|
||||||
|
* Constant pool to be used for this object.
|
||||||
*/
|
*/
|
||||||
public final void setConstantPool(ConstantPool constant_pool) {
|
public final void setConstantPool(ConstantPool constant_pool) {
|
||||||
this.constant_pool = constant_pool;
|
this.constant_pool = constant_pool;
|
||||||
|
@ -22,8 +22,8 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the type of a local variable or item on stack
|
* This class represents the type of a local variable or item on stack used in
|
||||||
* used in the StackMap entries.
|
* the StackMap entries.
|
||||||
*
|
*
|
||||||
* @version $Id: StackMapType.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: StackMapType.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -37,13 +37,15 @@ public final class StackMapType implements Cloneable {
|
|||||||
private int index = -1; // Index to CONSTANT_Class or offset
|
private int index = -1; // Index to CONSTANT_Class or offset
|
||||||
private ConstantPool constant_pool;
|
private ConstantPool constant_pool;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param file Input stream
|
*
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
StackMapType(DataInputStream file, ConstantPool constant_pool) throws IOException {
|
StackMapType(DataInputStream file, ConstantPool constant_pool)
|
||||||
|
throws IOException {
|
||||||
this(file.readByte(), -1, constant_pool);
|
this(file.readByte(), -1, constant_pool);
|
||||||
if (hasIndex()) {
|
if (hasIndex()) {
|
||||||
setIndex(file.readShort());
|
setIndex(file.readShort());
|
||||||
@ -51,10 +53,11 @@ public final class StackMapType implements Cloneable {
|
|||||||
setConstantPool(constant_pool);
|
setConstantPool(constant_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param type type tag as defined in the Constants interface
|
* @param type
|
||||||
* @param index index to constant pool, or byte code offset
|
* type tag as defined in the Constants interface
|
||||||
|
* @param index
|
||||||
|
* index to constant pool, or byte code offset
|
||||||
*/
|
*/
|
||||||
public StackMapType(byte type, int index, ConstantPool constant_pool) {
|
public StackMapType(byte type, int index, ConstantPool constant_pool) {
|
||||||
setType(type);
|
setType(type);
|
||||||
@ -62,7 +65,6 @@ public final class StackMapType implements Cloneable {
|
|||||||
setConstantPool(constant_pool);
|
setConstantPool(constant_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setType(byte t) {
|
public void setType(byte t) {
|
||||||
if ((t < Constants.ITEM_Bogus) || (t > Constants.ITEM_NewObject)) {
|
if ((t < Constants.ITEM_Bogus) || (t > Constants.ITEM_NewObject)) {
|
||||||
throw new RuntimeException("Illegal type for StackMapType: " + t);
|
throw new RuntimeException("Illegal type for StackMapType: " + t);
|
||||||
@ -70,29 +72,27 @@ public final class StackMapType implements Cloneable {
|
|||||||
type = t;
|
type = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public byte getType() {
|
public byte getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setIndex(int t) {
|
public void setIndex(int t) {
|
||||||
index = t;
|
index = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return index to constant pool if type == ITEM_Object, or offset
|
* @return index to constant pool if type == ITEM_Object, or offset in byte
|
||||||
* in byte code, if type == ITEM_NewObject, and -1 otherwise
|
* code, if type == ITEM_NewObject, and -1 otherwise
|
||||||
*/
|
*/
|
||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump type entries to file.
|
* Dump type entries to file.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
@ -102,20 +102,21 @@ public final class StackMapType implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return true, if type is either ITEM_Object or ITEM_NewObject
|
* @return true, if type is either ITEM_Object or ITEM_NewObject
|
||||||
*/
|
*/
|
||||||
public final boolean hasIndex() {
|
public final boolean hasIndex() {
|
||||||
return ((type == Constants.ITEM_Object) || (type == Constants.ITEM_NewObject));
|
return ((type == Constants.ITEM_Object) || (type == Constants.ITEM_NewObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String printIndex() {
|
private String printIndex() {
|
||||||
if (type == Constants.ITEM_Object) {
|
if (type == Constants.ITEM_Object) {
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
return ", class=<unknown>";
|
return ", class=<unknown>";
|
||||||
}
|
}
|
||||||
return ", class=" + constant_pool.constantToString(index, Constants.CONSTANT_Class);
|
return ", class="
|
||||||
|
+ constant_pool.constantToString(index,
|
||||||
|
Constants.CONSTANT_Class);
|
||||||
} else if (type == Constants.ITEM_NewObject) {
|
} else if (type == Constants.ITEM_NewObject) {
|
||||||
return ", offset=" + index;
|
return ", offset=" + index;
|
||||||
} else {
|
} else {
|
||||||
@ -123,15 +124,14 @@ public final class StackMapType implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation
|
* @return String representation
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return "(type=" + Constants.ITEM_NAMES[type] + printIndex() + ")";
|
return "(type=" + Constants.ITEM_NAMES[type] + printIndex() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this object
|
* @return deep copy of this object
|
||||||
*/
|
*/
|
||||||
@ -143,7 +143,6 @@ public final class StackMapType implements Cloneable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Constant pool used by this object.
|
* @return Constant pool used by this object.
|
||||||
*/
|
*/
|
||||||
@ -151,9 +150,9 @@ public final class StackMapType implements Cloneable {
|
|||||||
return constant_pool;
|
return constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param constant_pool Constant pool to be used for this object.
|
* @param constant_pool
|
||||||
|
* Constant pool to be used for this object.
|
||||||
*/
|
*/
|
||||||
public final void setConstantPool(ConstantPool constant_pool) {
|
public final void setConstantPool(ConstantPool constant_pool) {
|
||||||
this.constant_pool = constant_pool;
|
this.constant_pool = constant_pool;
|
||||||
|
@ -23,12 +23,11 @@ import org.apache.bcel.Constants;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is derived from <em>Attribute</em> and declares this class as
|
* This class is derived from <em>Attribute</em> and declares this class as
|
||||||
* `synthetic', i.e., it needs special handling. The JVM specification
|
* `synthetic', i.e., it needs special handling. The JVM specification states "A
|
||||||
* states "A class member that does not appear in the source code must be
|
* class member that does not appear in the source code must be marked using a
|
||||||
* marked using a Synthetic attribute." It may appear in the ClassFile
|
* Synthetic attribute." It may appear in the ClassFile attribute table, a
|
||||||
* attribute table, a field_info table or a method_info table. This class
|
* field_info table or a method_info table. This class is intended to be
|
||||||
* is intended to be instantiated from the
|
* instantiated from the <em>Attribute.readAttribute()</em> method.
|
||||||
* <em>Attribute.readAttribute()</em> method.
|
|
||||||
*
|
*
|
||||||
* @version $Id: Synthetic.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: Synthetic.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -36,9 +35,12 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class Synthetic extends Attribute {
|
public final class Synthetic extends Attribute {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private byte[] bytes;
|
private byte[] bytes;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use copy() for a physical copy.
|
* references (shallow copy). Use copy() for a physical copy.
|
||||||
@ -47,31 +49,38 @@ public final class Synthetic extends Attribute {
|
|||||||
this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
|
this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name_index Index in constant pool to CONSTANT_Utf8, which
|
* @param name_index
|
||||||
* should represent the string "Synthetic".
|
* Index in constant pool to CONSTANT_Utf8, which should
|
||||||
* @param length Content length in bytes - should be zero.
|
* represent the string "Synthetic".
|
||||||
* @param bytes Attribute contents
|
* @param length
|
||||||
* @param constant_pool The constant pool this attribute is associated
|
* Content length in bytes - should be zero.
|
||||||
* with.
|
* @param bytes
|
||||||
|
* Attribute contents
|
||||||
|
* @param constant_pool
|
||||||
|
* The constant pool this attribute is associated with.
|
||||||
*/
|
*/
|
||||||
public Synthetic(int name_index, int length, byte[] bytes, ConstantPool constant_pool) {
|
public Synthetic(int name_index, int length, byte[] bytes,
|
||||||
|
ConstantPool constant_pool) {
|
||||||
super(Constants.ATTR_SYNTHETIC, name_index, length, constant_pool);
|
super(Constants.ATTR_SYNTHETIC, name_index, length, constant_pool);
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param name_index Index in constant pool to CONSTANT_Utf8
|
*
|
||||||
* @param length Content length in bytes
|
* @param name_index
|
||||||
* @param file Input stream
|
* Index in constant pool to CONSTANT_Utf8
|
||||||
* @param constant_pool Array of constants
|
* @param length
|
||||||
|
* Content length in bytes
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
Synthetic(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
Synthetic(int name_index, int length, DataInputStream file,
|
||||||
throws IOException {
|
ConstantPool constant_pool) throws IOException {
|
||||||
this(name_index, length, (byte[]) null, constant_pool);
|
this(name_index, length, (byte[]) null, constant_pool);
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
bytes = new byte[length];
|
bytes = new byte[length];
|
||||||
@ -80,25 +89,27 @@ public final class Synthetic extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitSynthetic(this);
|
v.visitSynthetic(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump source file attribute to file stream in binary format.
|
* Dump source file attribute to file stream in binary format.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
super.dump(file);
|
super.dump(file);
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
@ -106,7 +117,6 @@ public final class Synthetic extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return data bytes.
|
* @return data bytes.
|
||||||
*/
|
*/
|
||||||
@ -114,7 +124,6 @@ public final class Synthetic extends Attribute {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bytes
|
* @param bytes
|
||||||
*/
|
*/
|
||||||
@ -122,10 +131,10 @@ public final class Synthetic extends Attribute {
|
|||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
StringBuffer buf = new StringBuffer("Synthetic");
|
StringBuffer buf = new StringBuffer("Synthetic");
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
@ -134,10 +143,10 @@ public final class Synthetic extends Attribute {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this attribute
|
* @return deep copy of this attribute
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Attribute copy(ConstantPool _constant_pool) {
|
public Attribute copy(ConstantPool _constant_pool) {
|
||||||
Synthetic c = (Synthetic) clone();
|
Synthetic c = (Synthetic) clone();
|
||||||
if (bytes != null) {
|
if (bytes != null) {
|
||||||
|
@ -22,18 +22,18 @@ import java.io.IOException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a reference to an unknown (i.e.,
|
* This class represents a reference to an unknown (i.e., application-specific)
|
||||||
* application-specific) attribute of a class. It is instantiated from the
|
* attribute of a class. It is instantiated from the
|
||||||
* <em>Attribute.readAttribute()</em> method. Applications that need to
|
* <em>Attribute.readAttribute()</em> method. Applications that need to read in
|
||||||
* read in application-specific attributes should create an <a
|
* application-specific attributes should create an <a
|
||||||
* href="./AttributeReader.html">AttributeReader</a> implementation and
|
* href="./AttributeReader.html">AttributeReader</a> implementation and attach
|
||||||
* attach it via <a
|
* it via <a href="./Attribute.html#addAttributeReader(java.lang.String,
|
||||||
* href="./Attribute.html#addAttributeReader(java.lang.String,
|
|
||||||
* org.apache.bcel.classfile.AttributeReader)">Attribute.addAttributeReader</a>.
|
* org.apache.bcel.classfile.AttributeReader)">Attribute.addAttributeReader</a>.
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* @version $Id: Unknown.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: Unknown.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @see org.apache.bcel.classfile.Attribute
|
* @see org.apache.bcel.classfile.Attribute
|
||||||
@ -42,24 +42,27 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class Unknown extends Attribute {
|
public final class Unknown extends Attribute {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private byte[] bytes;
|
private byte[] bytes;
|
||||||
private String name;
|
private String name;
|
||||||
private static Map unknown_attributes = new HashMap();
|
private static Map<String, Unknown> unknown_attributes = new HashMap<String, Unknown>();
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return array of unknown attributes, but just one for each kind.
|
* @return array of unknown attributes, but just one for each kind.
|
||||||
*/
|
*/
|
||||||
static Unknown[] getUnknownAttributes() {
|
static Unknown[] getUnknownAttributes() {
|
||||||
Unknown[] unknowns = new Unknown[unknown_attributes.size()];
|
Unknown[] unknowns = new Unknown[unknown_attributes.size()];
|
||||||
Iterator entries = unknown_attributes.values().iterator();
|
Iterator<Unknown> entries = unknown_attributes.values().iterator();
|
||||||
for (int i = 0; entries.hasNext(); i++) {
|
for (int i = 0; entries.hasNext(); i++) {
|
||||||
unknowns[i] = (Unknown) entries.next();
|
unknowns[i] = entries.next();
|
||||||
}
|
}
|
||||||
unknown_attributes.clear();
|
unknown_attributes.clear();
|
||||||
return unknowns;
|
return unknowns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize from another object. Note that both objects use the same
|
* Initialize from another object. Note that both objects use the same
|
||||||
* references (shallow copy). Use clone() for a physical copy.
|
* references (shallow copy). Use clone() for a physical copy.
|
||||||
@ -68,34 +71,42 @@ public final class Unknown extends Attribute {
|
|||||||
this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
|
this(c.getNameIndex(), c.getLength(), c.getBytes(), c.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a non-standard attribute.
|
* Create a non-standard attribute.
|
||||||
*
|
*
|
||||||
* @param name_index Index in constant pool
|
* @param name_index
|
||||||
* @param length Content length in bytes
|
* Index in constant pool
|
||||||
* @param bytes Attribute contents
|
* @param length
|
||||||
* @param constant_pool Array of constants
|
* Content length in bytes
|
||||||
|
* @param bytes
|
||||||
|
* Attribute contents
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
*/
|
*/
|
||||||
public Unknown(int name_index, int length, byte[] bytes, ConstantPool constant_pool) {
|
public Unknown(int name_index, int length, byte[] bytes,
|
||||||
|
ConstantPool constant_pool) {
|
||||||
super(Constants.ATTR_UNKNOWN, name_index, length, constant_pool);
|
super(Constants.ATTR_UNKNOWN, name_index, length, constant_pool);
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
name = ((ConstantUtf8) constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8))
|
name = ((ConstantUtf8) constant_pool.getConstant(name_index,
|
||||||
.getBytes();
|
Constants.CONSTANT_Utf8)).getBytes();
|
||||||
unknown_attributes.put(name, this);
|
unknown_attributes.put(name, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct object from file stream.
|
* Construct object from file stream.
|
||||||
* @param name_index Index in constant pool
|
*
|
||||||
* @param length Content length in bytes
|
* @param name_index
|
||||||
* @param file Input stream
|
* Index in constant pool
|
||||||
* @param constant_pool Array of constants
|
* @param length
|
||||||
|
* Content length in bytes
|
||||||
|
* @param file
|
||||||
|
* Input stream
|
||||||
|
* @param constant_pool
|
||||||
|
* Array of constants
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
Unknown(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
|
Unknown(int name_index, int length, DataInputStream file,
|
||||||
throws IOException {
|
ConstantPool constant_pool) throws IOException {
|
||||||
this(name_index, length, (byte[]) null, constant_pool);
|
this(name_index, length, (byte[]) null, constant_pool);
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
bytes = new byte[length];
|
bytes = new byte[length];
|
||||||
@ -103,25 +114,27 @@ public final class Unknown extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by objects that are traversing the nodes of the tree implicitely
|
* 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,
|
* defined by the contents of a Java class. I.e., the hierarchy of methods,
|
||||||
* fields, attributes, etc. spawns a tree of objects.
|
* fields, attributes, etc. spawns a tree of objects.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitUnknown(this);
|
v.visitUnknown(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump unknown bytes to file stream.
|
* Dump unknown bytes to file stream.
|
||||||
*
|
*
|
||||||
* @param file Output file stream
|
* @param file
|
||||||
|
* Output file stream
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final void dump(DataOutputStream file) throws IOException {
|
public final void dump(DataOutputStream file) throws IOException {
|
||||||
super.dump(file);
|
super.dump(file);
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
@ -129,7 +142,6 @@ public final class Unknown extends Attribute {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return data bytes.
|
* @return data bytes.
|
||||||
*/
|
*/
|
||||||
@ -137,7 +149,6 @@ public final class Unknown extends Attribute {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return name of attribute.
|
* @return name of attribute.
|
||||||
*/
|
*/
|
||||||
@ -145,18 +156,18 @@ public final class Unknown extends Attribute {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bytes the bytes to set
|
* @param bytes
|
||||||
|
* the bytes to set
|
||||||
*/
|
*/
|
||||||
public final void setBytes(byte[] bytes) {
|
public final void setBytes(byte[] bytes) {
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
if (length == 0 || bytes == null) {
|
if (length == 0 || bytes == null) {
|
||||||
return "(Unknown attribute " + name + ")";
|
return "(Unknown attribute " + name + ")";
|
||||||
@ -172,10 +183,10 @@ public final class Unknown extends Attribute {
|
|||||||
return "(Unknown attribute " + name + ": " + hex + ")";
|
return "(Unknown attribute " + name + ": " + hex + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return deep copy of this attribute
|
* @return deep copy of this attribute
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Attribute copy(ConstantPool _constant_pool) {
|
public Attribute copy(ConstantPool _constant_pool) {
|
||||||
Unknown c = (Unknown) clone();
|
Unknown c = (Unknown) clone();
|
||||||
if (bytes != null) {
|
if (bytes != null) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -17,9 +17,9 @@
|
|||||||
package org.apache.bcel.classfile;
|
package org.apache.bcel.classfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to make use of the Visitor pattern programming style.
|
* Interface to make use of the Visitor pattern programming style. I.e. a class
|
||||||
* I.e. a class that implements this interface can traverse the contents of
|
* that implements this interface can traverse the contents of a Java class just
|
||||||
* a Java class just by calling the `accept' method which all classes have.
|
* by calling the `accept' method which all classes have.
|
||||||
*
|
*
|
||||||
* @version $Id: Visitor.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: Visitor.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -32,96 +32,65 @@ public interface Visitor {
|
|||||||
// public void visitAnnotationDefault(AnnotationDefault obj);
|
// public void visitAnnotationDefault(AnnotationDefault obj);
|
||||||
public void visitCode(Code obj);
|
public void visitCode(Code obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitCodeException(CodeException obj);
|
public void visitCodeException(CodeException obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitConstantClass(ConstantClass obj);
|
public void visitConstantClass(ConstantClass obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitConstantDouble(ConstantDouble obj);
|
public void visitConstantDouble(ConstantDouble obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitConstantFieldref(ConstantFieldref obj);
|
public void visitConstantFieldref(ConstantFieldref obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitConstantFloat(ConstantFloat obj);
|
public void visitConstantFloat(ConstantFloat obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitConstantInteger(ConstantInteger obj);
|
public void visitConstantInteger(ConstantInteger obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj);
|
public void visitConstantInterfaceMethodref(ConstantInterfaceMethodref obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitConstantLong(ConstantLong obj);
|
public void visitConstantLong(ConstantLong obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitConstantMethodref(ConstantMethodref obj);
|
public void visitConstantMethodref(ConstantMethodref obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitConstantNameAndType(ConstantNameAndType obj);
|
public void visitConstantNameAndType(ConstantNameAndType obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitConstantPool(ConstantPool obj);
|
public void visitConstantPool(ConstantPool obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitConstantString(ConstantString obj);
|
public void visitConstantString(ConstantString obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitConstantUtf8(ConstantUtf8 obj);
|
public void visitConstantUtf8(ConstantUtf8 obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitConstantValue(ConstantValue obj);
|
public void visitConstantValue(ConstantValue obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitDeprecated(Deprecated obj);
|
public void visitDeprecated(Deprecated obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitExceptionTable(ExceptionTable obj);
|
public void visitExceptionTable(ExceptionTable obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitField(Field obj);
|
public void visitField(Field obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitInnerClass(InnerClass obj);
|
public void visitInnerClass(InnerClass obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitInnerClasses(InnerClasses obj);
|
public void visitInnerClasses(InnerClasses obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitJavaClass(JavaClass obj);
|
public void visitJavaClass(JavaClass obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitLineNumber(LineNumber obj);
|
public void visitLineNumber(LineNumber obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitLineNumberTable(LineNumberTable obj);
|
public void visitLineNumberTable(LineNumberTable obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitLocalVariable(LocalVariable obj);
|
public void visitLocalVariable(LocalVariable obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitLocalVariableTable(LocalVariableTable obj);
|
public void visitLocalVariableTable(LocalVariableTable obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitMethod(Method obj);
|
public void visitMethod(Method obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitSignature(Signature obj);
|
public void visitSignature(Signature obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitSourceFile(SourceFile obj);
|
public void visitSourceFile(SourceFile obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitSynthetic(Synthetic obj);
|
public void visitSynthetic(Synthetic obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitUnknown(Unknown obj);
|
public void visitUnknown(Unknown obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitStackMap(StackMap obj);
|
public void visitStackMap(StackMap obj);
|
||||||
|
|
||||||
|
|
||||||
public void visitStackMapEntry(StackMapEntry obj);
|
public void visitStackMapEntry(StackMapEntry obj);
|
||||||
}
|
}
|
||||||
|
@ -18,28 +18,38 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* AALOAD - Load reference from array
|
* AALOAD - Load reference from array
|
||||||
* <PRE>Stack: ..., arrayref, index -> value</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., arrayref, index -> value
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: AALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: AALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class AALOAD extends ArrayInstruction implements StackProducer {
|
public class AALOAD extends ArrayInstruction implements StackProducer {
|
||||||
|
|
||||||
/** Load reference from array
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load reference from array
|
||||||
*/
|
*/
|
||||||
public AALOAD() {
|
public AALOAD() {
|
||||||
super(org.apache.bcel.Constants.AALOAD);
|
super(org.apache.bcel.Constants.AALOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
v.visitExceptionThrower(this);
|
v.visitExceptionThrower(this);
|
||||||
|
@ -18,28 +18,38 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* AASTORE - Store into reference array
|
* AASTORE - Store into reference array
|
||||||
* <PRE>Stack: ..., arrayref, index, value -> ...</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., arrayref, index, value -> ...
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: AASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: AASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class AASTORE extends ArrayInstruction implements StackConsumer {
|
public class AASTORE extends ArrayInstruction implements StackConsumer {
|
||||||
|
|
||||||
/** Store into reference array
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store into reference array
|
||||||
*/
|
*/
|
||||||
public AASTORE() {
|
public AASTORE() {
|
||||||
super(org.apache.bcel.Constants.AASTORE);
|
super(org.apache.bcel.Constants.AASTORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitStackConsumer(this);
|
v.visitStackConsumer(this);
|
||||||
v.visitExceptionThrower(this);
|
v.visitExceptionThrower(this);
|
||||||
|
@ -18,12 +18,21 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ACONST_NULL - Push null reference
|
* ACONST_NULL - Push null reference
|
||||||
* <PRE>Stack: ... -> ..., null</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ... -> ..., null
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: ACONST_NULL.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ACONST_NULL.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class ACONST_NULL extends Instruction implements PushInstruction, TypedInstruction {
|
public class ACONST_NULL extends Instruction implements PushInstruction,
|
||||||
|
TypedInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Push null reference
|
* Push null reference
|
||||||
@ -32,22 +41,24 @@ public class ACONST_NULL extends Instruction implements PushInstruction, TypedIn
|
|||||||
super(org.apache.bcel.Constants.ACONST_NULL, (short) 1);
|
super(org.apache.bcel.Constants.ACONST_NULL, (short) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return Type.NULL
|
* @return Type.NULL
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Type getType(ConstantPoolGen cp) {
|
public Type getType(ConstantPoolGen cp) {
|
||||||
return Type.NULL;
|
return Type.NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
v.visitPushInstruction(this);
|
v.visitPushInstruction(this);
|
||||||
|
@ -18,38 +18,51 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ALOAD - Load reference from local variable
|
* ALOAD - Load reference from local variable
|
||||||
* <PRE>Stack: ... -> ..., objectref</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ... -> ..., objectref
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: ALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class ALOAD extends LoadInstruction {
|
public class ALOAD extends LoadInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor needed for the Class.newInstance() statement in
|
* Empty constructor needed for the Class.newInstance() statement in
|
||||||
* Instruction.readInstruction(). Not to be used otherwise.
|
* Instruction.readInstruction(). Not to be used otherwise.
|
||||||
*/
|
*/
|
||||||
ALOAD() {
|
ALOAD() {
|
||||||
super(org.apache.bcel.Constants.ALOAD, org.apache.bcel.Constants.ALOAD_0);
|
super(org.apache.bcel.Constants.ALOAD,
|
||||||
|
org.apache.bcel.Constants.ALOAD_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Load reference from local variable
|
|
||||||
* @param n index of local variable
|
|
||||||
*/
|
|
||||||
public ALOAD(int n) {
|
|
||||||
super(org.apache.bcel.Constants.ALOAD, org.apache.bcel.Constants.ALOAD_0, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Load reference from local variable
|
||||||
* Call visitor methods of implemented interfaces first, then
|
|
||||||
* call methods according to the class hierarchy in descending order,
|
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param n
|
||||||
|
* index of local variable
|
||||||
*/
|
*/
|
||||||
|
public ALOAD(int n) {
|
||||||
|
super(org.apache.bcel.Constants.ALOAD,
|
||||||
|
org.apache.bcel.Constants.ALOAD_0, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
|
* of implemented interfaces first, then call methods according to the class
|
||||||
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
|
* comes last.
|
||||||
|
*
|
||||||
|
* @param v
|
||||||
|
* Visitor object
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
super.accept(v);
|
super.accept(v);
|
||||||
v.visitALOAD(this);
|
v.visitALOAD(this);
|
||||||
|
@ -20,13 +20,21 @@ import org.apache.bcel.ExceptionConstants;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ANEWARRAY - Create new array of references
|
* ANEWARRAY - Create new array of references
|
||||||
* <PRE>Stack: ..., count -> ..., arrayref</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., count -> ..., arrayref
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: ANEWARRAY.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ANEWARRAY.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class ANEWARRAY extends CPInstruction implements LoadClass, AllocationInstruction,
|
public class ANEWARRAY extends CPInstruction implements LoadClass,
|
||||||
ExceptionThrower, StackConsumer, StackProducer {
|
AllocationInstruction, ExceptionThrower, StackConsumer, StackProducer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor needed for the Class.newInstance() statement in
|
* Empty constructor needed for the Class.newInstance() statement in
|
||||||
@ -35,29 +43,31 @@ public class ANEWARRAY extends CPInstruction implements LoadClass, AllocationIns
|
|||||||
ANEWARRAY() {
|
ANEWARRAY() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ANEWARRAY(int index) {
|
public ANEWARRAY(int index) {
|
||||||
super(org.apache.bcel.Constants.ANEWARRAY, index);
|
super(org.apache.bcel.Constants.ANEWARRAY, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class[] getExceptions() {
|
public Class<?>[] getExceptions() {
|
||||||
Class[] cs = new Class[1 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length];
|
Class<?>[] cs = new Class[1 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length];
|
||||||
System.arraycopy(ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0, cs, 0,
|
System.arraycopy(
|
||||||
|
ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0, cs,
|
||||||
|
0,
|
||||||
ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length);
|
ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length);
|
||||||
cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] = ExceptionConstants.NEGATIVE_ARRAY_SIZE_EXCEPTION;
|
cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] = ExceptionConstants.NEGATIVE_ARRAY_SIZE_EXCEPTION;
|
||||||
return cs;
|
return cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitLoadClass(this);
|
v.visitLoadClass(this);
|
||||||
v.visitAllocationInstruction(this);
|
v.visitAllocationInstruction(this);
|
||||||
@ -68,7 +78,7 @@ public class ANEWARRAY extends CPInstruction implements LoadClass, AllocationIns
|
|||||||
v.visitANEWARRAY(this);
|
v.visitANEWARRAY(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ObjectType getLoadClassType(ConstantPoolGen cpg) {
|
public ObjectType getLoadClassType(ConstantPoolGen cpg) {
|
||||||
Type t = getType(cpg);
|
Type t = getType(cpg);
|
||||||
if (t instanceof ArrayType) {
|
if (t instanceof ArrayType) {
|
||||||
|
@ -18,13 +18,21 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ARETURN - Return reference from method
|
* ARETURN - Return reference from method
|
||||||
* <PRE>Stack: ..., objectref -> <empty></PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., objectref -> <empty>
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: ARETURN.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ARETURN.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class ARETURN extends ReturnInstruction {
|
public class ARETURN extends ReturnInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return reference from method
|
* Return reference from method
|
||||||
*/
|
*/
|
||||||
@ -32,15 +40,16 @@ public class ARETURN extends ReturnInstruction {
|
|||||||
super(org.apache.bcel.Constants.ARETURN);
|
super(org.apache.bcel.Constants.ARETURN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitExceptionThrower(this);
|
v.visitExceptionThrower(this);
|
||||||
v.visitTypedInstruction(this);
|
v.visitTypedInstruction(this);
|
||||||
|
@ -18,37 +18,47 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ARRAYLENGTH - Get length of array
|
* ARRAYLENGTH - Get length of array
|
||||||
* <PRE>Stack: ..., arrayref -> ..., length</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., arrayref -> ..., length
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: ARRAYLENGTH.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ARRAYLENGTH.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class ARRAYLENGTH extends Instruction implements ExceptionThrower, StackProducer {
|
public class ARRAYLENGTH extends Instruction implements ExceptionThrower,
|
||||||
|
StackProducer {
|
||||||
|
|
||||||
/** Get length of array
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get length of array
|
||||||
*/
|
*/
|
||||||
public ARRAYLENGTH() {
|
public ARRAYLENGTH() {
|
||||||
super(org.apache.bcel.Constants.ARRAYLENGTH, (short) 1);
|
super(org.apache.bcel.Constants.ARRAYLENGTH, (short) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return exceptions this instruction may cause
|
* @return exceptions this instruction may cause
|
||||||
*/
|
*/
|
||||||
public Class[] getExceptions() {
|
@Override
|
||||||
return new Class[] {
|
public Class<?>[] getExceptions() {
|
||||||
org.apache.bcel.ExceptionConstants.NULL_POINTER_EXCEPTION
|
return new Class[] { org.apache.bcel.ExceptionConstants.NULL_POINTER_EXCEPTION };
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitExceptionThrower(this);
|
v.visitExceptionThrower(this);
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
|
@ -18,38 +18,51 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ASTORE - Store reference into local variable
|
* ASTORE - Store reference into local variable
|
||||||
* <PRE>Stack ..., objectref -> ... </PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack ..., objectref -> ...
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: ASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class ASTORE extends StoreInstruction {
|
public class ASTORE extends StoreInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor needed for the Class.newInstance() statement in
|
* Empty constructor needed for the Class.newInstance() statement in
|
||||||
* Instruction.readInstruction(). Not to be used otherwise.
|
* Instruction.readInstruction(). Not to be used otherwise.
|
||||||
*/
|
*/
|
||||||
ASTORE() {
|
ASTORE() {
|
||||||
super(org.apache.bcel.Constants.ASTORE, org.apache.bcel.Constants.ASTORE_0);
|
super(org.apache.bcel.Constants.ASTORE,
|
||||||
|
org.apache.bcel.Constants.ASTORE_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Store reference into local variable
|
|
||||||
* @param n index of local variable
|
|
||||||
*/
|
|
||||||
public ASTORE(int n) {
|
|
||||||
super(org.apache.bcel.Constants.ASTORE, org.apache.bcel.Constants.ASTORE_0, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Store reference into local variable
|
||||||
* Call visitor methods of implemented interfaces first, then
|
|
||||||
* call methods according to the class hierarchy in descending order,
|
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param n
|
||||||
|
* index of local variable
|
||||||
*/
|
*/
|
||||||
|
public ASTORE(int n) {
|
||||||
|
super(org.apache.bcel.Constants.ASTORE,
|
||||||
|
org.apache.bcel.Constants.ASTORE_0, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
|
* of implemented interfaces first, then call methods according to the class
|
||||||
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
|
* comes last.
|
||||||
|
*
|
||||||
|
* @param v
|
||||||
|
* Visitor object
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
super.accept(v);
|
super.accept(v);
|
||||||
v.visitASTORE(this);
|
v.visitASTORE(this);
|
||||||
|
@ -18,12 +18,21 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ATHROW - Throw exception
|
* ATHROW - Throw exception
|
||||||
* <PRE>Stack: ..., objectref -> objectref</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., objectref -> objectref
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: ATHROW.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ATHROW.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class ATHROW extends Instruction implements UnconditionalBranch, ExceptionThrower {
|
public class ATHROW extends Instruction implements UnconditionalBranch,
|
||||||
|
ExceptionThrower {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throw exception
|
* Throw exception
|
||||||
@ -32,24 +41,24 @@ public class ATHROW extends Instruction implements UnconditionalBranch, Exceptio
|
|||||||
super(org.apache.bcel.Constants.ATHROW, (short) 1);
|
super(org.apache.bcel.Constants.ATHROW, (short) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return exceptions this instruction may cause
|
* @return exceptions this instruction may cause
|
||||||
*/
|
*/
|
||||||
public Class[] getExceptions() {
|
@Override
|
||||||
return new Class[] {
|
public Class<?>[] getExceptions() {
|
||||||
org.apache.bcel.ExceptionConstants.THROWABLE
|
return new Class[] { org.apache.bcel.ExceptionConstants.THROWABLE };
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitUnconditionalBranch(this);
|
v.visitUnconditionalBranch(this);
|
||||||
v.visitExceptionThrower(this);
|
v.visitExceptionThrower(this);
|
||||||
|
@ -24,8 +24,13 @@ import org.apache.bcel.Constants;
|
|||||||
* @version $Id: ArithmeticInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ArithmeticInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public abstract class ArithmeticInstruction extends Instruction implements TypedInstruction,
|
public abstract class ArithmeticInstruction extends Instruction implements
|
||||||
StackProducer, StackConsumer {
|
TypedInstruction, StackProducer, StackConsumer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor needed for the Class.newInstance() statement in
|
* Empty constructor needed for the Class.newInstance() statement in
|
||||||
@ -34,17 +39,18 @@ public abstract class ArithmeticInstruction extends Instruction implements Typed
|
|||||||
ArithmeticInstruction() {
|
ArithmeticInstruction() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param opcode of instruction
|
* @param opcode
|
||||||
|
* of instruction
|
||||||
*/
|
*/
|
||||||
protected ArithmeticInstruction(short opcode) {
|
protected ArithmeticInstruction(short opcode) {
|
||||||
super(opcode, (short) 1);
|
super(opcode, (short) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return type associated with the instruction
|
* @return type associated with the instruction
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Type getType(ConstantPoolGen cp) {
|
public Type getType(ConstantPoolGen cp) {
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case Constants.DADD:
|
case Constants.DADD:
|
||||||
|
@ -22,8 +22,13 @@ package org.apache.bcel.generic;
|
|||||||
* @version $Id: ArrayInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ArrayInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public abstract class ArrayInstruction extends Instruction implements ExceptionThrower,
|
public abstract class ArrayInstruction extends Instruction implements
|
||||||
TypedInstruction {
|
ExceptionThrower, TypedInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor needed for the Class.newInstance() statement in
|
* Empty constructor needed for the Class.newInstance() statement in
|
||||||
@ -32,22 +37,23 @@ public abstract class ArrayInstruction extends Instruction implements ExceptionT
|
|||||||
ArrayInstruction() {
|
ArrayInstruction() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param opcode of instruction
|
* @param opcode
|
||||||
|
* of instruction
|
||||||
*/
|
*/
|
||||||
protected ArrayInstruction(short opcode) {
|
protected ArrayInstruction(short opcode) {
|
||||||
super(opcode, (short) 1);
|
super(opcode, (short) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Class[] getExceptions() {
|
public Class<?>[] getExceptions() {
|
||||||
return org.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION;
|
return org.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return type associated with the instruction
|
* @return type associated with the instruction
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Type getType(ConstantPoolGen cp) {
|
public Type getType(ConstantPoolGen cp) {
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case org.apache.bcel.Constants.IALOAD:
|
case org.apache.bcel.Constants.IALOAD:
|
||||||
|
@ -26,39 +26,44 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class ArrayType extends ReferenceType {
|
public final class ArrayType extends ReferenceType {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private int dimensions;
|
private int dimensions;
|
||||||
private Type basic_type;
|
private Type basic_type;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience constructor for array type, e.g. int[]
|
* Convenience constructor for array type, e.g. int[]
|
||||||
*
|
*
|
||||||
* @param type array type, e.g. T_INT
|
* @param type
|
||||||
|
* array type, e.g. T_INT
|
||||||
*/
|
*/
|
||||||
public ArrayType(byte type, int dimensions) {
|
public ArrayType(byte type, int dimensions) {
|
||||||
this(BasicType.getType(type), dimensions);
|
this(BasicType.getType(type), dimensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience constructor for reference array type, e.g. Object[]
|
* Convenience constructor for reference array type, e.g. Object[]
|
||||||
*
|
*
|
||||||
* @param class_name complete name of class (java.lang.String, e.g.)
|
* @param class_name
|
||||||
|
* complete name of class (java.lang.String, e.g.)
|
||||||
*/
|
*/
|
||||||
public ArrayType(String class_name, int dimensions) {
|
public ArrayType(String class_name, int dimensions) {
|
||||||
this(new ObjectType(class_name), dimensions);
|
this(new ObjectType(class_name), dimensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for array of given type
|
* Constructor for array of given type
|
||||||
*
|
*
|
||||||
* @param type type of array (may be an array itself)
|
* @param type
|
||||||
|
* type of array (may be an array itself)
|
||||||
*/
|
*/
|
||||||
public ArrayType(Type type, int dimensions) {
|
public ArrayType(Type type, int dimensions) {
|
||||||
super(Constants.T_ARRAY, "<dummy>");
|
super(Constants.T_ARRAY, "<dummy>");
|
||||||
if ((dimensions < 1) || (dimensions > Constants.MAX_BYTE)) {
|
if ((dimensions < 1) || (dimensions > Constants.MAX_BYTE)) {
|
||||||
throw new ClassGenException("Invalid number of dimensions: " + dimensions);
|
throw new ClassGenException("Invalid number of dimensions: "
|
||||||
|
+ dimensions);
|
||||||
}
|
}
|
||||||
switch (type.getType()) {
|
switch (type.getType()) {
|
||||||
case Constants.T_ARRAY:
|
case Constants.T_ARRAY:
|
||||||
@ -81,7 +86,6 @@ public final class ArrayType extends ReferenceType {
|
|||||||
signature = buf.toString();
|
signature = buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return basic type of array, i.e., for int[][][] the basic type is int
|
* @return basic type of array, i.e., for int[][][] the basic type is int
|
||||||
*/
|
*/
|
||||||
@ -89,9 +93,9 @@ public final class ArrayType extends ReferenceType {
|
|||||||
return basic_type;
|
return basic_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return element type of array, i.e., for int[][][] the element type is int[][]
|
* @return element type of array, i.e., for int[][][] the element type is
|
||||||
|
* int[][]
|
||||||
*/
|
*/
|
||||||
public Type getElementType() {
|
public Type getElementType() {
|
||||||
if (dimensions == 1) {
|
if (dimensions == 1) {
|
||||||
@ -100,27 +104,30 @@ public final class ArrayType extends ReferenceType {
|
|||||||
return new ArrayType(basic_type, dimensions - 1);
|
return new ArrayType(basic_type, dimensions - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return number of dimensions of array
|
* @return number of dimensions of array
|
||||||
*/
|
*/
|
||||||
public int getDimensions() {
|
public int getDimensions() {
|
||||||
return dimensions;
|
return dimensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return a hash code value for the object.
|
* @return a hash code value for the object.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return basic_type.hashCode() ^ dimensions;
|
return basic_type.hashCode() ^ dimensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return true if both type objects refer to the same array type.
|
* @return true if both type objects refer to the same array type.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean equals(Object _type) {
|
public boolean equals(Object _type) {
|
||||||
if (_type instanceof ArrayType) {
|
if (_type instanceof ArrayType) {
|
||||||
ArrayType array = (ArrayType) _type;
|
ArrayType array = (ArrayType) _type;
|
||||||
return (array.dimensions == dimensions) && array.basic_type.equals(basic_type);
|
return (array.dimensions == dimensions)
|
||||||
|
&& array.basic_type.equals(basic_type);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -18,28 +18,38 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* BALOAD - Load byte or boolean from array
|
* BALOAD - Load byte or boolean from array
|
||||||
* <PRE>Stack: ..., arrayref, index -> ..., value</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., arrayref, index -> ..., value
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: BALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: BALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class BALOAD extends ArrayInstruction implements StackProducer {
|
public class BALOAD extends ArrayInstruction implements StackProducer {
|
||||||
|
|
||||||
/** Load byte or boolean from array
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load byte or boolean from array
|
||||||
*/
|
*/
|
||||||
public BALOAD() {
|
public BALOAD() {
|
||||||
super(org.apache.bcel.Constants.BALOAD);
|
super(org.apache.bcel.Constants.BALOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
v.visitExceptionThrower(this);
|
v.visitExceptionThrower(this);
|
||||||
|
@ -18,28 +18,38 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* BASTORE - Store into byte or boolean array
|
* BASTORE - Store into byte or boolean array
|
||||||
* <PRE>Stack: ..., arrayref, index, value -> ...</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., arrayref, index, value -> ...
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: BASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: BASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class BASTORE extends ArrayInstruction implements StackConsumer {
|
public class BASTORE extends ArrayInstruction implements StackConsumer {
|
||||||
|
|
||||||
/** Store byte or boolean into array
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store byte or boolean into array
|
||||||
*/
|
*/
|
||||||
public BASTORE() {
|
public BASTORE() {
|
||||||
super(org.apache.bcel.Constants.BASTORE);
|
super(org.apache.bcel.Constants.BASTORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitStackConsumer(this);
|
v.visitStackConsumer(this);
|
||||||
v.visitExceptionThrower(this);
|
v.visitExceptionThrower(this);
|
||||||
|
@ -23,16 +23,21 @@ import org.apache.bcel.util.ByteSequence;
|
|||||||
/**
|
/**
|
||||||
* BIPUSH - Push byte on stack
|
* BIPUSH - Push byte on stack
|
||||||
*
|
*
|
||||||
* <PRE>Stack: ... -> ..., value</PRE>
|
* <PRE>
|
||||||
|
* Stack: ... -> ..., value
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: BIPUSH.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: BIPUSH.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class BIPUSH extends Instruction implements ConstantPushInstruction {
|
public class BIPUSH extends Instruction implements ConstantPushInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private byte b;
|
private byte b;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor needed for the Class.newInstance() statement in
|
* Empty constructor needed for the Class.newInstance() statement in
|
||||||
* Instruction.readInstruction(). Not to be used otherwise.
|
* Instruction.readInstruction(). Not to be used otherwise.
|
||||||
@ -40,61 +45,64 @@ public class BIPUSH extends Instruction implements ConstantPushInstruction {
|
|||||||
BIPUSH() {
|
BIPUSH() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Push byte on stack
|
* Push byte on stack
|
||||||
*/
|
*/
|
||||||
public BIPUSH(byte b) {
|
public BIPUSH(byte b) {
|
||||||
super(org.apache.bcel.Constants.BIPUSH, (short) 2);
|
super(org.apache.bcel.Constants.BIPUSH, (short) 2);
|
||||||
this.b = b;
|
this.b = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump instruction as byte code to stream out.
|
* Dump instruction as byte code to stream out.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void dump(DataOutputStream out) throws IOException {
|
public void dump(DataOutputStream out) throws IOException {
|
||||||
super.dump(out);
|
super.dump(out);
|
||||||
out.writeByte(b);
|
out.writeByte(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mnemonic for instruction
|
* @return mnemonic for instruction
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString(boolean verbose) {
|
public String toString(boolean verbose) {
|
||||||
return super.toString(verbose) + " " + b;
|
return super.toString(verbose) + " " + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read needed data (e.g. index) from file.
|
* Read needed data (e.g. index) from file.
|
||||||
*/
|
*/
|
||||||
protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
|
@Override
|
||||||
|
protected void initFromFile(ByteSequence bytes, boolean wide)
|
||||||
|
throws IOException {
|
||||||
length = 2;
|
length = 2;
|
||||||
b = bytes.readByte();
|
b = bytes.readByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Number getValue() {
|
public Number getValue() {
|
||||||
return new Integer(b);
|
return new Integer(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return Type.BYTE
|
* @return Type.BYTE
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Type getType(ConstantPoolGen cp) {
|
public Type getType(ConstantPoolGen cp) {
|
||||||
return Type.BYTE;
|
return Type.BYTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitPushInstruction(this);
|
v.visitPushInstruction(this);
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
|
@ -24,19 +24,25 @@ package org.apache.bcel.generic;
|
|||||||
*/
|
*/
|
||||||
public class BREAKPOINT extends Instruction {
|
public class BREAKPOINT extends Instruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public BREAKPOINT() {
|
public BREAKPOINT() {
|
||||||
super(org.apache.bcel.Constants.BREAKPOINT, (short) 1);
|
super(org.apache.bcel.Constants.BREAKPOINT, (short) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitBREAKPOINT(this);
|
v.visitBREAKPOINT(this);
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,16 @@ import org.apache.bcel.Constants;
|
|||||||
*/
|
*/
|
||||||
public final class BasicType extends Type {
|
public final class BasicType extends Type {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for basic types such as int, long, `void'
|
* Constructor for basic types such as int, long, `void'
|
||||||
*
|
*
|
||||||
* @param type one of T_INT, T_BOOLEAN, ..., T_VOID
|
* @param type
|
||||||
|
* one of T_INT, T_BOOLEAN, ..., T_VOID
|
||||||
* @see org.apache.bcel.Constants
|
* @see org.apache.bcel.Constants
|
||||||
*/
|
*/
|
||||||
BasicType(byte type) {
|
BasicType(byte type) {
|
||||||
@ -39,7 +45,6 @@ public final class BasicType extends Type {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static final BasicType getType(byte type) {
|
public static final BasicType getType(byte type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Constants.T_VOID:
|
case Constants.T_VOID:
|
||||||
@ -65,17 +70,20 @@ public final class BasicType extends Type {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return a hash code value for the object.
|
* @return a hash code value for the object.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return true if both type objects refer to the same type
|
* @return true if both type objects refer to the same type
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean equals(Object _type) {
|
public boolean equals(Object _type) {
|
||||||
return (_type instanceof BasicType) ? ((BasicType) _type).type == this.type : false;
|
return (_type instanceof BasicType) ? ((BasicType) _type).type == this.type
|
||||||
|
: false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ package org.apache.bcel.generic;
|
|||||||
/**
|
/**
|
||||||
* BranchHandle is returned by specialized InstructionList.append() whenever a
|
* BranchHandle is returned by specialized InstructionList.append() whenever a
|
||||||
* BranchInstruction is appended. This is useful when the target of this
|
* BranchInstruction is appended. This is useful when the target of this
|
||||||
* instruction is not known at time of creation and must be set later
|
* instruction is not known at time of creation and must be set later via
|
||||||
* via setTarget().
|
* setTarget().
|
||||||
*
|
*
|
||||||
* @see InstructionHandle
|
* @see InstructionHandle
|
||||||
* @see Instruction
|
* @see Instruction
|
||||||
@ -30,19 +30,22 @@ package org.apache.bcel.generic;
|
|||||||
*/
|
*/
|
||||||
public final class BranchHandle extends InstructionHandle {
|
public final class BranchHandle extends InstructionHandle {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private BranchInstruction bi; // An alias in fact, but saves lots of casts
|
private BranchInstruction bi; // An alias in fact, but saves lots of casts
|
||||||
|
|
||||||
|
|
||||||
private BranchHandle(BranchInstruction i) {
|
private BranchHandle(BranchInstruction i) {
|
||||||
super(i);
|
super(i);
|
||||||
bi = i;
|
bi = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Factory methods.
|
/**
|
||||||
|
* Factory methods.
|
||||||
*/
|
*/
|
||||||
private static BranchHandle bh_list = null; // List of reusable handles
|
private static BranchHandle bh_list = null; // List of reusable handles
|
||||||
|
|
||||||
|
|
||||||
static final BranchHandle getBranchHandle(BranchInstruction i) {
|
static final BranchHandle getBranchHandle(BranchInstruction i) {
|
||||||
if (bh_list == null) {
|
if (bh_list == null) {
|
||||||
return new BranchHandle(i);
|
return new BranchHandle(i);
|
||||||
@ -53,36 +56,37 @@ public final class BranchHandle extends InstructionHandle {
|
|||||||
return bh;
|
return bh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Handle adds itself to the list of resuable handles.
|
* Handle adds itself to the list of resuable handles.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void addHandle() {
|
protected void addHandle() {
|
||||||
next = bh_list;
|
next = bh_list;
|
||||||
bh_list = this;
|
bh_list = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
/* Override InstructionHandle methods: delegate to branch instruction.
|
* Override InstructionHandle methods: delegate to branch instruction.
|
||||||
* Through this overriding all access to the private i_position field should
|
* Through this overriding all access to the private i_position field should
|
||||||
* be prevented.
|
* be prevented.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getPosition() {
|
public int getPosition() {
|
||||||
return bi.position;
|
return bi.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
void setPosition(int pos) {
|
void setPosition(int pos) {
|
||||||
i_position = bi.position = pos;
|
i_position = bi.position = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected int updatePosition(int offset, int max_offset) {
|
protected int updatePosition(int offset, int max_offset) {
|
||||||
int x = bi.updatePosition(offset, max_offset);
|
int x = bi.updatePosition(offset, max_offset);
|
||||||
i_position = bi.position;
|
i_position = bi.position;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass new target to instruction.
|
* Pass new target to instruction.
|
||||||
*/
|
*/
|
||||||
@ -90,7 +94,6 @@ public final class BranchHandle extends InstructionHandle {
|
|||||||
bi.setTarget(ih);
|
bi.setTarget(ih);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update target of instruction.
|
* Update target of instruction.
|
||||||
*/
|
*/
|
||||||
@ -98,7 +101,6 @@ public final class BranchHandle extends InstructionHandle {
|
|||||||
bi.updateTarget(old_ih, new_ih);
|
bi.updateTarget(old_ih, new_ih);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return target of instruction.
|
* @return target of instruction.
|
||||||
*/
|
*/
|
||||||
@ -106,10 +108,11 @@ public final class BranchHandle extends InstructionHandle {
|
|||||||
return bi.getTarget();
|
return bi.getTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set new contents. Old instruction is disposed and may not be used anymore.
|
* Set new contents. Old instruction is disposed and may not be used
|
||||||
|
* anymore.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setInstruction(Instruction i) {
|
public void setInstruction(Instruction i) {
|
||||||
super.setInstruction(i);
|
super.setInstruction(i);
|
||||||
if (!(i instanceof BranchInstruction)) {
|
if (!(i instanceof BranchInstruction)) {
|
||||||
|
@ -21,21 +21,25 @@ import java.io.IOException;
|
|||||||
import org.apache.bcel.util.ByteSequence;
|
import org.apache.bcel.util.ByteSequence;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract super class for branching instructions like GOTO, IFEQ, etc..
|
* Abstract super class for branching instructions like GOTO, IFEQ, etc.. Branch
|
||||||
* Branch instructions may have a variable length, namely GOTO, JSR,
|
* instructions may have a variable length, namely GOTO, JSR, LOOKUPSWITCH and
|
||||||
* LOOKUPSWITCH and TABLESWITCH.
|
* TABLESWITCH.
|
||||||
*
|
*
|
||||||
* @see InstructionList
|
* @see InstructionList
|
||||||
* @version $Id: BranchInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: BranchInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public abstract class BranchInstruction extends Instruction implements InstructionTargeter {
|
public abstract class BranchInstruction extends Instruction implements
|
||||||
|
InstructionTargeter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
protected int index; // Branch target relative to this instruction
|
protected int index; // Branch target relative to this instruction
|
||||||
protected InstructionHandle target; // Target object in instruction list
|
protected InstructionHandle target; // Target object in instruction list
|
||||||
protected int position; // Byte code offset
|
protected int position; // Byte code offset
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor needed for the Class.newInstance() statement in
|
* Empty constructor needed for the Class.newInstance() statement in
|
||||||
* Instruction.readInstruction(). Not to be used otherwise.
|
* Instruction.readInstruction(). Not to be used otherwise.
|
||||||
@ -43,33 +47,39 @@ public abstract class BranchInstruction extends Instruction implements Instructi
|
|||||||
BranchInstruction() {
|
BranchInstruction() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Common super constructor
|
* Common super constructor
|
||||||
* @param opcode Instruction opcode
|
*
|
||||||
* @param target instruction to branch to
|
* @param opcode
|
||||||
|
* Instruction opcode
|
||||||
|
* @param target
|
||||||
|
* instruction to branch to
|
||||||
*/
|
*/
|
||||||
protected BranchInstruction(short opcode, InstructionHandle target) {
|
protected BranchInstruction(short opcode, InstructionHandle target) {
|
||||||
super(opcode, (short) 3);
|
super(opcode, (short) 3);
|
||||||
setTarget(target);
|
setTarget(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump instruction as byte code to stream out.
|
* Dump instruction as byte code to stream out.
|
||||||
* @param out Output stream
|
*
|
||||||
|
* @param out
|
||||||
|
* Output stream
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void dump(DataOutputStream out) throws IOException {
|
public void dump(DataOutputStream out) throws IOException {
|
||||||
out.writeByte(opcode);
|
out.writeByte(opcode);
|
||||||
index = getTargetOffset();
|
index = getTargetOffset();
|
||||||
if (Math.abs(index) >= 32767) {
|
if (Math.abs(index) >= 32767) {
|
||||||
throw new ClassGenException("Branch target offset too large for short");
|
throw new ClassGenException(
|
||||||
|
"Branch target offset too large for short");
|
||||||
}
|
}
|
||||||
out.writeShort(index); // May be negative, i.e., point backwards
|
out.writeShort(index); // May be negative, i.e., point backwards
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param _target branch target
|
* @param _target
|
||||||
|
* branch target
|
||||||
* @return the offset to `target' relative to this instruction
|
* @return the offset to `target' relative to this instruction
|
||||||
*/
|
*/
|
||||||
protected int getTargetOffset(InstructionHandle _target) {
|
protected int getTargetOffset(InstructionHandle _target) {
|
||||||
@ -79,13 +89,13 @@ public abstract class BranchInstruction extends Instruction implements Instructi
|
|||||||
}
|
}
|
||||||
int t = _target.getPosition();
|
int t = _target.getPosition();
|
||||||
if (t < 0) {
|
if (t < 0) {
|
||||||
throw new ClassGenException("Invalid branch target position offset for "
|
throw new ClassGenException(
|
||||||
|
"Invalid branch target position offset for "
|
||||||
+ super.toString(true) + ":" + t + ":" + _target);
|
+ super.toString(true) + ":" + t + ":" + _target);
|
||||||
}
|
}
|
||||||
return t - position;
|
return t - position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the offset to this instruction's target
|
* @return the offset to this instruction's target
|
||||||
*/
|
*/
|
||||||
@ -93,34 +103,38 @@ public abstract class BranchInstruction extends Instruction implements Instructi
|
|||||||
return getTargetOffset(target);
|
return getTargetOffset(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by InstructionList.setPositions when setting the position for every
|
* Called by InstructionList.setPositions when setting the position for
|
||||||
* instruction. In the presence of variable length instructions `setPositions'
|
* every instruction. In the presence of variable length instructions
|
||||||
* performs multiple passes over the instruction list to calculate the
|
* `setPositions' performs multiple passes over the instruction list to
|
||||||
* correct (byte) positions and offsets by calling this function.
|
* calculate the correct (byte) positions and offsets by calling this
|
||||||
|
* function.
|
||||||
*
|
*
|
||||||
* @param offset additional offset caused by preceding (variable length) instructions
|
* @param offset
|
||||||
* @param max_offset the maximum offset that may be caused by these instructions
|
* additional offset caused by preceding (variable length)
|
||||||
* @return additional offset caused by possible change of this instruction's length
|
* instructions
|
||||||
|
* @param max_offset
|
||||||
|
* the maximum offset that may be caused by these instructions
|
||||||
|
* @return additional offset caused by possible change of this instruction's
|
||||||
|
* length
|
||||||
*/
|
*/
|
||||||
protected int updatePosition(int offset, int max_offset) {
|
protected int updatePosition(int offset, int max_offset) {
|
||||||
position += offset;
|
position += offset;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Long output format:
|
* Long output format:
|
||||||
*
|
*
|
||||||
* <position in byte code>
|
* <position in byte code> <name of opcode> "["<opcode
|
||||||
* <name of opcode> "["<opcode number>"]"
|
* number>"]" "("<length of instruction>")" "<"<target
|
||||||
* "("<length of instruction>")"
|
* instruction>">" "@"<branch target offset>
|
||||||
* "<"<target instruction>">" "@"<branch target offset>
|
|
||||||
*
|
*
|
||||||
* @param verbose long/short format switch
|
* @param verbose
|
||||||
|
* long/short format switch
|
||||||
* @return mnemonic for instruction
|
* @return mnemonic for instruction
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString(boolean verbose) {
|
public String toString(boolean verbose) {
|
||||||
String s = super.toString(verbose);
|
String s = super.toString(verbose);
|
||||||
String t = "null";
|
String t = "null";
|
||||||
@ -131,7 +145,8 @@ public abstract class BranchInstruction extends Instruction implements Instructi
|
|||||||
} else if (target.getInstruction() == null) {
|
} else if (target.getInstruction() == null) {
|
||||||
t = "<null instruction!!!?>";
|
t = "<null instruction!!!?>";
|
||||||
} else {
|
} else {
|
||||||
t = target.getInstruction().toString(false); // Avoid circles
|
t = target.getInstruction().toString(false); // Avoid
|
||||||
|
// circles
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -143,21 +158,23 @@ public abstract class BranchInstruction extends Instruction implements Instructi
|
|||||||
return s + " -> " + t;
|
return s + " -> " + t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read needed data (e.g. index) from file. Conversion to a InstructionHandle
|
* Read needed data (e.g. index) from file. Conversion to a
|
||||||
* is done in InstructionList(byte[]).
|
* InstructionHandle is done in InstructionList(byte[]).
|
||||||
*
|
*
|
||||||
* @param bytes input stream
|
* @param bytes
|
||||||
* @param wide wide prefix?
|
* input stream
|
||||||
|
* @param wide
|
||||||
|
* wide prefix?
|
||||||
* @see InstructionList
|
* @see InstructionList
|
||||||
*/
|
*/
|
||||||
protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
|
@Override
|
||||||
|
protected void initFromFile(ByteSequence bytes, boolean wide)
|
||||||
|
throws IOException {
|
||||||
length = 3;
|
length = 3;
|
||||||
index = bytes.readShort();
|
index = bytes.readShort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return target offset in byte code
|
* @return target offset in byte code
|
||||||
*/
|
*/
|
||||||
@ -165,7 +182,6 @@ public abstract class BranchInstruction extends Instruction implements Instructi
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return target of branch instruction
|
* @return target of branch instruction
|
||||||
*/
|
*/
|
||||||
@ -173,22 +189,22 @@ public abstract class BranchInstruction extends Instruction implements Instructi
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set branch target
|
* Set branch target
|
||||||
* @param target branch target
|
*
|
||||||
|
* @param target
|
||||||
|
* branch target
|
||||||
*/
|
*/
|
||||||
public void setTarget(InstructionHandle target) {
|
public void setTarget(InstructionHandle target) {
|
||||||
notifyTarget(this.target, target, this);
|
notifyTarget(this.target, target, this);
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by BranchInstruction, LocalVariableGen, CodeExceptionGen
|
* Used by BranchInstruction, LocalVariableGen, CodeExceptionGen
|
||||||
*/
|
*/
|
||||||
static final void notifyTarget( InstructionHandle old_ih, InstructionHandle new_ih,
|
static final void notifyTarget(InstructionHandle old_ih,
|
||||||
InstructionTargeter t ) {
|
InstructionHandle new_ih, InstructionTargeter t) {
|
||||||
if (old_ih != null) {
|
if (old_ih != null) {
|
||||||
old_ih.removeTargeter(t);
|
old_ih.removeTargeter(t);
|
||||||
}
|
}
|
||||||
@ -197,31 +213,34 @@ public abstract class BranchInstruction extends Instruction implements Instructi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param old_ih old target
|
* @param old_ih
|
||||||
* @param new_ih new target
|
* old target
|
||||||
|
* @param new_ih
|
||||||
|
* new target
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
|
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
|
||||||
if (target == old_ih) {
|
if (target == old_ih) {
|
||||||
setTarget(new_ih);
|
setTarget(new_ih);
|
||||||
} else {
|
} else {
|
||||||
throw new ClassGenException("Not targeting " + old_ih + ", but " + target);
|
throw new ClassGenException("Not targeting " + old_ih + ", but "
|
||||||
|
+ target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true, if ih is target of this instruction
|
* @return true, if ih is target of this instruction
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean containsTarget(InstructionHandle ih) {
|
public boolean containsTarget(InstructionHandle ih) {
|
||||||
return (target == ih);
|
return (target == ih);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inform target that it's not targeted anymore.
|
* Inform target that it's not targeted anymore.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
setTarget(null);
|
setTarget(null);
|
||||||
index = -1;
|
index = -1;
|
||||||
|
@ -18,28 +18,38 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* CALOAD - Load char from array
|
* CALOAD - Load char from array
|
||||||
* <PRE>Stack: ..., arrayref, index -> ..., value</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., arrayref, index -> ..., value
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: CALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: CALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class CALOAD extends ArrayInstruction implements StackProducer {
|
public class CALOAD extends ArrayInstruction implements StackProducer {
|
||||||
|
|
||||||
/** Load char from array
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load char from array
|
||||||
*/
|
*/
|
||||||
public CALOAD() {
|
public CALOAD() {
|
||||||
super(org.apache.bcel.Constants.CALOAD);
|
super(org.apache.bcel.Constants.CALOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
v.visitExceptionThrower(this);
|
v.visitExceptionThrower(this);
|
||||||
|
@ -18,28 +18,38 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* CASTORE - Store into char array
|
* CASTORE - Store into char array
|
||||||
* <PRE>Stack: ..., arrayref, index, value -> ...</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., arrayref, index, value -> ...
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: CASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: CASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class CASTORE extends ArrayInstruction implements StackConsumer {
|
public class CASTORE extends ArrayInstruction implements StackConsumer {
|
||||||
|
|
||||||
/** Store char into array
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store char into array
|
||||||
*/
|
*/
|
||||||
public CASTORE() {
|
public CASTORE() {
|
||||||
super(org.apache.bcel.Constants.CASTORE);
|
super(org.apache.bcel.Constants.CASTORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitStackConsumer(this);
|
v.visitStackConsumer(this);
|
||||||
v.visitExceptionThrower(this);
|
v.visitExceptionThrower(this);
|
||||||
|
@ -20,13 +20,21 @@ import org.apache.bcel.ExceptionConstants;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* CHECKCAST - Check whether object is of given type
|
* CHECKCAST - Check whether object is of given type
|
||||||
* <PRE>Stack: ..., objectref -> ..., objectref</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., objectref -> ..., objectref
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: CHECKCAST.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: CHECKCAST.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class CHECKCAST extends CPInstruction implements LoadClass, ExceptionThrower, StackProducer,
|
public class CHECKCAST extends CPInstruction implements LoadClass,
|
||||||
StackConsumer {
|
ExceptionThrower, StackProducer, StackConsumer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor needed for the Class.newInstance() statement in
|
* Empty constructor needed for the Class.newInstance() statement in
|
||||||
@ -35,26 +43,31 @@ public class CHECKCAST extends CPInstruction implements LoadClass, ExceptionThro
|
|||||||
CHECKCAST() {
|
CHECKCAST() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Check whether object is of given type
|
* Check whether object is of given type
|
||||||
* @param index index to class in constant pool
|
*
|
||||||
|
* @param index
|
||||||
|
* index to class in constant pool
|
||||||
*/
|
*/
|
||||||
public CHECKCAST(int index) {
|
public CHECKCAST(int index) {
|
||||||
super(org.apache.bcel.Constants.CHECKCAST, index);
|
super(org.apache.bcel.Constants.CHECKCAST, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return exceptions this instruction may cause
|
* @return exceptions this instruction may cause
|
||||||
*/
|
*/
|
||||||
public Class[] getExceptions() {
|
@Override
|
||||||
Class[] cs = new Class[1 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length];
|
public Class<?>[] getExceptions() {
|
||||||
System.arraycopy(ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0, cs, 0,
|
Class<?>[] cs = new Class[1 + ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length];
|
||||||
|
System.arraycopy(
|
||||||
|
ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION, 0, cs,
|
||||||
|
0,
|
||||||
ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length);
|
ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length);
|
||||||
cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] = ExceptionConstants.CLASS_CAST_EXCEPTION;
|
cs[ExceptionConstants.EXCS_CLASS_AND_INTERFACE_RESOLUTION.length] = ExceptionConstants.CLASS_CAST_EXCEPTION;
|
||||||
return cs;
|
return cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ObjectType getLoadClassType(ConstantPoolGen cpg) {
|
public ObjectType getLoadClassType(ConstantPoolGen cpg) {
|
||||||
Type t = getType(cpg);
|
Type t = getType(cpg);
|
||||||
if (t instanceof ArrayType) {
|
if (t instanceof ArrayType) {
|
||||||
@ -63,15 +76,16 @@ public class CHECKCAST extends CPInstruction implements LoadClass, ExceptionThro
|
|||||||
return (t instanceof ObjectType) ? (ObjectType) t : null;
|
return (t instanceof ObjectType) ? (ObjectType) t : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitLoadClass(this);
|
v.visitLoadClass(this);
|
||||||
v.visitExceptionThrower(this);
|
v.visitExceptionThrower(this);
|
||||||
|
@ -24,8 +24,8 @@ import org.apache.bcel.classfile.ConstantPool;
|
|||||||
import org.apache.bcel.util.ByteSequence;
|
import org.apache.bcel.util.ByteSequence;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract super class for instructions that use an index into the
|
* Abstract super class for instructions that use an index into the constant
|
||||||
* constant pool such as LDC, INVOKEVIRTUAL, etc.
|
* pool such as LDC, INVOKEVIRTUAL, etc.
|
||||||
*
|
*
|
||||||
* @see ConstantPoolGen
|
* @see ConstantPoolGen
|
||||||
* @see LDC
|
* @see LDC
|
||||||
@ -34,12 +34,15 @@ import org.apache.bcel.util.ByteSequence;
|
|||||||
* @version $Id: CPInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: CPInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public abstract class CPInstruction extends Instruction implements TypedInstruction,
|
public abstract class CPInstruction extends Instruction implements
|
||||||
IndexedInstruction {
|
TypedInstruction, IndexedInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
protected int index; // index to constant pool
|
protected int index; // index to constant pool
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor needed for the Class.newInstance() statement in
|
* Empty constructor needed for the Class.newInstance() statement in
|
||||||
* Instruction.readInstruction(). Not to be used otherwise.
|
* Instruction.readInstruction(). Not to be used otherwise.
|
||||||
@ -47,43 +50,46 @@ public abstract class CPInstruction extends Instruction implements TypedInstruct
|
|||||||
CPInstruction() {
|
CPInstruction() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param index to constant pool
|
* @param index
|
||||||
|
* to constant pool
|
||||||
*/
|
*/
|
||||||
protected CPInstruction(short opcode, int index) {
|
protected CPInstruction(short opcode, int index) {
|
||||||
super(opcode, (short) 3);
|
super(opcode, (short) 3);
|
||||||
setIndex(index);
|
setIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump instruction as byte code to stream out.
|
* Dump instruction as byte code to stream out.
|
||||||
* @param out Output stream
|
*
|
||||||
|
* @param out
|
||||||
|
* Output stream
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void dump(DataOutputStream out) throws IOException {
|
public void dump(DataOutputStream out) throws IOException {
|
||||||
out.writeByte(opcode);
|
out.writeByte(opcode);
|
||||||
out.writeShort(index);
|
out.writeShort(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Long output format:
|
* Long output format:
|
||||||
*
|
*
|
||||||
* <name of opcode> "["<opcode number>"]"
|
* <name of opcode> "["<opcode number>"]" "("<length of
|
||||||
* "("<length of instruction>")" "<"< constant pool index>">"
|
* instruction>")" "<"< constant pool index>">"
|
||||||
*
|
*
|
||||||
* @param verbose long/short format switch
|
* @param verbose
|
||||||
|
* long/short format switch
|
||||||
* @return mnemonic for instruction
|
* @return mnemonic for instruction
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString(boolean verbose) {
|
public String toString(boolean verbose) {
|
||||||
return super.toString(verbose) + " " + index;
|
return super.toString(verbose) + " " + index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mnemonic for instruction with symbolic references resolved
|
* @return mnemonic for instruction with symbolic references resolved
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString(ConstantPool cp) {
|
public String toString(ConstantPool cp) {
|
||||||
Constant c = cp.getConstant(index);
|
Constant c = cp.getConstant(index);
|
||||||
String str = cp.constantToString(c);
|
String str = cp.constantToString(c);
|
||||||
@ -93,30 +99,36 @@ public abstract class CPInstruction extends Instruction implements TypedInstruct
|
|||||||
return org.apache.bcel.Constants.OPCODE_NAMES[opcode] + " " + str;
|
return org.apache.bcel.Constants.OPCODE_NAMES[opcode] + " " + str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read needed data (i.e., index) from file.
|
* Read needed data (i.e., index) from file.
|
||||||
* @param bytes input stream
|
*
|
||||||
* @param wide wide prefix?
|
* @param bytes
|
||||||
|
* input stream
|
||||||
|
* @param wide
|
||||||
|
* wide prefix?
|
||||||
*/
|
*/
|
||||||
protected void initFromFile( ByteSequence bytes, boolean wide ) throws IOException {
|
@Override
|
||||||
|
protected void initFromFile(ByteSequence bytes, boolean wide)
|
||||||
|
throws IOException {
|
||||||
setIndex(bytes.readUnsignedShort());
|
setIndex(bytes.readUnsignedShort());
|
||||||
length = 3;
|
length = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return index in constant pool referred by this instruction.
|
* @return index in constant pool referred by this instruction.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final int getIndex() {
|
public final int getIndex() {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the index to constant pool.
|
* Set the index to constant pool.
|
||||||
* @param index in constant pool.
|
*
|
||||||
|
* @param index
|
||||||
|
* in constant pool.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setIndex(int index) {
|
public void setIndex(int index) {
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
throw new ClassGenException("Negative index value: " + index);
|
throw new ClassGenException("Negative index value: " + index);
|
||||||
@ -124,12 +136,14 @@ public abstract class CPInstruction extends Instruction implements TypedInstruct
|
|||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return type related with this instruction.
|
* @return type related with this instruction.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Type getType(ConstantPoolGen cpg) {
|
public Type getType(ConstantPoolGen cpg) {
|
||||||
ConstantPool cp = cpg.getConstantPool();
|
ConstantPool cp = cpg.getConstantPool();
|
||||||
String name = cp.getConstantString(index, org.apache.bcel.Constants.CONSTANT_Class);
|
String name = cp.getConstantString(index,
|
||||||
|
org.apache.bcel.Constants.CONSTANT_Class);
|
||||||
if (!name.startsWith("[")) {
|
if (!name.startsWith("[")) {
|
||||||
name = "L" + name + ";";
|
name = "L" + name + ";";
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package org.apache.bcel.generic;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
import org.apache.bcel.classfile.AccessFlags;
|
import org.apache.bcel.classfile.AccessFlags;
|
||||||
import org.apache.bcel.classfile.Attribute;
|
import org.apache.bcel.classfile.Attribute;
|
||||||
@ -39,53 +40,67 @@ import org.apache.bcel.util.BCELComparator;
|
|||||||
*/
|
*/
|
||||||
public class ClassGen extends AccessFlags implements Cloneable {
|
public class ClassGen extends AccessFlags implements Cloneable {
|
||||||
|
|
||||||
/* Corresponds to the fields found in a JavaClass object.
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
/*
|
||||||
|
* Corresponds to the fields found in a JavaClass object.
|
||||||
*/
|
*/
|
||||||
private String class_name, super_class_name, file_name;
|
private String class_name, super_class_name, file_name;
|
||||||
private int class_name_index = -1, superclass_name_index = -1;
|
private int class_name_index = -1, superclass_name_index = -1;
|
||||||
private int major = Constants.MAJOR_1_1, minor = Constants.MINOR_1_1;
|
private int major = Constants.MAJOR_1_1, minor = Constants.MINOR_1_1;
|
||||||
private ConstantPoolGen cp; // Template for building up constant pool
|
private ConstantPoolGen cp; // Template for building up constant pool
|
||||||
// ArrayLists instead of arrays to gather fields, methods, etc.
|
// ArrayLists instead of arrays to gather fields, methods, etc.
|
||||||
private List field_vec = new ArrayList();
|
private List<Field> field_vec = new ArrayList<Field>();
|
||||||
private List method_vec = new ArrayList();
|
private List<Method> method_vec = new ArrayList<Method>();
|
||||||
private List attribute_vec = new ArrayList();
|
private List<Attribute> attribute_vec = new ArrayList<Attribute>();
|
||||||
private List interface_vec = new ArrayList();
|
private List<String> interface_vec = new ArrayList<String>();
|
||||||
private static BCELComparator _cmp = new BCELComparator() {
|
private static BCELComparator _cmp = new BCELComparator() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object o1, Object o2) {
|
public boolean equals(Object o1, Object o2) {
|
||||||
ClassGen THIS = (ClassGen) o1;
|
ClassGen THIS = (ClassGen) o1;
|
||||||
ClassGen THAT = (ClassGen) o2;
|
ClassGen THAT = (ClassGen) o2;
|
||||||
return THIS.getClassName().equals(THAT.getClassName());
|
return THIS.getClassName().equals(THAT.getClassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int hashCode(Object o) {
|
public int hashCode(Object o) {
|
||||||
ClassGen THIS = (ClassGen) o;
|
ClassGen THIS = (ClassGen) o;
|
||||||
return THIS.getClassName().hashCode();
|
return THIS.getClassName().hashCode();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
/** Convenience constructor to set up some important values initially.
|
* Convenience constructor to set up some important values initially.
|
||||||
*
|
*
|
||||||
* @param class_name fully qualified class name
|
* @param class_name
|
||||||
* @param super_class_name fully qualified superclass name
|
* fully qualified class name
|
||||||
* @param file_name source file name
|
* @param super_class_name
|
||||||
* @param access_flags access qualifiers
|
* fully qualified superclass name
|
||||||
* @param interfaces implemented interfaces
|
* @param file_name
|
||||||
* @param cp constant pool to use
|
* source file name
|
||||||
|
* @param access_flags
|
||||||
|
* access qualifiers
|
||||||
|
* @param interfaces
|
||||||
|
* implemented interfaces
|
||||||
|
* @param cp
|
||||||
|
* constant pool to use
|
||||||
*/
|
*/
|
||||||
public ClassGen(String class_name, String super_class_name, String file_name, int access_flags,
|
public ClassGen(String class_name, String super_class_name,
|
||||||
String[] interfaces, ConstantPoolGen cp) {
|
String file_name, int access_flags, String[] interfaces,
|
||||||
|
ConstantPoolGen cp) {
|
||||||
this.class_name = class_name;
|
this.class_name = class_name;
|
||||||
this.super_class_name = super_class_name;
|
this.super_class_name = super_class_name;
|
||||||
this.file_name = file_name;
|
this.file_name = file_name;
|
||||||
this.access_flags = access_flags;
|
this.access_flags = access_flags;
|
||||||
this.cp = cp;
|
this.cp = cp;
|
||||||
// Put everything needed by default into the constant pool and the vectors
|
// Put everything needed by default into the constant pool and the
|
||||||
|
// vectors
|
||||||
if (file_name != null) {
|
if (file_name != null) {
|
||||||
addAttribute(new SourceFile(cp.addUtf8("SourceFile"), 2, cp.addUtf8(file_name), cp
|
addAttribute(new SourceFile(cp.addUtf8("SourceFile"), 2,
|
||||||
.getConstantPool()));
|
cp.addUtf8(file_name), cp.getConstantPool()));
|
||||||
}
|
}
|
||||||
class_name_index = cp.addClass(class_name);
|
class_name_index = cp.addClass(class_name);
|
||||||
superclass_name_index = cp.addClass(super_class_name);
|
superclass_name_index = cp.addClass(super_class_name);
|
||||||
@ -96,25 +111,31 @@ public class ClassGen extends AccessFlags implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Convenience constructor to set up some important values initially.
|
* Convenience constructor to set up some important values initially.
|
||||||
*
|
*
|
||||||
* @param class_name fully qualified class name
|
* @param class_name
|
||||||
* @param super_class_name fully qualified superclass name
|
* fully qualified class name
|
||||||
* @param file_name source file name
|
* @param super_class_name
|
||||||
* @param access_flags access qualifiers
|
* fully qualified superclass name
|
||||||
* @param interfaces implemented interfaces
|
* @param file_name
|
||||||
|
* source file name
|
||||||
|
* @param access_flags
|
||||||
|
* access qualifiers
|
||||||
|
* @param interfaces
|
||||||
|
* implemented interfaces
|
||||||
*/
|
*/
|
||||||
public ClassGen(String class_name, String super_class_name, String file_name, int access_flags,
|
public ClassGen(String class_name, String super_class_name,
|
||||||
String[] interfaces) {
|
String file_name, int access_flags, String[] interfaces) {
|
||||||
this(class_name, super_class_name, file_name, access_flags, interfaces,
|
this(class_name, super_class_name, file_name, access_flags, interfaces,
|
||||||
new ConstantPoolGen());
|
new ConstantPoolGen());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize with existing class.
|
* Initialize with existing class.
|
||||||
* @param clazz JavaClass object (e.g. read from file)
|
*
|
||||||
|
* @param clazz
|
||||||
|
* JavaClass object (e.g. read from file)
|
||||||
*/
|
*/
|
||||||
public ClassGen(JavaClass clazz) {
|
public ClassGen(JavaClass clazz) {
|
||||||
class_name_index = clazz.getClassNameIndex();
|
class_name_index = clazz.getClassNameIndex();
|
||||||
@ -144,7 +165,6 @@ public class ClassGen extends AccessFlags implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the (finally) built up Java class object.
|
* @return the (finally) built up Java class object.
|
||||||
*/
|
*/
|
||||||
@ -155,29 +175,31 @@ public class ClassGen extends AccessFlags implements Cloneable {
|
|||||||
Attribute[] attributes = getAttributes();
|
Attribute[] attributes = getAttributes();
|
||||||
// Must be last since the above calls may still add something to it
|
// Must be last since the above calls may still add something to it
|
||||||
ConstantPool _cp = this.cp.getFinalConstantPool();
|
ConstantPool _cp = this.cp.getFinalConstantPool();
|
||||||
return new JavaClass(class_name_index, superclass_name_index, file_name, major, minor,
|
return new JavaClass(class_name_index, superclass_name_index,
|
||||||
access_flags, _cp, interfaces, fields, methods, attributes);
|
file_name, major, minor, access_flags, _cp, interfaces, fields,
|
||||||
|
methods, attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an interface to this class, i.e., this class has to implement it.
|
* Add an interface to this class, i.e., this class has to implement it.
|
||||||
* @param name interface to implement (fully qualified class name)
|
*
|
||||||
|
* @param name
|
||||||
|
* interface to implement (fully qualified class name)
|
||||||
*/
|
*/
|
||||||
public void addInterface(String name) {
|
public void addInterface(String name) {
|
||||||
interface_vec.add(name);
|
interface_vec.add(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an interface from this class.
|
* Remove an interface from this class.
|
||||||
* @param name interface to remove (fully qualified name)
|
*
|
||||||
|
* @param name
|
||||||
|
* interface to remove (fully qualified name)
|
||||||
*/
|
*/
|
||||||
public void removeInterface(String name) {
|
public void removeInterface(String name) {
|
||||||
interface_vec.remove(name);
|
interface_vec.remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return major version number of class file
|
* @return major version number of class file
|
||||||
*/
|
*/
|
||||||
@ -185,23 +207,26 @@ public class ClassGen extends AccessFlags implements Cloneable {
|
|||||||
return major;
|
return major;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Set major version number of class file, default value is 45 (JDK 1.1)
|
* Set major version number of class file, default value is 45 (JDK 1.1)
|
||||||
* @param major major version number
|
*
|
||||||
|
* @param major
|
||||||
|
* major version number
|
||||||
*/
|
*/
|
||||||
public void setMajor(int major) {
|
public void setMajor(int major) {
|
||||||
this.major = major;
|
this.major = major;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Set minor version number of class file, default value is 3 (JDK 1.1)
|
* Set minor version number of class file, default value is 3 (JDK 1.1)
|
||||||
* @param minor minor version number
|
*
|
||||||
|
* @param minor
|
||||||
|
* minor version number
|
||||||
*/
|
*/
|
||||||
public void setMinor(int minor) {
|
public void setMinor(int minor) {
|
||||||
this.minor = minor;
|
this.minor = minor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return minor version number of class file
|
* @return minor version number of class file
|
||||||
*/
|
*/
|
||||||
@ -209,62 +234,67 @@ public class ClassGen extends AccessFlags implements Cloneable {
|
|||||||
return minor;
|
return minor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an attribute to this class.
|
* Add an attribute to this class.
|
||||||
* @param a attribute to add
|
*
|
||||||
|
* @param a
|
||||||
|
* attribute to add
|
||||||
*/
|
*/
|
||||||
public void addAttribute(Attribute a) {
|
public void addAttribute(Attribute a) {
|
||||||
attribute_vec.add(a);
|
attribute_vec.add(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a method to this class.
|
* Add a method to this class.
|
||||||
* @param m method to add
|
*
|
||||||
|
* @param m
|
||||||
|
* method to add
|
||||||
*/
|
*/
|
||||||
public void addMethod(Method m) {
|
public void addMethod(Method m) {
|
||||||
method_vec.add(m);
|
method_vec.add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method.
|
* Convenience method.
|
||||||
*
|
*
|
||||||
* Add an empty constructor to this class that does nothing but calling super().
|
* Add an empty constructor to this class that does nothing but calling
|
||||||
* @param access_flags rights for constructor
|
* super().
|
||||||
|
*
|
||||||
|
* @param access_flags
|
||||||
|
* rights for constructor
|
||||||
*/
|
*/
|
||||||
public void addEmptyConstructor(int access_flags) {
|
public void addEmptyConstructor(int access_flags) {
|
||||||
InstructionList il = new InstructionList();
|
InstructionList il = new InstructionList();
|
||||||
il.append(InstructionConstants.THIS); // Push `this'
|
il.append(InstructionConstants.THIS); // Push `this'
|
||||||
il.append(new INVOKESPECIAL(cp.addMethodref(super_class_name, "<init>", "()V")));
|
il.append(new INVOKESPECIAL(cp.addMethodref(super_class_name, "<init>",
|
||||||
|
"()V")));
|
||||||
il.append(InstructionConstants.RETURN);
|
il.append(InstructionConstants.RETURN);
|
||||||
MethodGen mg = new MethodGen(access_flags, Type.VOID, Type.NO_ARGS, null, "<init>",
|
MethodGen mg = new MethodGen(access_flags, Type.VOID, Type.NO_ARGS,
|
||||||
class_name, il, cp);
|
null, "<init>", class_name, il, cp);
|
||||||
mg.setMaxStack(1);
|
mg.setMaxStack(1);
|
||||||
addMethod(mg.getMethod());
|
addMethod(mg.getMethod());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a field to this class.
|
* Add a field to this class.
|
||||||
* @param f field to add
|
*
|
||||||
|
* @param f
|
||||||
|
* field to add
|
||||||
*/
|
*/
|
||||||
public void addField(Field f) {
|
public void addField(Field f) {
|
||||||
field_vec.add(f);
|
field_vec.add(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean containsField(Field f) {
|
public boolean containsField(Field f) {
|
||||||
return field_vec.contains(f);
|
return field_vec.contains(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return field object with given name, or null
|
* @return field object with given name, or null
|
||||||
*/
|
*/
|
||||||
public Field containsField(String name) {
|
public Field containsField(String name) {
|
||||||
for (Iterator e = field_vec.iterator(); e.hasNext();) {
|
for (Iterator<Field> e = field_vec.iterator(); e.hasNext();) {
|
||||||
Field f = (Field) e.next();
|
Field f = e.next();
|
||||||
if (f.getName().equals(name)) {
|
if (f.getName().equals(name)) {
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
@ -272,12 +302,12 @@ public class ClassGen extends AccessFlags implements Cloneable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return method object with given name and signature, or null
|
* @return method object with given name and signature, or null
|
||||||
*/
|
*/
|
||||||
public Method containsMethod(String name, String signature) {
|
public Method containsMethod(String name, String signature) {
|
||||||
for (Iterator e = method_vec.iterator(); e.hasNext();) {
|
for (Iterator<Method> e = method_vec.iterator(); e.hasNext();) {
|
||||||
Method m = (Method) e.next();
|
Method m = e.next();
|
||||||
if (m.getName().equals(name) && m.getSignature().equals(signature)) {
|
if (m.getName().equals(name) && m.getSignature().equals(signature)) {
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
@ -285,27 +315,29 @@ public class ClassGen extends AccessFlags implements Cloneable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an attribute from this class.
|
* Remove an attribute from this class.
|
||||||
* @param a attribute to remove
|
*
|
||||||
|
* @param a
|
||||||
|
* attribute to remove
|
||||||
*/
|
*/
|
||||||
public void removeAttribute(Attribute a) {
|
public void removeAttribute(Attribute a) {
|
||||||
attribute_vec.remove(a);
|
attribute_vec.remove(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a method from this class.
|
* Remove a method from this class.
|
||||||
* @param m method to remove
|
*
|
||||||
|
* @param m
|
||||||
|
* method to remove
|
||||||
*/
|
*/
|
||||||
public void removeMethod(Method m) {
|
public void removeMethod(Method m) {
|
||||||
method_vec.remove(m);
|
method_vec.remove(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Replace given method with new one. If the old one does not exist
|
* Replace given method with new one. If the old one does not exist add the
|
||||||
* add the new_ method to the class anyway.
|
* new_ method to the class anyway.
|
||||||
*/
|
*/
|
||||||
public void replaceMethod(Method old, Method new_) {
|
public void replaceMethod(Method old, Method new_) {
|
||||||
if (new_ == null) {
|
if (new_ == null) {
|
||||||
@ -319,9 +351,9 @@ public class ClassGen extends AccessFlags implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Replace given field with new one. If the old one does not exist
|
* Replace given field with new one. If the old one does not exist add the
|
||||||
* add the new_ field to the class anyway.
|
* new_ field to the class anyway.
|
||||||
*/
|
*/
|
||||||
public void replaceField(Field old, Field new_) {
|
public void replaceField(Field old, Field new_) {
|
||||||
if (new_ == null) {
|
if (new_ == null) {
|
||||||
@ -335,48 +367,42 @@ public class ClassGen extends AccessFlags implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a field to this class.
|
* Remove a field to this class.
|
||||||
* @param f field to remove
|
*
|
||||||
|
* @param f
|
||||||
|
* field to remove
|
||||||
*/
|
*/
|
||||||
public void removeField(Field f) {
|
public void removeField(Field f) {
|
||||||
field_vec.remove(f);
|
field_vec.remove(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getClassName() {
|
public String getClassName() {
|
||||||
return class_name;
|
return class_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getSuperclassName() {
|
public String getSuperclassName() {
|
||||||
return super_class_name;
|
return super_class_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
return file_name;
|
return file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setClassName(String name) {
|
public void setClassName(String name) {
|
||||||
class_name = name.replace('/', '.');
|
class_name = name.replace('/', '.');
|
||||||
class_name_index = cp.addClass(name);
|
class_name_index = cp.addClass(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setSuperclassName(String name) {
|
public void setSuperclassName(String name) {
|
||||||
super_class_name = name.replace('/', '.');
|
super_class_name = name.replace('/', '.');
|
||||||
superclass_name_index = cp.addClass(name);
|
superclass_name_index = cp.addClass(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Method[] getMethods() {
|
public Method[] getMethods() {
|
||||||
return (Method[]) method_vec.toArray(new Method[method_vec.size()]);
|
return method_vec.toArray(new Method[method_vec.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setMethods(Method[] methods) {
|
public void setMethods(Method[] methods) {
|
||||||
method_vec.clear();
|
method_vec.clear();
|
||||||
for (int m = 0; m < methods.length; m++) {
|
for (int m = 0; m < methods.length; m++) {
|
||||||
@ -384,17 +410,14 @@ public class ClassGen extends AccessFlags implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setMethodAt(Method method, int pos) {
|
public void setMethodAt(Method method, int pos) {
|
||||||
method_vec.set(pos, method);
|
method_vec.set(pos, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Method getMethodAt(int pos) {
|
public Method getMethodAt(int pos) {
|
||||||
return (Method) method_vec.get(pos);
|
return method_vec.get(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String[] getInterfaceNames() {
|
public String[] getInterfaceNames() {
|
||||||
int size = interface_vec.size();
|
int size = interface_vec.size();
|
||||||
String[] interfaces = new String[size];
|
String[] interfaces = new String[size];
|
||||||
@ -402,74 +425,68 @@ public class ClassGen extends AccessFlags implements Cloneable {
|
|||||||
return interfaces;
|
return interfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int[] getInterfaces() {
|
public int[] getInterfaces() {
|
||||||
int size = interface_vec.size();
|
int size = interface_vec.size();
|
||||||
int[] interfaces = new int[size];
|
int[] interfaces = new int[size];
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
interfaces[i] = cp.addClass((String) interface_vec.get(i));
|
interfaces[i] = cp.addClass(interface_vec.get(i));
|
||||||
}
|
}
|
||||||
return interfaces;
|
return interfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Field[] getFields() {
|
public Field[] getFields() {
|
||||||
return (Field[]) field_vec.toArray(new Field[field_vec.size()]);
|
return field_vec.toArray(new Field[field_vec.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Attribute[] getAttributes() {
|
public Attribute[] getAttributes() {
|
||||||
return (Attribute[]) attribute_vec.toArray(new Attribute[attribute_vec.size()]);
|
return attribute_vec.toArray(new Attribute[attribute_vec.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ConstantPoolGen getConstantPool() {
|
public ConstantPoolGen getConstantPool() {
|
||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setConstantPool(ConstantPoolGen constant_pool) {
|
public void setConstantPool(ConstantPoolGen constant_pool) {
|
||||||
cp = constant_pool;
|
cp = constant_pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setClassNameIndex(int class_name_index) {
|
public void setClassNameIndex(int class_name_index) {
|
||||||
this.class_name_index = class_name_index;
|
this.class_name_index = class_name_index;
|
||||||
class_name = cp.getConstantPool().getConstantString(class_name_index,
|
class_name = cp.getConstantPool()
|
||||||
Constants.CONSTANT_Class).replace('/', '.');
|
.getConstantString(class_name_index, Constants.CONSTANT_Class)
|
||||||
|
.replace('/', '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setSuperclassNameIndex(int superclass_name_index) {
|
public void setSuperclassNameIndex(int superclass_name_index) {
|
||||||
this.superclass_name_index = superclass_name_index;
|
this.superclass_name_index = superclass_name_index;
|
||||||
super_class_name = cp.getConstantPool().getConstantString(superclass_name_index,
|
super_class_name = cp
|
||||||
|
.getConstantPool()
|
||||||
|
.getConstantString(superclass_name_index,
|
||||||
Constants.CONSTANT_Class).replace('/', '.');
|
Constants.CONSTANT_Class).replace('/', '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getSuperclassNameIndex() {
|
public int getSuperclassNameIndex() {
|
||||||
return superclass_name_index;
|
return superclass_name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getClassNameIndex() {
|
public int getClassNameIndex() {
|
||||||
return class_name_index;
|
return class_name_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList observers;
|
private ArrayList<ClassObserver> observers;
|
||||||
|
|
||||||
|
/**
|
||||||
/** Add observer for this object.
|
* Add observer for this object.
|
||||||
*/
|
*/
|
||||||
public void addObserver(ClassObserver o) {
|
public void addObserver(ClassObserver o) {
|
||||||
if (observers == null) {
|
if (observers == null) {
|
||||||
observers = new ArrayList();
|
observers = new ArrayList<ClassObserver>();
|
||||||
}
|
}
|
||||||
observers.add(o);
|
observers.add(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Remove observer for this object.
|
* Remove observer for this object.
|
||||||
*/
|
*/
|
||||||
public void removeObserver(ClassObserver o) {
|
public void removeObserver(ClassObserver o) {
|
||||||
if (observers != null) {
|
if (observers != null) {
|
||||||
@ -477,20 +494,20 @@ public class ClassGen extends AccessFlags implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Call notify() method on all observers. This method is not called
|
* Call notify() method on all observers. This method is not called
|
||||||
* automatically whenever the state has changed, but has to be
|
* automatically whenever the state has changed, but has to be called by the
|
||||||
* called by the user after he has finished editing the object.
|
* user after he has finished editing the object.
|
||||||
*/
|
*/
|
||||||
public void update() {
|
public void update() {
|
||||||
if (observers != null) {
|
if (observers != null) {
|
||||||
for (Iterator e = observers.iterator(); e.hasNext();) {
|
for (Iterator<ClassObserver> e = observers.iterator(); e.hasNext();) {
|
||||||
((ClassObserver) e.next()).notify(this);
|
e.next().notify(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
try {
|
try {
|
||||||
return super.clone();
|
return super.clone();
|
||||||
@ -500,7 +517,6 @@ public class ClassGen extends AccessFlags implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Comparison strategy object
|
* @return Comparison strategy object
|
||||||
*/
|
*/
|
||||||
@ -508,33 +524,32 @@ public class ClassGen extends AccessFlags implements Cloneable {
|
|||||||
return _cmp;
|
return _cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param comparator Comparison strategy object
|
* @param comparator
|
||||||
|
* Comparison strategy object
|
||||||
*/
|
*/
|
||||||
public static void setComparator(BCELComparator comparator) {
|
public static void setComparator(BCELComparator comparator) {
|
||||||
_cmp = comparator;
|
_cmp = comparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value as defined by given BCELComparator strategy.
|
* Return value as defined by given BCELComparator strategy. By default two
|
||||||
* By default two ClassGen objects are said to be equal when
|
* ClassGen objects are said to be equal when their class names are equal.
|
||||||
* their class names are equal.
|
|
||||||
*
|
*
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return _cmp.equals(this, obj);
|
return _cmp.equals(this, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value as defined by given BCELComparator strategy.
|
* Return value as defined by given BCELComparator strategy. By default
|
||||||
* By default return the hashcode of the class name.
|
* return the hashcode of the class name.
|
||||||
*
|
*
|
||||||
* @see java.lang.Object#hashCode()
|
* @see java.lang.Object#hashCode()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return _cmp.hashCode(this);
|
return _cmp.hashCode(this);
|
||||||
}
|
}
|
||||||
|
@ -17,19 +17,23 @@
|
|||||||
package org.apache.bcel.generic;
|
package org.apache.bcel.generic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown on internal errors. Extends RuntimeException so it hasn't to be declared
|
* Thrown on internal errors. Extends RuntimeException so it hasn't to be
|
||||||
* in the throws clause every time.
|
* declared in the throws clause every time.
|
||||||
*
|
*
|
||||||
* @version $Id: ClassGenException.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ClassGenException.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class ClassGenException extends RuntimeException {
|
public class ClassGenException extends RuntimeException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public ClassGenException() {
|
public ClassGenException() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ClassGenException(String s) {
|
public ClassGenException(String s) {
|
||||||
super(s);
|
super(s);
|
||||||
}
|
}
|
||||||
|
@ -33,49 +33,60 @@ import org.apache.bcel.classfile.CodeException;
|
|||||||
* @see CodeException
|
* @see CodeException
|
||||||
* @see InstructionHandle
|
* @see InstructionHandle
|
||||||
*/
|
*/
|
||||||
public final class CodeExceptionGen implements InstructionTargeter, Cloneable, java.io.Serializable {
|
public final class CodeExceptionGen implements InstructionTargeter, Cloneable,
|
||||||
|
java.io.Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private InstructionHandle start_pc;
|
private InstructionHandle start_pc;
|
||||||
private InstructionHandle end_pc;
|
private InstructionHandle end_pc;
|
||||||
private InstructionHandle handler_pc;
|
private InstructionHandle handler_pc;
|
||||||
private ObjectType catch_type;
|
private ObjectType catch_type;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an exception handler, i.e., specify region where a handler is active and an
|
* Add an exception handler, i.e., specify region where a handler is active
|
||||||
* instruction where the actual handling is done.
|
* and an instruction where the actual handling is done.
|
||||||
*
|
*
|
||||||
* @param start_pc Start of handled region (inclusive)
|
* @param start_pc
|
||||||
* @param end_pc End of handled region (inclusive)
|
* Start of handled region (inclusive)
|
||||||
* @param handler_pc Where handling is done
|
* @param end_pc
|
||||||
* @param catch_type which exception is handled, null for ANY
|
* 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,
|
public CodeExceptionGen(InstructionHandle start_pc,
|
||||||
InstructionHandle handler_pc, ObjectType catch_type) {
|
InstructionHandle end_pc, InstructionHandle handler_pc,
|
||||||
|
ObjectType catch_type) {
|
||||||
setStartPC(start_pc);
|
setStartPC(start_pc);
|
||||||
setEndPC(end_pc);
|
setEndPC(end_pc);
|
||||||
setHandlerPC(handler_pc);
|
setHandlerPC(handler_pc);
|
||||||
this.catch_type = catch_type;
|
this.catch_type = catch_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get CodeException object.<BR>
|
* Get CodeException object.<BR>
|
||||||
*
|
*
|
||||||
* This relies on that the instruction list has already been dumped
|
* This relies on that the instruction list has already been dumped to byte
|
||||||
* to byte code or or that the `setPositions' methods has been
|
* code or or that the `setPositions' methods has been called for the
|
||||||
* called for the instruction list.
|
* instruction list.
|
||||||
*
|
*
|
||||||
* @param cp constant pool
|
* @param cp
|
||||||
|
* constant pool
|
||||||
*/
|
*/
|
||||||
public CodeException getCodeException(ConstantPoolGen cp) {
|
public CodeException getCodeException(ConstantPoolGen cp) {
|
||||||
return new CodeException(start_pc.getPosition(), end_pc.getPosition()
|
return new CodeException(start_pc.getPosition(), end_pc.getPosition()
|
||||||
+ end_pc.getInstruction().getLength(), handler_pc.getPosition(),
|
+ end_pc.getInstruction().getLength(),
|
||||||
(catch_type == null) ? 0 : cp.addClass(catch_type));
|
handler_pc.getPosition(), (catch_type == null) ? 0
|
||||||
|
: cp.addClass(catch_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
/* Set start of handler
|
* Set start of handler
|
||||||
|
*
|
||||||
* @param start_pc Start of handled region (inclusive)
|
* @param start_pc Start of handled region (inclusive)
|
||||||
*/
|
*/
|
||||||
public void setStartPC(InstructionHandle start_pc) {
|
public void setStartPC(InstructionHandle start_pc) {
|
||||||
@ -83,8 +94,9 @@ public final class CodeExceptionGen implements InstructionTargeter, Cloneable, j
|
|||||||
this.start_pc = start_pc;
|
this.start_pc = start_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
/* Set end of handler
|
* Set end of handler
|
||||||
|
*
|
||||||
* @param end_pc End of handled region (inclusive)
|
* @param end_pc End of handled region (inclusive)
|
||||||
*/
|
*/
|
||||||
public void setEndPC(InstructionHandle end_pc) {
|
public void setEndPC(InstructionHandle end_pc) {
|
||||||
@ -92,8 +104,9 @@ public final class CodeExceptionGen implements InstructionTargeter, Cloneable, j
|
|||||||
this.end_pc = end_pc;
|
this.end_pc = end_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
/* Set handler code
|
* Set handler code
|
||||||
|
*
|
||||||
* @param handler_pc Start of handler
|
* @param handler_pc Start of handler
|
||||||
*/
|
*/
|
||||||
public void setHandlerPC(InstructionHandle handler_pc) {
|
public void setHandlerPC(InstructionHandle handler_pc) {
|
||||||
@ -101,11 +114,13 @@ public final class CodeExceptionGen implements InstructionTargeter, Cloneable, j
|
|||||||
this.handler_pc = handler_pc;
|
this.handler_pc = handler_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param old_ih old target, either start or end
|
* @param old_ih
|
||||||
* @param new_ih new target
|
* old target, either start or end
|
||||||
|
* @param new_ih
|
||||||
|
* new target
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
|
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
|
||||||
boolean targeted = false;
|
boolean targeted = false;
|
||||||
if (start_pc == old_ih) {
|
if (start_pc == old_ih) {
|
||||||
@ -121,58 +136,57 @@ public final class CodeExceptionGen implements InstructionTargeter, Cloneable, j
|
|||||||
setHandlerPC(new_ih);
|
setHandlerPC(new_ih);
|
||||||
}
|
}
|
||||||
if (!targeted) {
|
if (!targeted) {
|
||||||
throw new ClassGenException("Not targeting " + old_ih + ", but {" + start_pc + ", "
|
throw new ClassGenException("Not targeting " + old_ih + ", but {"
|
||||||
+ end_pc + ", " + handler_pc + "}");
|
+ start_pc + ", " + end_pc + ", " + handler_pc + "}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true, if ih is target of this handler
|
* @return true, if ih is target of this handler
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean containsTarget(InstructionHandle ih) {
|
public boolean containsTarget(InstructionHandle ih) {
|
||||||
return (start_pc == ih) || (end_pc == ih) || (handler_pc == ih);
|
return (start_pc == ih) || (end_pc == ih) || (handler_pc == ih);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Sets the type of the Exception to catch. Set 'null' for ANY. */
|
/** Sets the type of the Exception to catch. Set 'null' for ANY. */
|
||||||
public void setCatchType(ObjectType catch_type) {
|
public void setCatchType(ObjectType catch_type) {
|
||||||
this.catch_type = catch_type;
|
this.catch_type = catch_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Gets the type of the Exception to catch, 'null' for ANY. */
|
/** Gets the type of the Exception to catch, 'null' for ANY. */
|
||||||
public ObjectType getCatchType() {
|
public ObjectType getCatchType() {
|
||||||
return catch_type;
|
return catch_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return start of handled region (inclusive)
|
* @return start of handled region (inclusive)
|
||||||
*/
|
*/
|
||||||
public InstructionHandle getStartPC() {
|
public InstructionHandle getStartPC() {
|
||||||
return start_pc;
|
return start_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return end of handled region (inclusive)
|
* @return end of handled region (inclusive)
|
||||||
*/
|
*/
|
||||||
public InstructionHandle getEndPC() {
|
public InstructionHandle getEndPC() {
|
||||||
return end_pc;
|
return end_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return start of handler
|
* @return start of handler
|
||||||
*/
|
*/
|
||||||
public InstructionHandle getHandlerPC() {
|
public InstructionHandle getHandlerPC() {
|
||||||
return handler_pc;
|
return handler_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CodeExceptionGen(" + start_pc + ", " + end_pc + ", " + handler_pc + ")";
|
return "CodeExceptionGen(" + start_pc + ", " + end_pc + ", "
|
||||||
|
+ handler_pc + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
try {
|
try {
|
||||||
return super.clone();
|
return super.clone();
|
||||||
|
@ -17,15 +17,14 @@
|
|||||||
package org.apache.bcel.generic;
|
package org.apache.bcel.generic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper class for `compound' operations, virtual instructions that
|
* Wrapper class for `compound' operations, virtual instructions that don't
|
||||||
* don't exist as byte code, but give a useful meaning. For example,
|
* exist as byte code, but give a useful meaning. For example, the (virtual)
|
||||||
* the (virtual) PUSH instruction takes an arbitray argument and produces the
|
* PUSH instruction takes an arbitray argument and produces the appropiate code
|
||||||
* appropiate code at dump time (ICONST, LDC, BIPUSH, ...). Also you can use the
|
* at dump time (ICONST, LDC, BIPUSH, ...). Also you can use the SWITCH
|
||||||
* SWITCH instruction as a useful template for either LOOKUPSWITCH or
|
* instruction as a useful template for either LOOKUPSWITCH or TABLESWITCH.
|
||||||
* TABLESWITCH.
|
|
||||||
*
|
*
|
||||||
* The interface provides the possibilty for the user to write
|
* The interface provides the possibilty for the user to write `templates' or
|
||||||
* `templates' or `macros' for such reuseable code patterns.
|
* `macros' for such reuseable code patterns.
|
||||||
*
|
*
|
||||||
* @version $Id: CompoundInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: CompoundInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
|
@ -18,6 +18,7 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.bcel.Constants;
|
import org.apache.bcel.Constants;
|
||||||
import org.apache.bcel.classfile.Constant;
|
import org.apache.bcel.classfile.Constant;
|
||||||
import org.apache.bcel.classfile.ConstantCP;
|
import org.apache.bcel.classfile.ConstantCP;
|
||||||
@ -35,14 +36,13 @@ import org.apache.bcel.classfile.ConstantString;
|
|||||||
import org.apache.bcel.classfile.ConstantUtf8;
|
import org.apache.bcel.classfile.ConstantUtf8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to build up a constant pool. The user adds
|
* This class is used to build up a constant pool. The user adds constants via
|
||||||
* constants via `addXXX' methods, `addString', `addClass',
|
* `addXXX' methods, `addString', `addClass', etc.. These methods return an
|
||||||
* etc.. These methods return an index into the constant
|
* index into the constant pool. Finally, `getFinalConstantPool()' returns the
|
||||||
* pool. Finally, `getFinalConstantPool()' returns the constant pool
|
* constant pool built up. Intermediate versions of the constant pool can be
|
||||||
* built up. Intermediate versions of the constant pool can be
|
|
||||||
* obtained with `getConstantPool()'. A constant pool has capacity for
|
* obtained with `getConstantPool()'. A constant pool has capacity for
|
||||||
* Constants.MAX_SHORT entries. Note that the first (0) is used by the
|
* Constants.MAX_SHORT entries. Note that the first (0) is used by the JVM and
|
||||||
* JVM and that Double and Long constants need two slots.
|
* that Double and Long constants need two slots.
|
||||||
*
|
*
|
||||||
* @version $Id: ConstantPoolGen.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConstantPoolGen.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
@ -50,6 +50,10 @@ import org.apache.bcel.classfile.ConstantUtf8;
|
|||||||
*/
|
*/
|
||||||
public class ConstantPoolGen implements java.io.Serializable {
|
public class ConstantPoolGen implements java.io.Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
protected int size = 1024; // Inital size, sufficient in most cases
|
protected int size = 1024; // Inital size, sufficient in most cases
|
||||||
protected Constant[] constants = new Constant[size];
|
protected Constant[] constants = new Constant[size];
|
||||||
protected int index = 1; // First entry (0) used by JVM
|
protected int index = 1; // First entry (0) used by JVM
|
||||||
@ -60,19 +64,22 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
|
|
||||||
private static class Index implements java.io.Serializable {
|
private static class Index implements java.io.Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
|
|
||||||
Index(int i) {
|
Index(int i) {
|
||||||
index = i;
|
index = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize with given array of constants.
|
* Initialize with given array of constants.
|
||||||
*
|
*
|
||||||
* @param cs array of given constants, new ones will be appended
|
* @param cs
|
||||||
|
* array of given constants, new ones will be appended
|
||||||
*/
|
*/
|
||||||
public ConstantPoolGen(Constant[] cs) {
|
public ConstantPoolGen(Constant[] cs) {
|
||||||
if (cs.length > size) {
|
if (cs.length > size) {
|
||||||
@ -102,7 +109,8 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
} else if (c instanceof ConstantNameAndType) {
|
} else if (c instanceof ConstantNameAndType) {
|
||||||
ConstantNameAndType n = (ConstantNameAndType) c;
|
ConstantNameAndType n = (ConstantNameAndType) c;
|
||||||
ConstantUtf8 u8 = (ConstantUtf8) constants[n.getNameIndex()];
|
ConstantUtf8 u8 = (ConstantUtf8) constants[n.getNameIndex()];
|
||||||
ConstantUtf8 u8_2 = (ConstantUtf8) constants[n.getSignatureIndex()];
|
ConstantUtf8 u8_2 = (ConstantUtf8) constants[n
|
||||||
|
.getSignatureIndex()];
|
||||||
String key = u8.getBytes() + NAT_DELIM + u8_2.getBytes();
|
String key = u8.getBytes() + NAT_DELIM + u8_2.getBytes();
|
||||||
if (!n_a_t_table.containsKey(key)) {
|
if (!n_a_t_table.containsKey(key)) {
|
||||||
n_a_t_table.put(key, new Index(i));
|
n_a_t_table.put(key, new Index(i));
|
||||||
@ -115,8 +123,10 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
} else if (c instanceof ConstantCP) {
|
} else if (c instanceof ConstantCP) {
|
||||||
ConstantCP m = (ConstantCP) c;
|
ConstantCP m = (ConstantCP) c;
|
||||||
ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()];
|
ConstantClass clazz = (ConstantClass) constants[m
|
||||||
ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()];
|
.getClassIndex()];
|
||||||
|
ConstantNameAndType n = (ConstantNameAndType) constants[m
|
||||||
|
.getNameAndTypeIndex()];
|
||||||
ConstantUtf8 u8 = (ConstantUtf8) constants[clazz.getNameIndex()];
|
ConstantUtf8 u8 = (ConstantUtf8) constants[clazz.getNameIndex()];
|
||||||
String class_name = u8.getBytes().replace('/', '.');
|
String class_name = u8.getBytes().replace('/', '.');
|
||||||
u8 = (ConstantUtf8) constants[n.getNameIndex()];
|
u8 = (ConstantUtf8) constants[n.getNameIndex()];
|
||||||
@ -129,7 +139,8 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
} else if (c instanceof ConstantFieldref) {
|
} else if (c instanceof ConstantFieldref) {
|
||||||
delim = FIELDREF_DELIM;
|
delim = FIELDREF_DELIM;
|
||||||
}
|
}
|
||||||
String key = class_name + delim + method_name + delim + signature;
|
String key = class_name + delim + method_name + delim
|
||||||
|
+ signature;
|
||||||
if (!cp_table.containsKey(key)) {
|
if (!cp_table.containsKey(key)) {
|
||||||
cp_table.put(key, new Index(i));
|
cp_table.put(key, new Index(i));
|
||||||
}
|
}
|
||||||
@ -137,7 +148,6 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize with given constant pool.
|
* Initialize with given constant pool.
|
||||||
*/
|
*/
|
||||||
@ -145,15 +155,14 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
this(cp.getConstantPool());
|
this(cp.getConstantPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create empty constant pool.
|
* Create empty constant pool.
|
||||||
*/
|
*/
|
||||||
public ConstantPoolGen() {
|
public ConstantPoolGen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Resize internal array of constants.
|
* Resize internal array of constants.
|
||||||
*/
|
*/
|
||||||
protected void adjustSize() {
|
protected void adjustSize() {
|
||||||
if (index + 3 >= size) {
|
if (index + 3 >= size) {
|
||||||
@ -164,25 +173,26 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map string_table = new HashMap();
|
private Map<String, Index> string_table = new HashMap<String, Index>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look for ConstantString in ConstantPool containing String `str'.
|
* Look for ConstantString in ConstantPool containing String `str'.
|
||||||
*
|
*
|
||||||
* @param str String to search for
|
* @param str
|
||||||
|
* String to search for
|
||||||
* @return index on success, -1 otherwise
|
* @return index on success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
public int lookupString(String str) {
|
public int lookupString(String str) {
|
||||||
Index index = (Index) string_table.get(str);
|
Index index = string_table.get(str);
|
||||||
return (index != null) ? index.index : -1;
|
return (index != null) ? index.index : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new String constant to the ConstantPool, if it is not already in there.
|
* Add a new String constant to the ConstantPool, if it is not already in
|
||||||
|
* there.
|
||||||
*
|
*
|
||||||
* @param str String to add
|
* @param str
|
||||||
|
* String to add
|
||||||
* @return index of entry
|
* @return index of entry
|
||||||
*/
|
*/
|
||||||
public int addString(String str) {
|
public int addString(String str) {
|
||||||
@ -201,21 +211,20 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map class_table = new HashMap();
|
private Map<String, Index> class_table = new HashMap<String, Index>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look for ConstantClass in ConstantPool named `str'.
|
* Look for ConstantClass in ConstantPool named `str'.
|
||||||
*
|
*
|
||||||
* @param str String to search for
|
* @param str
|
||||||
|
* String to search for
|
||||||
* @return index on success, -1 otherwise
|
* @return index on success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
public int lookupClass(String str) {
|
public int lookupClass(String str) {
|
||||||
Index index = (Index) class_table.get(str.replace('.', '/'));
|
Index index = class_table.get(str.replace('.', '/'));
|
||||||
return (index != null) ? index.index : -1;
|
return (index != null) ? index.index : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private int addClass_(String clazz) {
|
private int addClass_(String clazz) {
|
||||||
int ret;
|
int ret;
|
||||||
if ((ret = lookupClass(clazz)) != -1) {
|
if ((ret = lookupClass(clazz)) != -1) {
|
||||||
@ -231,45 +240,46 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new Class reference to the ConstantPool, if it is not already in there.
|
* Add a new Class reference to the ConstantPool, if it is not already in
|
||||||
|
* there.
|
||||||
*
|
*
|
||||||
* @param str Class to add
|
* @param str
|
||||||
|
* Class to add
|
||||||
* @return index of entry
|
* @return index of entry
|
||||||
*/
|
*/
|
||||||
public int addClass(String str) {
|
public int addClass(String str) {
|
||||||
return addClass_(str.replace('.', '/'));
|
return addClass_(str.replace('.', '/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new Class reference to the ConstantPool for a given type.
|
* Add a new Class reference to the ConstantPool for a given type.
|
||||||
*
|
*
|
||||||
* @param type Class to add
|
* @param type
|
||||||
|
* Class to add
|
||||||
* @return index of entry
|
* @return index of entry
|
||||||
*/
|
*/
|
||||||
public int addClass(ObjectType type) {
|
public int addClass(ObjectType type) {
|
||||||
return addClass(type.getClassName());
|
return addClass(type.getClassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a reference to an array class (e.g. String[][]) as needed by MULTIANEWARRAY
|
* Add a reference to an array class (e.g. String[][]) as needed by
|
||||||
* instruction, e.g. to the ConstantPool.
|
* MULTIANEWARRAY instruction, e.g. to the ConstantPool.
|
||||||
*
|
*
|
||||||
* @param type type of array class
|
* @param type
|
||||||
|
* type of array class
|
||||||
* @return index of entry
|
* @return index of entry
|
||||||
*/
|
*/
|
||||||
public int addArrayClass(ArrayType type) {
|
public int addArrayClass(ArrayType type) {
|
||||||
return addClass_(type.getSignature());
|
return addClass_(type.getSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look for ConstantInteger in ConstantPool.
|
* Look for ConstantInteger in ConstantPool.
|
||||||
*
|
*
|
||||||
* @param n integer number to look for
|
* @param n
|
||||||
|
* integer number to look for
|
||||||
* @return index on success, -1 otherwise
|
* @return index on success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
public int lookupInteger(int n) {
|
public int lookupInteger(int n) {
|
||||||
@ -284,11 +294,12 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new Integer constant to the ConstantPool, if it is not already in there.
|
* Add a new Integer constant to the ConstantPool, if it is not already in
|
||||||
|
* there.
|
||||||
*
|
*
|
||||||
* @param n integer number to add
|
* @param n
|
||||||
|
* integer number to add
|
||||||
* @return index of entry
|
* @return index of entry
|
||||||
*/
|
*/
|
||||||
public int addInteger(int n) {
|
public int addInteger(int n) {
|
||||||
@ -302,11 +313,11 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look for ConstantFloat in ConstantPool.
|
* Look for ConstantFloat in ConstantPool.
|
||||||
*
|
*
|
||||||
* @param n Float number to look for
|
* @param n
|
||||||
|
* Float number to look for
|
||||||
* @return index on success, -1 otherwise
|
* @return index on success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
public int lookupFloat(float n) {
|
public int lookupFloat(float n) {
|
||||||
@ -322,11 +333,12 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new Float constant to the ConstantPool, if it is not already in there.
|
* Add a new Float constant to the ConstantPool, if it is not already in
|
||||||
|
* there.
|
||||||
*
|
*
|
||||||
* @param n Float number to add
|
* @param n
|
||||||
|
* Float number to add
|
||||||
* @return index of entry
|
* @return index of entry
|
||||||
*/
|
*/
|
||||||
public int addFloat(float n) {
|
public int addFloat(float n) {
|
||||||
@ -340,25 +352,26 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map utf8_table = new HashMap();
|
private Map<String, Index> utf8_table = new HashMap<String, Index>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look for ConstantUtf8 in ConstantPool.
|
* Look for ConstantUtf8 in ConstantPool.
|
||||||
*
|
*
|
||||||
* @param n Utf8 string to look for
|
* @param n
|
||||||
|
* Utf8 string to look for
|
||||||
* @return index on success, -1 otherwise
|
* @return index on success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
public int lookupUtf8(String n) {
|
public int lookupUtf8(String n) {
|
||||||
Index index = (Index) utf8_table.get(n);
|
Index index = utf8_table.get(n);
|
||||||
return (index != null) ? index.index : -1;
|
return (index != null) ? index.index : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new Utf8 constant to the ConstantPool, if it is not already in there.
|
* Add a new Utf8 constant to the ConstantPool, if it is not already in
|
||||||
|
* there.
|
||||||
*
|
*
|
||||||
* @param n Utf8 string to add
|
* @param n
|
||||||
|
* Utf8 string to add
|
||||||
* @return index of entry
|
* @return index of entry
|
||||||
*/
|
*/
|
||||||
public int addUtf8(String n) {
|
public int addUtf8(String n) {
|
||||||
@ -375,11 +388,11 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look for ConstantLong in ConstantPool.
|
* Look for ConstantLong in ConstantPool.
|
||||||
*
|
*
|
||||||
* @param n Long number to look for
|
* @param n
|
||||||
|
* Long number to look for
|
||||||
* @return index on success, -1 otherwise
|
* @return index on success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
public int lookupLong(long n) {
|
public int lookupLong(long n) {
|
||||||
@ -394,11 +407,12 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new long constant to the ConstantPool, if it is not already in there.
|
* Add a new long constant to the ConstantPool, if it is not already in
|
||||||
|
* there.
|
||||||
*
|
*
|
||||||
* @param n Long number to add
|
* @param n
|
||||||
|
* Long number to add
|
||||||
* @return index of entry
|
* @return index of entry
|
||||||
*/
|
*/
|
||||||
public int addLong(long n) {
|
public int addLong(long n) {
|
||||||
@ -413,11 +427,11 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look for ConstantDouble in ConstantPool.
|
* Look for ConstantDouble in ConstantPool.
|
||||||
*
|
*
|
||||||
* @param n Double number to look for
|
* @param n
|
||||||
|
* Double number to look for
|
||||||
* @return index on success, -1 otherwise
|
* @return index on success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
public int lookupDouble(double n) {
|
public int lookupDouble(double n) {
|
||||||
@ -433,11 +447,12 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new double constant to the ConstantPool, if it is not already in there.
|
* Add a new double constant to the ConstantPool, if it is not already in
|
||||||
|
* there.
|
||||||
*
|
*
|
||||||
* @param n Double number to add
|
* @param n
|
||||||
|
* Double number to add
|
||||||
* @return index of entry
|
* @return index of entry
|
||||||
*/
|
*/
|
||||||
public int addDouble(double n) {
|
public int addDouble(double n) {
|
||||||
@ -452,28 +467,30 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map n_a_t_table = new HashMap();
|
private Map<String, Index> n_a_t_table = new HashMap<String, Index>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look for ConstantNameAndType in ConstantPool.
|
* Look for ConstantNameAndType in ConstantPool.
|
||||||
*
|
*
|
||||||
* @param name of variable/method
|
* @param name
|
||||||
* @param signature of variable/method
|
* of variable/method
|
||||||
|
* @param signature
|
||||||
|
* of variable/method
|
||||||
* @return index on success, -1 otherwise
|
* @return index on success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
public int lookupNameAndType(String name, String signature) {
|
public int lookupNameAndType(String name, String signature) {
|
||||||
Index _index = (Index) n_a_t_table.get(name + NAT_DELIM + signature);
|
Index _index = n_a_t_table.get(name + NAT_DELIM + signature);
|
||||||
return (_index != null) ? _index.index : -1;
|
return (_index != null) ? _index.index : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new NameAndType constant to the ConstantPool if it is not already
|
* Add a new NameAndType constant to the ConstantPool if it is not already
|
||||||
* in there.
|
* in there.
|
||||||
*
|
*
|
||||||
* @param name Name string to add
|
* @param name
|
||||||
* @param signature signature string to add
|
* Name string to add
|
||||||
|
* @param signature
|
||||||
|
* signature string to add
|
||||||
* @return index of entry
|
* @return index of entry
|
||||||
*/
|
*/
|
||||||
public int addNameAndType(String name, String signature) {
|
public int addNameAndType(String name, String signature) {
|
||||||
@ -486,7 +503,8 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
name_index = addUtf8(name);
|
name_index = addUtf8(name);
|
||||||
signature_index = addUtf8(signature);
|
signature_index = addUtf8(signature);
|
||||||
ret = index;
|
ret = index;
|
||||||
constants[index++] = new ConstantNameAndType(name_index, signature_index);
|
constants[index++] = new ConstantNameAndType(name_index,
|
||||||
|
signature_index);
|
||||||
String key = name + NAT_DELIM + signature;
|
String key = name + NAT_DELIM + signature;
|
||||||
if (!n_a_t_table.containsKey(key)) {
|
if (!n_a_t_table.containsKey(key)) {
|
||||||
n_a_t_table.put(key, new Index(ret));
|
n_a_t_table.put(key, new Index(ret));
|
||||||
@ -494,39 +512,45 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map cp_table = new HashMap();
|
private Map<String, Index> cp_table = new HashMap<String, Index>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look for ConstantMethodref in ConstantPool.
|
* Look for ConstantMethodref in ConstantPool.
|
||||||
*
|
*
|
||||||
* @param class_name Where to find method
|
* @param class_name
|
||||||
* @param method_name Guess what
|
* Where to find method
|
||||||
* @param signature return and argument types
|
* @param method_name
|
||||||
|
* Guess what
|
||||||
|
* @param signature
|
||||||
|
* return and argument types
|
||||||
* @return index on success, -1 otherwise
|
* @return index on success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
public int lookupMethodref( String class_name, String method_name, String signature ) {
|
public int lookupMethodref(String class_name, String method_name,
|
||||||
Index index = (Index) cp_table.get(class_name + METHODREF_DELIM + method_name
|
String signature) {
|
||||||
|
Index index = cp_table.get(class_name + METHODREF_DELIM + method_name
|
||||||
+ METHODREF_DELIM + signature);
|
+ METHODREF_DELIM + signature);
|
||||||
return (index != null) ? index.index : -1;
|
return (index != null) ? index.index : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int lookupMethodref(MethodGen method) {
|
public int lookupMethodref(MethodGen method) {
|
||||||
return lookupMethodref(method.getClassName(), method.getName(), method.getSignature());
|
return lookupMethodref(method.getClassName(), method.getName(),
|
||||||
|
method.getSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new Methodref constant to the ConstantPool, if it is not already
|
* Add a new Methodref constant to the ConstantPool, if it is not already in
|
||||||
* in there.
|
* there.
|
||||||
*
|
*
|
||||||
* @param class_name class name string to add
|
* @param class_name
|
||||||
* @param method_name method name string to add
|
* class name string to add
|
||||||
* @param signature method signature string to add
|
* @param method_name
|
||||||
|
* method name string to add
|
||||||
|
* @param signature
|
||||||
|
* method signature string to add
|
||||||
* @return index of entry
|
* @return index of entry
|
||||||
*/
|
*/
|
||||||
public int addMethodref( String class_name, String method_name, String signature ) {
|
public int addMethodref(String class_name, String method_name,
|
||||||
|
String signature) {
|
||||||
int ret, class_index, name_and_type_index;
|
int ret, class_index, name_and_type_index;
|
||||||
if ((ret = lookupMethodref(class_name, method_name, signature)) != -1) {
|
if ((ret = lookupMethodref(class_name, method_name, signature)) != -1) {
|
||||||
return ret; // Already in CP
|
return ret; // Already in CP
|
||||||
@ -535,51 +559,58 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
name_and_type_index = addNameAndType(method_name, signature);
|
name_and_type_index = addNameAndType(method_name, signature);
|
||||||
class_index = addClass(class_name);
|
class_index = addClass(class_name);
|
||||||
ret = index;
|
ret = index;
|
||||||
constants[index++] = new ConstantMethodref(class_index, name_and_type_index);
|
constants[index++] = new ConstantMethodref(class_index,
|
||||||
String key = class_name + METHODREF_DELIM + method_name + METHODREF_DELIM + signature;
|
name_and_type_index);
|
||||||
|
String key = class_name + METHODREF_DELIM + method_name
|
||||||
|
+ METHODREF_DELIM + signature;
|
||||||
if (!cp_table.containsKey(key)) {
|
if (!cp_table.containsKey(key)) {
|
||||||
cp_table.put(key, new Index(ret));
|
cp_table.put(key, new Index(ret));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int addMethodref(MethodGen method) {
|
public int addMethodref(MethodGen method) {
|
||||||
return addMethodref(method.getClassName(), method.getName(), method.getSignature());
|
return addMethodref(method.getClassName(), method.getName(),
|
||||||
|
method.getSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look for ConstantInterfaceMethodref in ConstantPool.
|
* Look for ConstantInterfaceMethodref in ConstantPool.
|
||||||
*
|
*
|
||||||
* @param class_name Where to find method
|
* @param class_name
|
||||||
* @param method_name Guess what
|
* Where to find method
|
||||||
* @param signature return and argument types
|
* @param method_name
|
||||||
|
* Guess what
|
||||||
|
* @param signature
|
||||||
|
* return and argument types
|
||||||
* @return index on success, -1 otherwise
|
* @return index on success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
public int lookupInterfaceMethodref( String class_name, String method_name, String signature ) {
|
public int lookupInterfaceMethodref(String class_name, String method_name,
|
||||||
Index index = (Index) cp_table.get(class_name + IMETHODREF_DELIM + method_name
|
String signature) {
|
||||||
|
Index index = cp_table.get(class_name + IMETHODREF_DELIM + method_name
|
||||||
+ IMETHODREF_DELIM + signature);
|
+ IMETHODREF_DELIM + signature);
|
||||||
return (index != null) ? index.index : -1;
|
return (index != null) ? index.index : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int lookupInterfaceMethodref(MethodGen method) {
|
public int lookupInterfaceMethodref(MethodGen method) {
|
||||||
return lookupInterfaceMethodref(method.getClassName(), method.getName(), method
|
return lookupInterfaceMethodref(method.getClassName(),
|
||||||
.getSignature());
|
method.getName(), method.getSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new InterfaceMethodref constant to the ConstantPool, if it is not already
|
* Add a new InterfaceMethodref constant to the ConstantPool, if it is not
|
||||||
* in there.
|
* already in there.
|
||||||
*
|
*
|
||||||
* @param class_name class name string to add
|
* @param class_name
|
||||||
* @param method_name method name string to add
|
* class name string to add
|
||||||
* @param signature signature string to add
|
* @param method_name
|
||||||
|
* method name string to add
|
||||||
|
* @param signature
|
||||||
|
* signature string to add
|
||||||
* @return index of entry
|
* @return index of entry
|
||||||
*/
|
*/
|
||||||
public int addInterfaceMethodref( String class_name, String method_name, String signature ) {
|
public int addInterfaceMethodref(String class_name, String method_name,
|
||||||
|
String signature) {
|
||||||
int ret, class_index, name_and_type_index;
|
int ret, class_index, name_and_type_index;
|
||||||
if ((ret = lookupInterfaceMethodref(class_name, method_name, signature)) != -1) {
|
if ((ret = lookupInterfaceMethodref(class_name, method_name, signature)) != -1) {
|
||||||
return ret; // Already in CP
|
return ret; // Already in CP
|
||||||
@ -588,45 +619,53 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
class_index = addClass(class_name);
|
class_index = addClass(class_name);
|
||||||
name_and_type_index = addNameAndType(method_name, signature);
|
name_and_type_index = addNameAndType(method_name, signature);
|
||||||
ret = index;
|
ret = index;
|
||||||
constants[index++] = new ConstantInterfaceMethodref(class_index, name_and_type_index);
|
constants[index++] = new ConstantInterfaceMethodref(class_index,
|
||||||
String key = class_name + IMETHODREF_DELIM + method_name + IMETHODREF_DELIM + signature;
|
name_and_type_index);
|
||||||
|
String key = class_name + IMETHODREF_DELIM + method_name
|
||||||
|
+ IMETHODREF_DELIM + signature;
|
||||||
if (!cp_table.containsKey(key)) {
|
if (!cp_table.containsKey(key)) {
|
||||||
cp_table.put(key, new Index(ret));
|
cp_table.put(key, new Index(ret));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int addInterfaceMethodref(MethodGen method) {
|
public int addInterfaceMethodref(MethodGen method) {
|
||||||
return addInterfaceMethodref(method.getClassName(), method.getName(), method.getSignature());
|
return addInterfaceMethodref(method.getClassName(), method.getName(),
|
||||||
|
method.getSignature());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look for ConstantFieldref in ConstantPool.
|
* Look for ConstantFieldref in ConstantPool.
|
||||||
*
|
*
|
||||||
* @param class_name Where to find method
|
* @param class_name
|
||||||
* @param field_name Guess what
|
* Where to find method
|
||||||
* @param signature return and argument types
|
* @param field_name
|
||||||
|
* Guess what
|
||||||
|
* @param signature
|
||||||
|
* return and argument types
|
||||||
* @return index on success, -1 otherwise
|
* @return index on success, -1 otherwise
|
||||||
*/
|
*/
|
||||||
public int lookupFieldref( String class_name, String field_name, String signature ) {
|
public int lookupFieldref(String class_name, String field_name,
|
||||||
Index index = (Index) cp_table.get(class_name + FIELDREF_DELIM + field_name
|
String signature) {
|
||||||
|
Index index = cp_table.get(class_name + FIELDREF_DELIM + field_name
|
||||||
+ FIELDREF_DELIM + signature);
|
+ FIELDREF_DELIM + signature);
|
||||||
return (index != null) ? index.index : -1;
|
return (index != null) ? index.index : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new Fieldref constant to the ConstantPool, if it is not already
|
* Add a new Fieldref constant to the ConstantPool, if it is not already in
|
||||||
* in there.
|
* there.
|
||||||
*
|
*
|
||||||
* @param class_name class name string to add
|
* @param class_name
|
||||||
* @param field_name field name string to add
|
* class name string to add
|
||||||
* @param signature signature string to add
|
* @param field_name
|
||||||
|
* field name string to add
|
||||||
|
* @param signature
|
||||||
|
* signature string to add
|
||||||
* @return index of entry
|
* @return index of entry
|
||||||
*/
|
*/
|
||||||
public int addFieldref( String class_name, String field_name, String signature ) {
|
public int addFieldref(String class_name, String field_name,
|
||||||
|
String signature) {
|
||||||
int ret;
|
int ret;
|
||||||
int class_index, name_and_type_index;
|
int class_index, name_and_type_index;
|
||||||
if ((ret = lookupFieldref(class_name, field_name, signature)) != -1) {
|
if ((ret = lookupFieldref(class_name, field_name, signature)) != -1) {
|
||||||
@ -636,35 +675,37 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
class_index = addClass(class_name);
|
class_index = addClass(class_name);
|
||||||
name_and_type_index = addNameAndType(field_name, signature);
|
name_and_type_index = addNameAndType(field_name, signature);
|
||||||
ret = index;
|
ret = index;
|
||||||
constants[index++] = new ConstantFieldref(class_index, name_and_type_index);
|
constants[index++] = new ConstantFieldref(class_index,
|
||||||
String key = class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM + signature;
|
name_and_type_index);
|
||||||
|
String key = class_name + FIELDREF_DELIM + field_name + FIELDREF_DELIM
|
||||||
|
+ signature;
|
||||||
if (!cp_table.containsKey(key)) {
|
if (!cp_table.containsKey(key)) {
|
||||||
cp_table.put(key, new Index(ret));
|
cp_table.put(key, new Index(ret));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param i index in constant pool
|
* @param i
|
||||||
|
* index in constant pool
|
||||||
* @return constant pool entry at index i
|
* @return constant pool entry at index i
|
||||||
*/
|
*/
|
||||||
public Constant getConstant(int i) {
|
public Constant getConstant(int i) {
|
||||||
return constants[i];
|
return constants[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use with care!
|
* Use with care!
|
||||||
*
|
*
|
||||||
* @param i index in constant pool
|
* @param i
|
||||||
* @param c new constant pool entry at index i
|
* index in constant pool
|
||||||
|
* @param c
|
||||||
|
* new constant pool entry at index i
|
||||||
*/
|
*/
|
||||||
public void setConstant(int i, Constant c) {
|
public void setConstant(int i, Constant c) {
|
||||||
constants[i] = c;
|
constants[i] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return intermediate constant pool
|
* @return intermediate constant pool
|
||||||
*/
|
*/
|
||||||
@ -672,7 +713,6 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return new ConstantPool(constants);
|
return new ConstantPool(constants);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return current size of constant pool
|
* @return current size of constant pool
|
||||||
*/
|
*/
|
||||||
@ -680,7 +720,6 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return constant pool with proper length
|
* @return constant pool with proper length
|
||||||
*/
|
*/
|
||||||
@ -690,10 +729,10 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return new ConstantPool(cs);
|
return new ConstantPool(cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String representation.
|
* @return String representation.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
for (int i = 1; i < index; i++) {
|
for (int i = 1; i < index; i++) {
|
||||||
@ -702,8 +741,8 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Import constant from another ConstantPool and return new index.
|
* Import constant from another ConstantPool and return new index.
|
||||||
*/
|
*/
|
||||||
public int addConstant(Constant c, ConstantPoolGen cp) {
|
public int addConstant(Constant c, ConstantPoolGen cp) {
|
||||||
Constant[] constants = cp.getConstantPool().getConstantPool();
|
Constant[] constants = cp.getConstantPool().getConstantPool();
|
||||||
@ -739,7 +778,8 @@ public class ConstantPoolGen implements java.io.Serializable {
|
|||||||
case Constants.CONSTANT_Fieldref: {
|
case Constants.CONSTANT_Fieldref: {
|
||||||
ConstantCP m = (ConstantCP) c;
|
ConstantCP m = (ConstantCP) c;
|
||||||
ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()];
|
ConstantClass clazz = (ConstantClass) constants[m.getClassIndex()];
|
||||||
ConstantNameAndType n = (ConstantNameAndType) constants[m.getNameAndTypeIndex()];
|
ConstantNameAndType n = (ConstantNameAndType) constants[m
|
||||||
|
.getNameAndTypeIndex()];
|
||||||
ConstantUtf8 u8 = (ConstantUtf8) constants[clazz.getNameIndex()];
|
ConstantUtf8 u8 = (ConstantUtf8) constants[clazz.getNameIndex()];
|
||||||
String class_name = u8.getBytes().replace('/', '.');
|
String class_name = u8.getBytes().replace('/', '.');
|
||||||
u8 = (ConstantUtf8) constants[n.getNameIndex()];
|
u8 = (ConstantUtf8) constants[n.getNameIndex()];
|
||||||
|
@ -17,16 +17,18 @@
|
|||||||
package org.apache.bcel.generic;
|
package org.apache.bcel.generic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Denotes a push instruction that produces a literal on the stack
|
* Denotes a push instruction that produces a literal on the stack such as
|
||||||
* such as SIPUSH, BIPUSH, ICONST, etc.
|
* SIPUSH, BIPUSH, ICONST, etc.
|
||||||
*
|
*
|
||||||
* @version $Id: ConstantPushInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConstantPushInstruction.java 386056 2006-03-15 11:31:56Z tcurdt
|
||||||
|
* $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
|
*
|
||||||
* @see ICONST
|
* @see ICONST
|
||||||
* @see SIPUSH
|
* @see SIPUSH
|
||||||
*/
|
*/
|
||||||
public interface ConstantPushInstruction extends PushInstruction, TypedInstruction {
|
public interface ConstantPushInstruction extends PushInstruction,
|
||||||
|
TypedInstruction {
|
||||||
|
|
||||||
public Number getValue();
|
public Number getValue();
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,13 @@ import org.apache.bcel.Constants;
|
|||||||
* @version $Id: ConversionInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: ConversionInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public abstract class ConversionInstruction extends Instruction implements TypedInstruction,
|
public abstract class ConversionInstruction extends Instruction implements
|
||||||
StackProducer, StackConsumer {
|
TypedInstruction, StackProducer, StackConsumer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor needed for the Class.newInstance() statement in
|
* Empty constructor needed for the Class.newInstance() statement in
|
||||||
@ -34,17 +39,18 @@ public abstract class ConversionInstruction extends Instruction implements Typed
|
|||||||
ConversionInstruction() {
|
ConversionInstruction() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param opcode opcode of instruction
|
* @param opcode
|
||||||
|
* opcode of instruction
|
||||||
*/
|
*/
|
||||||
protected ConversionInstruction(short opcode) {
|
protected ConversionInstruction(short opcode) {
|
||||||
super(opcode, (short) 1);
|
super(opcode, (short) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return type associated with the instruction
|
* @return type associated with the instruction
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Type getType(ConstantPoolGen cp) {
|
public Type getType(ConstantPoolGen cp) {
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case Constants.D2I:
|
case Constants.D2I:
|
||||||
|
@ -18,28 +18,38 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* D2F - Convert double to float
|
* D2F - Convert double to float
|
||||||
* <PRE>Stack: ..., value.word1, value.word2 -> ..., result</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., value.word1, value.word2 -> ..., result
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: D2F.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: D2F.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class D2F extends ConversionInstruction {
|
public class D2F extends ConversionInstruction {
|
||||||
|
|
||||||
/** Convert double to float
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert double to float
|
||||||
*/
|
*/
|
||||||
public D2F() {
|
public D2F() {
|
||||||
super(org.apache.bcel.Constants.D2F);
|
super(org.apache.bcel.Constants.D2F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitTypedInstruction(this);
|
v.visitTypedInstruction(this);
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
|
@ -18,28 +18,38 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* D2I - Convert double to int
|
* D2I - Convert double to int
|
||||||
* <PRE>Stack: ..., value.word1, value.word2 -> ..., result</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., value.word1, value.word2 -> ..., result
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: D2I.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: D2I.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class D2I extends ConversionInstruction {
|
public class D2I extends ConversionInstruction {
|
||||||
|
|
||||||
/** Convert double to int
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert double to int
|
||||||
*/
|
*/
|
||||||
public D2I() {
|
public D2I() {
|
||||||
super(org.apache.bcel.Constants.D2I);
|
super(org.apache.bcel.Constants.D2I);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitTypedInstruction(this);
|
v.visitTypedInstruction(this);
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
|
@ -18,28 +18,38 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* D2L - Convert double to long
|
* D2L - Convert double to long
|
||||||
* <PRE>Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: D2L.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: D2L.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class D2L extends ConversionInstruction {
|
public class D2L extends ConversionInstruction {
|
||||||
|
|
||||||
/** Convert double to long
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert double to long
|
||||||
*/
|
*/
|
||||||
public D2L() {
|
public D2L() {
|
||||||
super(org.apache.bcel.Constants.D2L);
|
super(org.apache.bcel.Constants.D2L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitTypedInstruction(this);
|
v.visitTypedInstruction(this);
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
|
@ -18,7 +18,11 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DADD - Add doubles
|
* DADD - Add doubles
|
||||||
* <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
|
||||||
|
* </PRE>
|
||||||
|
*
|
||||||
* ..., result.word1, result1.word2
|
* ..., result.word1, result1.word2
|
||||||
*
|
*
|
||||||
* @version $Id: DADD.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DADD.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
@ -26,21 +30,28 @@ package org.apache.bcel.generic;
|
|||||||
*/
|
*/
|
||||||
public class DADD extends ArithmeticInstruction {
|
public class DADD extends ArithmeticInstruction {
|
||||||
|
|
||||||
/** Add doubles
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add doubles
|
||||||
*/
|
*/
|
||||||
public DADD() {
|
public DADD() {
|
||||||
super(org.apache.bcel.Constants.DADD);
|
super(org.apache.bcel.Constants.DADD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitTypedInstruction(this);
|
v.visitTypedInstruction(this);
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
|
@ -18,28 +18,38 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DALOAD - Load double from array
|
* DALOAD - Load double from array
|
||||||
* <PRE>Stack: ..., arrayref, index -> ..., result.word1, result.word2</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., arrayref, index -> ..., result.word1, result.word2
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: DALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DALOAD.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class DALOAD extends ArrayInstruction implements StackProducer {
|
public class DALOAD extends ArrayInstruction implements StackProducer {
|
||||||
|
|
||||||
/** Load double from array
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load double from array
|
||||||
*/
|
*/
|
||||||
public DALOAD() {
|
public DALOAD() {
|
||||||
super(org.apache.bcel.Constants.DALOAD);
|
super(org.apache.bcel.Constants.DALOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
v.visitExceptionThrower(this);
|
v.visitExceptionThrower(this);
|
||||||
|
@ -18,28 +18,38 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DASTORE - Store into double array
|
* DASTORE - Store into double array
|
||||||
* <PRE>Stack: ..., arrayref, index, value.word1, value.word2 -> ...</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., arrayref, index, value.word1, value.word2 -> ...
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: DASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DASTORE.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class DASTORE extends ArrayInstruction implements StackConsumer {
|
public class DASTORE extends ArrayInstruction implements StackConsumer {
|
||||||
|
|
||||||
/** Store double into array
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store double into array
|
||||||
*/
|
*/
|
||||||
public DASTORE() {
|
public DASTORE() {
|
||||||
super(org.apache.bcel.Constants.DASTORE);
|
super(org.apache.bcel.Constants.DASTORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitStackConsumer(this);
|
v.visitStackConsumer(this);
|
||||||
v.visitExceptionThrower(this);
|
v.visitExceptionThrower(this);
|
||||||
|
@ -18,34 +18,46 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DCMPG - Compare doubles: value1 > value2
|
* DCMPG - Compare doubles: value1 > value2
|
||||||
* <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
|
||||||
|
* </PRE>
|
||||||
|
*
|
||||||
* ..., result
|
* ..., result
|
||||||
*
|
*
|
||||||
* @version $Id: DCMPG.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DCMPG.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class DCMPG extends Instruction implements TypedInstruction, StackProducer, StackConsumer {
|
public class DCMPG extends Instruction implements TypedInstruction,
|
||||||
|
StackProducer, StackConsumer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public DCMPG() {
|
public DCMPG() {
|
||||||
super(org.apache.bcel.Constants.DCMPG, (short) 1);
|
super(org.apache.bcel.Constants.DCMPG, (short) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return Type.DOUBLE
|
* @return Type.DOUBLE
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Type getType(ConstantPoolGen cp) {
|
public Type getType(ConstantPoolGen cp) {
|
||||||
return Type.DOUBLE;
|
return Type.DOUBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitTypedInstruction(this);
|
v.visitTypedInstruction(this);
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
|
@ -18,34 +18,46 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DCMPL - Compare doubles: value1 < value2
|
* DCMPL - Compare doubles: value1 < value2
|
||||||
* <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
|
||||||
|
* </PRE>
|
||||||
|
*
|
||||||
* ..., result
|
* ..., result
|
||||||
*
|
*
|
||||||
* @version $Id: DCMPL.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DCMPL.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class DCMPL extends Instruction implements TypedInstruction, StackProducer, StackConsumer {
|
public class DCMPL extends Instruction implements TypedInstruction,
|
||||||
|
StackProducer, StackConsumer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public DCMPL() {
|
public DCMPL() {
|
||||||
super(org.apache.bcel.Constants.DCMPL, (short) 1);
|
super(org.apache.bcel.Constants.DCMPL, (short) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return Type.DOUBLE
|
* @return Type.DOUBLE
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Type getType(ConstantPoolGen cp) {
|
public Type getType(ConstantPoolGen cp) {
|
||||||
return Type.DOUBLE;
|
return Type.DOUBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitTypedInstruction(this);
|
v.visitTypedInstruction(this);
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
|
@ -19,16 +19,22 @@ package org.apache.bcel.generic;
|
|||||||
/**
|
/**
|
||||||
* DCONST - Push 0.0 or 1.0, other values cause an exception
|
* DCONST - Push 0.0 or 1.0, other values cause an exception
|
||||||
*
|
*
|
||||||
* <PRE>Stack: ... -> ..., </PRE>
|
* <PRE>
|
||||||
|
* Stack: ... -> ...,
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: DCONST.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DCONST.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class DCONST extends Instruction implements ConstantPushInstruction, TypedInstruction {
|
public class DCONST extends Instruction implements ConstantPushInstruction,
|
||||||
|
TypedInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
private double value;
|
private double value;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor needed for the Class.newInstance() statement in
|
* Empty constructor needed for the Class.newInstance() statement in
|
||||||
* Instruction.readInstruction(). Not to be used otherwise.
|
* Instruction.readInstruction(). Not to be used otherwise.
|
||||||
@ -36,7 +42,6 @@ public class DCONST extends Instruction implements ConstantPushInstruction, Type
|
|||||||
DCONST() {
|
DCONST() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DCONST(double f) {
|
public DCONST(double f) {
|
||||||
super(org.apache.bcel.Constants.DCONST_0, (short) 1);
|
super(org.apache.bcel.Constants.DCONST_0, (short) 1);
|
||||||
if (f == 0.0) {
|
if (f == 0.0) {
|
||||||
@ -44,32 +49,35 @@ public class DCONST extends Instruction implements ConstantPushInstruction, Type
|
|||||||
} else if (f == 1.0) {
|
} else if (f == 1.0) {
|
||||||
opcode = org.apache.bcel.Constants.DCONST_1;
|
opcode = org.apache.bcel.Constants.DCONST_1;
|
||||||
} else {
|
} else {
|
||||||
throw new ClassGenException("DCONST can be used only for 0.0 and 1.0: " + f);
|
throw new ClassGenException(
|
||||||
|
"DCONST can be used only for 0.0 and 1.0: " + f);
|
||||||
}
|
}
|
||||||
value = f;
|
value = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Number getValue() {
|
public Number getValue() {
|
||||||
return new Double(value);
|
return new Double(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** @return Type.DOUBLE
|
* @return Type.DOUBLE
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Type getType(ConstantPoolGen cp) {
|
public Type getType(ConstantPoolGen cp) {
|
||||||
return Type.DOUBLE;
|
return Type.DOUBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitPushInstruction(this);
|
v.visitPushInstruction(this);
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
|
@ -18,7 +18,11 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DDIV - Divide doubles
|
* DDIV - Divide doubles
|
||||||
* <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
|
||||||
|
* </PRE>
|
||||||
|
*
|
||||||
* ..., result.word1, result.word2
|
* ..., result.word1, result.word2
|
||||||
*
|
*
|
||||||
* @version $Id: DDIV.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DDIV.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
@ -26,21 +30,28 @@ package org.apache.bcel.generic;
|
|||||||
*/
|
*/
|
||||||
public class DDIV extends ArithmeticInstruction {
|
public class DDIV extends ArithmeticInstruction {
|
||||||
|
|
||||||
/** Divide doubles
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Divide doubles
|
||||||
*/
|
*/
|
||||||
public DDIV() {
|
public DDIV() {
|
||||||
super(org.apache.bcel.Constants.DDIV);
|
super(org.apache.bcel.Constants.DDIV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitTypedInstruction(this);
|
v.visitTypedInstruction(this);
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
|
@ -18,38 +18,51 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DLOAD - Load double from local variable
|
* DLOAD - Load double from local variable
|
||||||
* <PRE>Stack ... -> ..., result.word1, result.word2</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack ... -> ..., result.word1, result.word2
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: DLOAD.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DLOAD.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class DLOAD extends LoadInstruction {
|
public class DLOAD extends LoadInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor needed for the Class.newInstance() statement in
|
* Empty constructor needed for the Class.newInstance() statement in
|
||||||
* Instruction.readInstruction(). Not to be used otherwise.
|
* Instruction.readInstruction(). Not to be used otherwise.
|
||||||
*/
|
*/
|
||||||
DLOAD() {
|
DLOAD() {
|
||||||
super(org.apache.bcel.Constants.DLOAD, org.apache.bcel.Constants.DLOAD_0);
|
super(org.apache.bcel.Constants.DLOAD,
|
||||||
|
org.apache.bcel.Constants.DLOAD_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Load double from local variable
|
|
||||||
* @param n index of local variable
|
|
||||||
*/
|
|
||||||
public DLOAD(int n) {
|
|
||||||
super(org.apache.bcel.Constants.DLOAD, org.apache.bcel.Constants.DLOAD_0, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Load double from local variable
|
||||||
* Call visitor methods of implemented interfaces first, then
|
|
||||||
* call methods according to the class hierarchy in descending order,
|
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param n
|
||||||
|
* index of local variable
|
||||||
*/
|
*/
|
||||||
|
public DLOAD(int n) {
|
||||||
|
super(org.apache.bcel.Constants.DLOAD,
|
||||||
|
org.apache.bcel.Constants.DLOAD_0, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
|
* of implemented interfaces first, then call methods according to the class
|
||||||
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
|
* comes last.
|
||||||
|
*
|
||||||
|
* @param v
|
||||||
|
* Visitor object
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
super.accept(v);
|
super.accept(v);
|
||||||
v.visitDLOAD(this);
|
v.visitDLOAD(this);
|
||||||
|
@ -18,7 +18,11 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DMUL - Multiply doubles
|
* DMUL - Multiply doubles
|
||||||
* <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
|
||||||
|
* </PRE>
|
||||||
|
*
|
||||||
* ..., result.word1, result.word2
|
* ..., result.word1, result.word2
|
||||||
*
|
*
|
||||||
* @version $Id: DMUL.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DMUL.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
@ -26,21 +30,28 @@ package org.apache.bcel.generic;
|
|||||||
*/
|
*/
|
||||||
public class DMUL extends ArithmeticInstruction {
|
public class DMUL extends ArithmeticInstruction {
|
||||||
|
|
||||||
/** Multiply doubles
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiply doubles
|
||||||
*/
|
*/
|
||||||
public DMUL() {
|
public DMUL() {
|
||||||
super(org.apache.bcel.Constants.DMUL);
|
super(org.apache.bcel.Constants.DMUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitTypedInstruction(this);
|
v.visitTypedInstruction(this);
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
|
@ -18,26 +18,35 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DNEG - Negate double
|
* DNEG - Negate double
|
||||||
* <PRE>Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., value.word1, value.word2 -> ..., result.word1, result.word2
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: DNEG.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DNEG.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class DNEG extends ArithmeticInstruction {
|
public class DNEG extends ArithmeticInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public DNEG() {
|
public DNEG() {
|
||||||
super(org.apache.bcel.Constants.DNEG);
|
super(org.apache.bcel.Constants.DNEG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitTypedInstruction(this);
|
v.visitTypedInstruction(this);
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
|
@ -18,7 +18,11 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DREM - Remainder of doubles
|
* DREM - Remainder of doubles
|
||||||
* <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
|
||||||
|
* </PRE>
|
||||||
|
*
|
||||||
* ..., result.word1, result.word2
|
* ..., result.word1, result.word2
|
||||||
*
|
*
|
||||||
* @version $Id: DREM.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DREM.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
@ -26,21 +30,28 @@ package org.apache.bcel.generic;
|
|||||||
*/
|
*/
|
||||||
public class DREM extends ArithmeticInstruction {
|
public class DREM extends ArithmeticInstruction {
|
||||||
|
|
||||||
/** Remainder of doubles
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remainder of doubles
|
||||||
*/
|
*/
|
||||||
public DREM() {
|
public DREM() {
|
||||||
super(org.apache.bcel.Constants.DREM);
|
super(org.apache.bcel.Constants.DREM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitTypedInstruction(this);
|
v.visitTypedInstruction(this);
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
|
@ -18,28 +18,38 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DRETURN - Return double from method
|
* DRETURN - Return double from method
|
||||||
* <PRE>Stack: ..., value.word1, value.word2 -> <empty></PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., value.word1, value.word2 -> <empty>
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: DRETURN.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DRETURN.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class DRETURN extends ReturnInstruction {
|
public class DRETURN extends ReturnInstruction {
|
||||||
|
|
||||||
/** Return double from method
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return double from method
|
||||||
*/
|
*/
|
||||||
public DRETURN() {
|
public DRETURN() {
|
||||||
super(org.apache.bcel.Constants.DRETURN);
|
super(org.apache.bcel.Constants.DRETURN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitExceptionThrower(this);
|
v.visitExceptionThrower(this);
|
||||||
v.visitTypedInstruction(this);
|
v.visitTypedInstruction(this);
|
||||||
|
@ -18,38 +18,51 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DSTORE - Store double into local variable
|
* DSTORE - Store double into local variable
|
||||||
* <pre>Stack: ..., value.word1, value.word2 -> ... </PRE>
|
*
|
||||||
|
* <pre>
|
||||||
|
* Stack: ..., value.word1, value.word2 -> ...
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: DSTORE.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DSTORE.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class DSTORE extends StoreInstruction {
|
public class DSTORE extends StoreInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty constructor needed for the Class.newInstance() statement in
|
* Empty constructor needed for the Class.newInstance() statement in
|
||||||
* Instruction.readInstruction(). Not to be used otherwise.
|
* Instruction.readInstruction(). Not to be used otherwise.
|
||||||
*/
|
*/
|
||||||
DSTORE() {
|
DSTORE() {
|
||||||
super(org.apache.bcel.Constants.DSTORE, org.apache.bcel.Constants.DSTORE_0);
|
super(org.apache.bcel.Constants.DSTORE,
|
||||||
|
org.apache.bcel.Constants.DSTORE_0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Store double into local variable
|
|
||||||
* @param n index of local variable
|
|
||||||
*/
|
|
||||||
public DSTORE(int n) {
|
|
||||||
super(org.apache.bcel.Constants.DSTORE, org.apache.bcel.Constants.DSTORE_0, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Store double into local variable
|
||||||
* Call visitor methods of implemented interfaces first, then
|
|
||||||
* call methods according to the class hierarchy in descending order,
|
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param n
|
||||||
|
* index of local variable
|
||||||
*/
|
*/
|
||||||
|
public DSTORE(int n) {
|
||||||
|
super(org.apache.bcel.Constants.DSTORE,
|
||||||
|
org.apache.bcel.Constants.DSTORE_0, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
|
* of implemented interfaces first, then call methods according to the class
|
||||||
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
|
* comes last.
|
||||||
|
*
|
||||||
|
* @param v
|
||||||
|
* Visitor object
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
super.accept(v);
|
super.accept(v);
|
||||||
v.visitDSTORE(this);
|
v.visitDSTORE(this);
|
||||||
|
@ -18,7 +18,11 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DSUB - Substract doubles
|
* DSUB - Substract doubles
|
||||||
* <PRE>Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 -></PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., value1.word1, value1.word2, value2.word1, value2.word2 ->
|
||||||
|
* </PRE>
|
||||||
|
*
|
||||||
* ..., result.word1, result.word2
|
* ..., result.word1, result.word2
|
||||||
*
|
*
|
||||||
* @version $Id: DSUB.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DSUB.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
@ -26,21 +30,28 @@ package org.apache.bcel.generic;
|
|||||||
*/
|
*/
|
||||||
public class DSUB extends ArithmeticInstruction {
|
public class DSUB extends ArithmeticInstruction {
|
||||||
|
|
||||||
/** Substract doubles
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Substract doubles
|
||||||
*/
|
*/
|
||||||
public DSUB() {
|
public DSUB() {
|
||||||
super(org.apache.bcel.Constants.DSUB);
|
super(org.apache.bcel.Constants.DSUB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitTypedInstruction(this);
|
v.visitTypedInstruction(this);
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
|
@ -18,26 +18,35 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DUP - Duplicate top operand stack word
|
* DUP - Duplicate top operand stack word
|
||||||
* <PRE>Stack: ..., word -> ..., word, word</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., word -> ..., word, word
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: DUP.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DUP.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class DUP extends StackInstruction implements PushInstruction {
|
public class DUP extends StackInstruction implements PushInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public DUP() {
|
public DUP() {
|
||||||
super(org.apache.bcel.Constants.DUP);
|
super(org.apache.bcel.Constants.DUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
v.visitPushInstruction(this);
|
v.visitPushInstruction(this);
|
||||||
|
@ -18,26 +18,35 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DUP2 - Duplicate two top operand stack words
|
* DUP2 - Duplicate two top operand stack words
|
||||||
* <PRE>Stack: ..., word2, word1 -> ..., word2, word1, word2, word1</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., word2, word1 -> ..., word2, word1, word2, word1
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: DUP2.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DUP2.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class DUP2 extends StackInstruction implements PushInstruction {
|
public class DUP2 extends StackInstruction implements PushInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public DUP2() {
|
public DUP2() {
|
||||||
super(org.apache.bcel.Constants.DUP2);
|
super(org.apache.bcel.Constants.DUP2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitStackProducer(this);
|
v.visitStackProducer(this);
|
||||||
v.visitPushInstruction(this);
|
v.visitPushInstruction(this);
|
||||||
|
@ -18,26 +18,35 @@ package org.apache.bcel.generic;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* DUP2_X1 - Duplicate two top operand stack words and put three down
|
* DUP2_X1 - Duplicate two top operand stack words and put three down
|
||||||
* <PRE>Stack: ..., word3, word2, word1 -> ..., word2, word1, word3, word2, word1</PRE>
|
*
|
||||||
|
* <PRE>
|
||||||
|
* Stack: ..., word3, word2, word1 -> ..., word2, word1, word3, word2, word1
|
||||||
|
* </PRE>
|
||||||
*
|
*
|
||||||
* @version $Id: DUP2_X1.java 386056 2006-03-15 11:31:56Z tcurdt $
|
* @version $Id: DUP2_X1.java 386056 2006-03-15 11:31:56Z tcurdt $
|
||||||
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
* @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
|
||||||
*/
|
*/
|
||||||
public class DUP2_X1 extends StackInstruction {
|
public class DUP2_X1 extends StackInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public DUP2_X1() {
|
public DUP2_X1() {
|
||||||
super(org.apache.bcel.Constants.DUP2_X1);
|
super(org.apache.bcel.Constants.DUP2_X1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call corresponding visitor method(s). The order is:
|
* Call corresponding visitor method(s). The order is: Call visitor methods
|
||||||
* Call visitor methods of implemented interfaces first, then
|
* of implemented interfaces first, then call methods according to the class
|
||||||
* call methods according to the class hierarchy in descending order,
|
* hierarchy in descending order, i.e., the most specific visitXXX() call
|
||||||
* i.e., the most specific visitXXX() call comes last.
|
* comes last.
|
||||||
*
|
*
|
||||||
* @param v Visitor object
|
* @param v
|
||||||
|
* Visitor object
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void accept(Visitor v) {
|
public void accept(Visitor v) {
|
||||||
v.visitStackInstruction(this);
|
v.visitStackInstruction(this);
|
||||||
v.visitDUP2_X1(this);
|
v.visitDUP2_X1(this);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user