org.objectweb.proactive.core.component.asmgen
Class AbstractInterfaceClassGenerator

java.lang.Object
  |
  +--org.objectweb.proactive.core.component.asmgen.AbstractInterfaceClassGenerator
All Implemented Interfaces:
org.objectweb.asm.Constants
Direct Known Subclasses:
MetaObjectInterfaceClassGenerator, RepresentativeInterfaceClassGenerator

public abstract class AbstractInterfaceClassGenerator
extends java.lang.Object
implements org.objectweb.asm.Constants

Abstract parent class for Interface implementation generation. It defines a skeleton for the classes generation, and provides a set of utility methods that will be used by derived classes.

Author:
Matthieu Morel

Field Summary
protected  java.lang.Class cl
           
protected  org.objectweb.asm.ClassWriter classGenerator
           
protected  java.lang.String className
           
protected static java.lang.String FUNCTIONAL_INTERFACE_NAME_FIELD_NAME
           
protected static java.lang.String FUNCTIONAL_INTERFACE_NAME_TYPE
           
protected  java.util.Vector interfacesToImplement
           
protected static java.lang.String METHOD_ARRAY_TYPE
           
protected static java.lang.String METHOD_TYPE
           
protected static java.lang.String METHODCALL_TYPE
           
protected  java.lang.reflect.Method[] methods
           
protected static java.lang.String OBJECT_ARRAY_TYPE
           
protected static java.lang.String OBJECT_TYPE
           
protected  java.lang.String packageName
           
protected  java.lang.String stubClassFullName
           
protected  java.lang.String stubClassSimpleName
           
protected static java.lang.String SUPER_CLASS_NAME
           
 
Fields inherited from interface org.objectweb.asm.Constants
AALOAD, AASTORE, ACC_ABSTRACT, 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
 
Constructor Summary
AbstractInterfaceClassGenerator()
           
 
Method Summary
protected static int convertJavaModifierToASM(int javaModifier)
          utility method
 byte[] create()
          actually creates the bytecode corresponding to the generated class
protected  org.objectweb.asm.ClassWriter createClassGenerator()
           
protected  void createConstructor()
           
protected abstract  void createDefaultMethods()
          Method createDefaultMethods.
protected abstract  void createFields()
          Method createFields.
protected abstract  org.objectweb.asm.CodeVisitor createMethod(int i, java.lang.reflect.Method method)
          Method createMethod.
protected  org.objectweb.asm.CodeVisitor createMethodGenerator(java.lang.reflect.Method m)
           
protected  void createReturnCode(org.objectweb.asm.CodeVisitor cv, java.lang.Class c)
           
protected abstract  void createStaticInitializer()
          Method createStaticInitializer.
protected abstract  void createStaticVariables()
          Method createStaticVariables.
protected  void createUnwrappingCode(org.objectweb.asm.CodeVisitor cv, java.lang.Class c)
           
protected  java.lang.Class defineClass(java.lang.String className, byte[] bytes)
           
protected  int getOpcodeOffset(java.lang.Class type)
          Returns the offset which must be added to some opcodes to get an opcode of the given type.
protected  int getSize(java.lang.Class type)
          Return the size of the given type.
 java.lang.String getStubClassFullName()
          utility method
protected  java.lang.Class loadClass(java.lang.String className)
           
protected static int removeNativeAndAbstractModifiers(int modifiers)
          utility method
protected  void setInfos()
          This method is called by the constructor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

METHODCALL_TYPE

protected static final java.lang.String METHODCALL_TYPE
See Also:
Constant Field Values

OBJECT_TYPE

protected static final java.lang.String OBJECT_TYPE
See Also:
Constant Field Values

OBJECT_ARRAY_TYPE

protected static final java.lang.String OBJECT_ARRAY_TYPE
See Also:
Constant Field Values

METHOD_TYPE

protected static final java.lang.String METHOD_TYPE
See Also:
Constant Field Values

METHOD_ARRAY_TYPE

protected static final java.lang.String METHOD_ARRAY_TYPE
See Also:
Constant Field Values

FUNCTIONAL_INTERFACE_NAME_TYPE

