multiverse.server.marshalling
Class InjectionGenerator

java.lang.Object
  extended by multiverse.server.marshalling.InjectionGenerator

public class InjectionGenerator
extends Object


Nested Class Summary
static class InjectionGenerator.BranchFixup
           
static class InjectionGenerator.PrimitiveTypeInfo
           
 
Field Summary
(package private)  HashSet<MarshallingRuntime.ClassNameAndTypeNumber> classesToBeMarshalled
           
(package private)  int currentStack
           
protected  boolean generateClassFiles
           
protected static InjectionGenerator instance
           
protected  boolean listGeneratedCode
           
(package private) static String marshallableClassName
           
(package private) static String marshallingRuntimeClassName
           
(package private)  int maxStack
           
(package private) static String mvByteBufferClassName
           
(package private)  org.apache.bcel.generic.ObjectType mvByteBufferType
           
(package private)  org.apache.bcel.generic.ObjectType OBJBOOLEAN
           
(package private)  org.apache.bcel.generic.ObjectType OBJBYTE
           
(package private)  org.apache.bcel.generic.ObjectType OBJCHAR
           
(package private)  org.apache.bcel.generic.ObjectType OBJDOUBLE
           
(package private)  org.apache.bcel.generic.ObjectType OBJFLOAT
           
(package private)  org.apache.bcel.generic.ObjectType OBJINT
           
(package private)  org.apache.bcel.generic.ObjectType OBJLONG
           
(package private)  org.apache.bcel.generic.ObjectType OBJSHORT
           
protected  String outputDir
           
protected static InjectionGenerator.PrimitiveTypeInfo[] primitiveTypes
           
 
Constructor Summary
InjectionGenerator(boolean generateClassFiles, String outputDir, boolean listGeneratedCode)
          InjectionGenerator constructor
 
Method Summary
protected  void addFieldFetch(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.generic.InstructionFactory factory, org.apache.bcel.classfile.Field f, org.apache.bcel.generic.InstructionList il)
           
protected  void addMarshallingForField(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.Field f, org.apache.bcel.generic.InstructionFactory factory, org.apache.bcel.generic.InstructionList il)
           
protected  void addMVByteBufferFieldGet(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.Field f, org.apache.bcel.generic.Type fieldType, InjectionGenerator.PrimitiveTypeInfo info, org.apache.bcel.generic.InstructionFactory factory, org.apache.bcel.generic.InstructionList il)
           
protected  void addMVByteBufferFieldPut(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.Field f, org.apache.bcel.generic.Type fieldType, InjectionGenerator.PrimitiveTypeInfo info, org.apache.bcel.generic.InstructionFactory factory, org.apache.bcel.generic.InstructionList il)
           
protected  void addStack(int count)
           
protected  void addUnmarshallingForField(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.Field f, org.apache.bcel.generic.InstructionFactory factory, org.apache.bcel.generic.ConstantPoolGen cp, org.apache.bcel.generic.InstructionList il)
           
protected  String aggregateTypeString(org.apache.bcel.generic.ObjectType fieldObjectType)
           
protected  org.apache.bcel.generic.MethodGen createMarshallingMethod(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.JavaClass superclass, org.apache.bcel.generic.ConstantPoolGen cp, org.apache.bcel.generic.InstructionFactory factory, LinkedList<org.apache.bcel.classfile.Field> fields, LinkedList<Integer> nullTestedFields, int flagBitCount)
          Create the marshalObject method
protected  org.apache.bcel.generic.MethodGen createUnmarshallingMethod(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.JavaClass superclass, org.apache.bcel.generic.ConstantPoolGen cp, org.apache.bcel.generic.InstructionFactory factory, LinkedList<org.apache.bcel.classfile.Field> fields, LinkedList<Integer> nullTestedFields, int flagBitCount)
          Create the unmarshalObject method
protected  boolean doesOrWillHandleMarshallable(org.apache.bcel.generic.ObjectType type)
           
protected  Short getAggregateTypeNum(org.apache.bcel.generic.ObjectType fieldObjectType)
           
protected  int getFinalStack()
           
static InjectionGenerator getInstance()
          Get the InjectionGenerator singleton instance
