org.objectweb.fractal.julia.asm
Class InterfaceClassGenerator

java.lang.Object
  extended by org.objectweb.fractal.julia.asm.AbstractClassGenerator
      extended by org.objectweb.fractal.julia.asm.InterfaceClassGenerator
All Implemented Interfaces:
Opcodes, ClassGenerator, Initializable

public class InterfaceClassGenerator
extends AbstractClassGenerator
implements Initializable

A class generator to generate Interface classes. This class generator generates sub classes of a given Interface class that implements the given set of interfaces. The super class must be a sub class of the BasicComponentInterface class.

The code generated for the I interface below is the following:

 public interface I {
   void m ();
 }

 public class XYZ extends superClass implements I, Generated {

   private I impl;

   public XYZ () {
   }

   public XYZ (Component o, String n,  Type t, boolean b, Object impl) {
     super(o, n, t, b, impl);
   }

   public void m () {
     impl.m();
   }

   public Object getFcItfImpl () {
     return impl;
   }

   public void setFcItfImpl (Object impl) {
     this.impl = (I)impl;
   }

   public String getFcGeneratorParameters () {
     return "(... superClass (I))";
   }
 }
 
If there is more than one interface, some additional casts are used:
 public class XY extends superClass implements I, J, Generated {

   private Object impl;

   public XY () {
   }

   public XY (Component o, String n,  Type t, boolean b, Object impl) {
     super(o, n, t, b, impl);
   }

   public void m () {
     ((I)impl).m();
   }

   public void n () {
     ((J)impl).n();
   }

   public Object getFcItfImpl () {
     return impl;
   }

   public void setFcItfImpl (Object impl) {
     this.impl = impl;
   }

   public String getFcGeneratorParameters () {
     return "(... superClass (I J))";
   }
 }
 


Field Summary
 
Fields inherited from class org.objectweb.fractal.julia.asm.AbstractClassGenerator
classLoader, cw, interfaces, loader, name, parameters, superClass
 
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
 
Constructor Summary
InterfaceClassGenerator()
           
 
Method Summary
protected  void generateConstructor()
          Generates the constructor of the class to be generated.
protected  void generateDefaultMethods()
          Calls the overriden method and generates the getFcItfImpl and setFcItfImpl methods.
protected  void generateMethod(Method m)
          Generates a method that forwards calls to the 'impl' object.
protected  String getSource()
          Returns the source of the class to be generated.
 void initialize(Tree args)
          Initializes this object with the given arguments.
protected  void parseArgs(Tree args)
          Initializes this class generator with the given arguments.
 
Methods inherited from class org.objectweb.fractal.julia.asm.AbstractClassGenerator
computeMaxs, generateClass, generateHeader, generateInterfaceMethods, getImplementedInterfaces, getOpcodeOffset, getSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InterfaceClassGenerator

public InterfaceClassGenerator()
Method Detail

initialize

public void initialize(Tree args)
                throws Exception
Initializes this object with the given arguments. These arguments must be of the form "(superClassName)", where superClassName is the name of the super class to be used for the class generated by this class generator.

Specified by:
initialize in interface Initializable
Parameters:
args - the arguments to be used to initialize this object. The format of these arguments depends on the class of this object.
Throws:
Exception - if a problem occurs during the object initialization.

parseArgs

protected void parseArgs(Tree args)
Initializes this class generator with the given arguments. This method requires arguments of the form "(objectDescriptor (itfName1 ... itfNameN))", where itfName1 ... itfNameN are the names of the interfaces it must implement.

Overrides:
parseArgs in class AbstractClassGenerator
Parameters:
args - the descriptor of the class to be generated.

getSource

protected String getSource()
Returns the source of the class to be generated. This method returns "INTERFACE[...]", where "..." is the name of the interface implemented by the generated class.

Overrides:
getSource in class AbstractClassGenerator
Returns:
the source of the class to be generated.

generateConstructor

protected void generateConstructor()
                            throws ClassGenerationException
Generates the constructor of the class to be generated. This method generates a default constructor and a constructor similar to the constructor of the BasicComponentInterface class.

Overrides:
generateConstructor in class AbstractClassGenerator
Throws:
ClassGenerationException - if a problem occurs.

generateDefaultMethods

protected void generateDefaultMethods()
                               throws ClassGenerationException
Calls the overriden method and generates the getFcItfImpl and setFcItfImpl methods.

Overrides:
generateDefaultMethods in class AbstractClassGenerator
Throws:
ClassGenerationException - if a problem occurs.

generateMethod

protected void generateMethod(Method m)
Generates a method that forwards calls to the 'impl' object.

Specified by:
generateMethod in class AbstractClassGenerator
Parameters:
m - the method that must be generated.