protected static final java.lang.String FUNCTIONAL_INTERFACE_NAME_TYPE
See Also:
Constant Field Values

FUNCTIONAL_INTERFACE_NAME_FIELD_NAME

protected static final java.lang.String FUNCTIONAL_INTERFACE_NAME_FIELD_NAME
See Also:
Constant Field Values

SUPER_CLASS_NAME

protected static final java.lang.String SUPER_CLASS_NAME
See Also:
Constant Field Values

cl

protected java.lang.Class cl

className

protected java.lang.String className

packageName

protected java.lang.String packageName

methods

protected java.lang.reflect.Method[] methods

interfacesToImplement

protected java.util.Vector interfacesToImplement

classGenerator

protected org.objectweb.asm.ClassWriter classGenerator

stubClassSimpleName

protected java.lang.String stubClassSimpleName

stubClassFullName

protected java.lang.String stubClassFullName
Constructor Detail

AbstractInterfaceClassGenerator

public AbstractInterfaceClassGenerator()
Method Detail

createStaticInitializer

protected abstract void createStaticInitializer()
                                         throws java.lang.ClassNotFoundException
Method createStaticInitializer.

java.lang.ClassNotFoundException

createFields

protected abstract void createFields()
Method createFields.


createDefaultMethods

protected abstract void createDefaultMethods()
Method createDefaultMethods.


createMethod

protected abstract org.objectweb.asm.CodeVisitor createMethod(int i,
                                                              java.lang.reflect.Method method)
Method createMethod.

Parameters:
i -
method -
Returns:
CodeVisitor

createStaticVariables

protected abstract void createStaticVariables()
Method createStaticVariables.


convertJavaModifierToASM

protected static int convertJavaModifierToASM(int javaModifier)
utility method

Parameters:
javaModifier -
Returns:
the code identifying the java modifier with ASM

removeNativeAndAbstractModifiers

protected static int removeNativeAndAbstractModifiers(int modifiers)
utility method

Parameters:
modifiers -
Returns:
modifiers after applying masks

getStubClassFullName

public java.lang.String getStubClassFullName()
utility method

Returns:
the full class name of the stub

create

public byte[] create()
              throws java.lang.ClassNotFoundException
actually creates the bytecode corresponding to the generated class

Returns:
the bytecode corresponding to the generated class
Throws:
java.lang.ClassNotFoundException

createClassGenerator

protected org.objectweb.asm.ClassWriter createClassGenerator()
Returns:
a visitor for writing Java classes

createConstructor

protected void createConstructor()

createMethodGenerator

protected org.objectweb.asm.CodeVisitor createMethodGenerator(java.lang.reflect.Method m)

createUnwrappingCode

protected void createUnwrappingCode(org.objectweb.asm.CodeVisitor cv,
                                    java.lang.Class c)

createReturnCode

protected void createReturnCode(org.objectweb.asm.CodeVisitor cv,
                                java.lang.Class c)

getOpcodeOffset

protected int getOpcodeOffset(java.lang.Class type)
Returns the offset which must be added to some opcodes to get an opcode of the given type. More precisely, returns the offset which must be added to an opc_iXXXX opcode to get the opc_YXXXX opcode corresponding to the given type. For example, if the given type is double the result is 3, which means that opc_dload, opc_dstore, opc_dreturn... opcodes are equal to opc_iload+3, opc_istore+3, opc_ireturn+3...

Parameters:
type - a Java class representing a Java type (primitive or not).
Returns:
the opcode offset of the corresponding to the given type.

getSize

protected int getSize(java.lang.Class type)
Return the size of the given type. This size is 2 for the double and long types, and 1 for the other types.

Parameters:
type - a Java class representing a Java type (primitive or not).
Returns:
the size of the given type.

defineClass

protected java.lang.Class defineClass(java.lang.String className,
                                      byte[] bytes)

loadClass

protected java.lang.Class loadClass(java.lang.String className)
                             throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException

setInfos

protected void setInfos()
                 throws java.lang.ClassNotFoundException
This method is called by the constructor

java.lang.ClassNotFoundException


Copyright © April 2004 INRIA All Rights Reserved.