protected static InjectionGenerator.PrimitiveTypeInfo getPrimitiveTypeInfo(org.apache.bcel.generic.Type type)
           
protected static LinkedList<org.apache.bcel.classfile.Field> getValidClassFields(org.apache.bcel.classfile.JavaClass c)
           
static org.apache.bcel.classfile.JavaClass getValidSuperclass(org.apache.bcel.classfile.JavaClass c)
           
static boolean handlesMarshallable(org.apache.bcel.classfile.JavaClass clazz)
           
protected  boolean handlesMarshallable(org.apache.bcel.generic.ObjectType type)
           
static boolean handlesMarshallable(String typeName)
           
static void initialize(boolean generateClassFiles, String outputDir, boolean listGeneratedCode)
           
protected  void initializeGlobals()
           
protected  void initStack()
           
protected  org.apache.bcel.classfile.JavaClass injectMarshallingMethods(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.JavaClass superclass, LinkedList<org.apache.bcel.classfile.Field> fields, LinkedList<Integer> nullTestedFields, int flagBitCount)
          Inject the marshalling methods for this class
static boolean interfaceClass(String s)
           
protected static boolean isPrimitiveObjectType(org.apache.bcel.generic.Type type)
           
protected static boolean isPrimitiveType(org.apache.bcel.generic.Type type)
           
protected  boolean isStringType(org.apache.bcel.generic.Type type)
           
protected  void logGeneratedMethod(org.apache.bcel.generic.ClassGen classGen, org.apache.bcel.generic.MethodGen method)
           
protected static void logInvoke(String s, org.apache.bcel.generic.InvokeInstruction iv, org.apache.bcel.generic.ConstantPoolGen cp)
           
protected static org.apache.bcel.classfile.JavaClass lookupClass(String className)
           
protected  InjectionGenerator.BranchFixup[] makeOmittedTest(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.Field f, org.apache.bcel.generic.InstructionFactory factory, org.apache.bcel.generic.InstructionList il)
           
protected  boolean marshalledByMarshallingRuntimeMarshalObject(org.apache.bcel.generic.ObjectType fieldObjectType)
           
 org.apache.bcel.classfile.JavaClass maybeInjectMarshalling(org.apache.bcel.classfile.JavaClass clazz, Short typeNum)
          This is the public method called by MarshallingRuntime to inject marshalling methods into the clazz argument
protected static String nonPrimitiveObjectTypeName(org.apache.bcel.generic.Type type)
           
protected  void noteBranchTargets(InjectionGenerator.BranchFixup[] branchFixups, org.apache.bcel.generic.InstructionList il)
           
protected  boolean objectTypeIsInterface(org.apache.bcel.generic.ObjectType type)
           
protected  boolean referencesInterface(org.apache.bcel.generic.ObjectType type)
           
protected  org.apache.bcel.generic.Type storageType(org.apache.bcel.generic.Type type)
           
protected static void throwError(String msg)
           
protected  org.apache.bcel.generic.Type underlyingPrimitiveType(org.apache.bcel.generic.Type type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentStack

int currentStack

maxStack

int maxStack

classesToBeMarshalled

HashSet<MarshallingRuntime.ClassNameAndTypeNumber> classesToBeMarshalled

marshallingRuntimeClassName

static String marshallingRuntimeClassName

marshallableClassName

static String marshallableClassName

mvByteBufferClassName

static String mvByteBufferClassName

mvByteBufferType

org.apache.bcel.generic.ObjectType mvByteBufferType

OBJBOOLEAN

org.apache.bcel.generic.ObjectType OBJBOOLEAN

OBJBYTE

org.apache.bcel.generic.ObjectType OBJBYTE

OBJCHAR

org.apache.bcel.generic.ObjectType OBJCHAR

OBJDOUBLE

org.apache.bcel.generic.ObjectType OBJDOUBLE

OBJFLOAT

org.apache.bcel.generic.ObjectType OBJFLOAT

OBJINT

org.apache.bcel.generic.ObjectType OBJINT

OBJLONG

org.apache.bcel.generic.ObjectType OBJLONG

OBJSHORT

org.apache.bcel.generic.ObjectType OBJSHORT

generateClassFiles

protected boolean generateClassFiles

outputDir

protected String outputDir

listGeneratedCode

protected boolean listGeneratedCode

primitiveTypes

protected static InjectionGenerator.PrimitiveTypeInfo[] primitiveTypes

instance

protected static InjectionGenerator instance
Constructor Detail

InjectionGenerator

public InjectionGenerator(boolean generateClassFiles,
                          String outputDir,
                          boolean listGeneratedCode)
InjectionGenerator constructor

Parameters:
generateClassFiles - True if we should generate new class files containing injected methods. This is used by the batch injection code.
outputDir - If not the empty string, this is the directory in which generated class files should be stored.
listGeneratedCode - True if we should log the generated methods in the log file. This is only set when debugging InjectionGenerator.
Method Detail

getInstance

public static InjectionGenerator getInstance()
Get the InjectionGenerator singleton instance


maybeInjectMarshalling

public org.apache.bcel.classfile.JavaClass maybeInjectMarshalling(org.apache.bcel.classfile.JavaClass clazz,
                                                                  Short typeNum)
This is the public method called by MarshallingRuntime to inject marshalling methods into the clazz argument

Parameters:
clazz - The BCEL JavaClass instance representing the class file
typeNum - The type number for the class
Returns:
The modified JavaClazz instance

injectMarshallingMethods

protected org.apache.bcel.classfile.JavaClass injectMarshallingMethods(org.apache.bcel.classfile.JavaClass clazz,
                                                                       org.apache.bcel.classfile.JavaClass superclass,
                                                                       LinkedList<org.apache.bcel.classfile.Field> fields,
                                                                       LinkedList<Integer> nullTestedFields,
                                                                       int flagBitCount)
Inject the marshalling methods for this class


logGeneratedMethod

protected void logGeneratedMethod(org.apache.bcel.generic.ClassGen classGen,
                                  org.apache.bcel.generic.MethodGen method)

createMarshallingMethod

protected org.apache.bcel.generic.MethodGen createMarshallingMethod(org.apache.bcel.classfile.JavaClass clazz,
                                                                    org.apache.bcel.classfile.JavaClass superclass,
                                                                    org.apache.bcel.generic.ConstantPoolGen cp,
                                                                    org.apache.bcel.generic.InstructionFactory factory,
                                                                    LinkedList<org.apache.bcel.classfile.Field> fields,
                                                                    LinkedList<Integer> nullTestedFields,
                                                                    int flagBitCount)
Create the marshalObject method


addMarshallingForField

protected void addMarshallingForField(org.apache.bcel.classfile.JavaClass clazz,
                                      org.apache.bcel.classfile.Field f,
                                      org.apache.bcel.generic.InstructionFactory factory,
                                      org.apache.bcel.generic.InstructionList il)

addMVByteBufferFieldPut

protected void addMVByteBufferFieldPut(org.apache.bcel.classfile.JavaClass clazz,
                                       org.apache.bcel.classfile.Field f,
                                       org.apache.bcel.generic.Type fieldType,
                                       InjectionGenerator.PrimitiveTypeInfo info,
                                       org.apache.bcel.generic.InstructionFactory factory,
                                       org.apache.bcel.generic.InstructionList il)

makeOmittedTest

protected InjectionGenerator.BranchFixup[] makeOmittedTest(org.apache.bcel.classfile.JavaClass clazz,
                                                           org.apache.bcel.classfile.Field f,
                                                           org.apache.bcel.generic.InstructionFactory factory,
                                                           org.apache.bcel.generic.InstructionList il)

createUnmarshallingMethod

protected org.apache.bcel.generic.MethodGen createUnmarshallingMethod(org.apache.bcel.classfile.JavaClass clazz,
                                                                      org.apache.bcel.classfile.JavaClass superclass,
                                                                      org.apache.bcel.generic.ConstantPoolGen cp,
                                                                      org.apache.bcel.generic.InstructionFactory factory,
                                                                      LinkedList<org.apache.bcel.classfile.Field> fields,
                                                                      LinkedList<Integer> nullTestedFields,
                                                                      int flagBitCount)
Create the unmarshalObject method


addUnmarshallingForField

protected void addUnmarshallingForField(org.apache.bcel.classfile.JavaClass clazz,
                                        org.apache.bcel.classfile.Field f,
                                        org.apache.bcel.generic.InstructionFactory factory,
                                        org.apache.bcel.generic.ConstantPoolGen cp,
                                        org.apache.bcel.generic.InstructionList il)

addMVByteBufferFieldGet

protected void addMVByteBufferFieldGet(org.apache.bcel.classfile.JavaClass clazz,
                                       org.apache.bcel.classfile.Field f,
                                       org.apache.bcel.generic.Type fieldType,
                                       InjectionGenerator.PrimitiveTypeInfo info,
                                       org.apache.bcel.generic.InstructionFactory factory,
                                       org.apache.bcel.generic.InstructionList il)

addFieldFetch

protected void addFieldFetch(org.apache.bcel.classfile.JavaClass clazz,
                             org.apache.bcel.generic.InstructionFactory factory,
                             org.apache.bcel.classfile.Field f,
                             org.apache.bcel.generic.InstructionList il)

lookupClass

protected static org.apache.bcel.classfile.JavaClass lookupClass(String className)

getPrimitiveTypeInfo

protected static InjectionGenerator.PrimitiveTypeInfo getPrimitiveTypeInfo(org.apache.bcel.generic.Type type)

isStringType

protected boolean isStringType(org.apache.bcel.generic.Type type)

isPrimitiveObjectType

protected static boolean isPrimitiveObjectType(org.apache.bcel.generic.Type type)

isPrimitiveType

protected static boolean isPrimitiveType(org.apache.bcel.generic.Type type)

nonPrimitiveObjectTypeName

protected static String nonPrimitiveObjectTypeName(org.apache.bcel.generic.Type type)

underlyingPrimitiveType

protected org.apache.bcel.generic.Type underlyingPrimitiveType(org.apache.bcel.generic.Type type)

storageType

protected org.apache.bcel.generic.Type storageType(org.apache.bcel.generic.Type type)

getAggregateTypeNum

protected Short getAggregateTypeNum(org.apache.bcel.generic.ObjectType fieldObjectType)

aggregateTypeString

protected String aggregateTypeString(org.apache.bcel.generic.ObjectType fieldObjectType)

marshalledByMarshallingRuntimeMarshalObject

protected boolean marshalledByMarshallingRuntimeMarshalObject(org.apache.bcel.generic.ObjectType fieldObjectType)

referencesInterface

protected boolean referencesInterface(org.apache.bcel.generic.ObjectType type)

doesOrWillHandleMarshallable

protected boolean doesOrWillHandleMarshallable(org.apache.bcel.generic.ObjectType type)

handlesMarshallable

protected boolean handlesMarshallable(org.apache.bcel.generic.ObjectType type)

handlesMarshallable

public static boolean handlesMarshallable(String typeName)

handlesMarshallable

public static boolean handlesMarshallable(org.apache.bcel.classfile.JavaClass clazz)

objectTypeIsInterface

protected boolean objectTypeIsInterface(org.apache.bcel.generic.ObjectType type)

interfaceClass

public static boolean interfaceClass(String s)

getValidClassFields

protected static LinkedList<org.apache.bcel.classfile.Field> getValidClassFields(org.apache.bcel.classfile.JavaClass c)

getValidSuperclass

public static org.apache.bcel.classfile.JavaClass getValidSuperclass(org.apache.bcel.classfile.JavaClass c)

noteBranchTargets

protected void noteBranchTargets(InjectionGenerator.BranchFixup[] branchFixups,
                                 org.apache.bcel.generic.InstructionList il)

initStack

protected void initStack()

addStack

protected void addStack(int count)

getFinalStack

protected int getFinalStack()

logInvoke

protected static void logInvoke(String s,
                                org.apache.bcel.generic.InvokeInstruction iv,
                                org.apache.bcel.generic.ConstantPoolGen cp)

throwError

protected static void throwError(String msg)

initializeGlobals

protected void initializeGlobals()

initialize

public static void initialize(boolean generateClassFiles,
                              String outputDir,
                              boolean listGeneratedCode)