|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.easybeans.enhancer.CommonClassGenerator
public abstract class CommonClassGenerator
Class with useful routines for writing a class.
Field Summary | |
---|---|
static java.lang.String |
ARRAY_OBJECTS
Define an array of objects. |
private org.objectweb.asm.ClassWriter |
cw
The ClassWriter to which this adapter delegates
calls. |
static java.lang.String |
EASYBEANS_FACTORY
Factory class (used to make the bean factory available). |
private org.objectweb.asm.FieldVisitor |
fv
Field visitor. |
static int |
GENERATED_CLASS_VERSION
Version used for generated class. |
static java.lang.String |
JAVA_LANG_EXCEPTION
Defines java.lang.Exception class. |
static java.lang.String |
JAVA_LANG_OBJECT
Defines java.lang.Object class. |
static java.lang.String |
JAVA_LANG_REFLECT_METHOD
Define java.lang.reflect.Method. |
static java.lang.String |
VOID_METHOD_JAVA_LANG_OBJECT
Defines a void method with JAVA_LANG_OBJECT as parameter. |
Fields inherited from interface org.objectweb.asm.Opcodes |
---|
AALOAD, AASTORE, ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_DEPRECATED, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VARARGS, ACC_VOLATILE, ACONST_NULL, ALOAD, ANEWARRAY, ARETURN, ARRAYLENGTH, ASTORE, ATHROW, BALOAD, BASTORE, BIPUSH, CALOAD, CASTORE, CHECKCAST, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DLOAD, DMUL, DNEG, DREM, DRETURN, DSTORE, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, FMUL, FNEG, FREM, FRETURN, FSTORE, FSUB, GETFIELD, GETSTATIC, GOTO, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, IF_ACMPEQ, IF_ACMPNE, IF_ICMPEQ, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ICMPLT, IF_ICMPNE, IFEQ, IFGE, IFGT, IFLE, IFLT, IFNE, IFNONNULL, IFNULL, IINC, ILOAD, IMUL, INEG, INSTANCEOF, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE, ISUB, IUSHR, IXOR, JSR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDC, LDIV, LLOAD, LMUL, LNEG, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, POP, POP2, PUTFIELD, PUTSTATIC, RET, RETURN, SALOAD, SASTORE, SIPUSH, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6 |
Constructor Summary | |
---|---|
CommonClassGenerator(org.objectweb.asm.ClassWriter cw)
Creates a default class with useful routines for writing a class. |
Method Summary | |
---|---|
protected void |
addAttribute(int access,
java.lang.String name,
java.lang.String desc)
Adds an attribute in the current classwriter. |
protected void |
addAttribute(int access,
java.lang.String name,
java.lang.String desc,
java.lang.Object value)
Adds an attribute in the current classwriter. |
static void |
addReturnType(org.objectweb.asm.Type type,
org.objectweb.asm.MethodVisitor mv)
Adds a return entry depending of the type value. |
static java.lang.String |
encodeArrayClassDesc(java.lang.String className)
Encodes an internal classname into an array descriptor. |
static java.lang.String |
encodeClassDesc(java.lang.String className)
Encodes an internal classname into a descriptor. |
org.objectweb.asm.ClassWriter |
getCW()
|
static int |
putFieldLoadOpCode(int sortCode)
Sends the OpCode used in an constructor to set the field. |
static void |
returnsObject(org.objectweb.asm.Type returnType,
org.objectweb.asm.MethodVisitor mv)
Returns the object by casting it or return null if method is of void type. |
static void |
transformObjectIntoPrimitive(org.objectweb.asm.Type type,
org.objectweb.asm.MethodVisitor mv)
If a type is one of the object type with something which could be linked to a primitive type, cast object into primitive. |
static void |
transformPrimitiveIntoObject(org.objectweb.asm.Type type,
org.objectweb.asm.MethodVisitor mv)
If a type is one of the primitive object : boolean, int, long, etc, adds an instruction to transform type into an object. |
static void |
visitClassType(org.objectweb.asm.Type type,
org.objectweb.asm.MethodVisitor mv)
Allow to access to a class. ie, for int.class it will access to Integer.TYPE. For objects, it only calls the Object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ARRAY_OBJECTS
public static final java.lang.String JAVA_LANG_OBJECT
public static final java.lang.String VOID_METHOD_JAVA_LANG_OBJECT
public static final java.lang.String JAVA_LANG_EXCEPTION
public static final java.lang.String JAVA_LANG_REFLECT_METHOD
public static final java.lang.String EASYBEANS_FACTORY
public static final int GENERATED_CLASS_VERSION
private org.objectweb.asm.ClassWriter cw
ClassWriter
to which this adapter delegates
calls.
private org.objectweb.asm.FieldVisitor fv
Constructor Detail |
---|
public CommonClassGenerator(org.objectweb.asm.ClassWriter cw)
cw
- the class writer which will generate the classMethod Detail |
---|
protected void addAttribute(int access, java.lang.String name, java.lang.String desc)
access
- the field's access flags (see Opcodes
). This
parameter also indicates if the field is synthetic and/or
deprecated.name
- the field's name.desc
- the field's descriptor (see Type
).protected void addAttribute(int access, java.lang.String name, java.lang.String desc, java.lang.Object value)
access
- the field's access flags (see Opcodes
). This
parameter also indicates if the field is synthetic and/or
deprecated.name
- the field's name.desc
- the field's descriptor (see Type
).value
- the field's initial value. This parameter, which may be
null if the field does not have an initial value, must
be an Integer
, a Float
, a Long
, a
Double
or a String
(for int,
float, long or String fields
respectively). This parameter is only used for static fields.
Its value is ignored for non static fields, which must be
initialized through bytecode instructions in constructors or
methods.public static java.lang.String encodeClassDesc(java.lang.String className)
className
- internal class name
public static java.lang.String encodeArrayClassDesc(java.lang.String className)
className
- internal class name
public org.objectweb.asm.ClassWriter getCW()
public static int putFieldLoadOpCode(int sortCode)
sortCode
- type of attribute to set
public static void transformPrimitiveIntoObject(org.objectweb.asm.Type type, org.objectweb.asm.MethodVisitor mv)
type
- the object that need to be processedmv
- the method visitor on which there is a need to adds an instructionpublic static void transformObjectIntoPrimitive(org.objectweb.asm.Type type, org.objectweb.asm.MethodVisitor mv)
type
- the object that need to be processedmv
- the method visitor on which there is a need to adds an instructionpublic static void addReturnType(org.objectweb.asm.Type type, org.objectweb.asm.MethodVisitor mv)
type
- the object that need to be processedmv
- the method visitor on which there is a need to adds an instructionpublic static void visitClassType(org.objectweb.asm.Type type, org.objectweb.asm.MethodVisitor mv)
type
- the type of the object from which we want the classmv
- object on which we add the instructionpublic static void returnsObject(org.objectweb.asm.Type returnType, org.objectweb.asm.MethodVisitor mv)
returnType
- the kind of return for this method.mv
- object on which we add the instruction.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |