|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.objectweb.fractal.julia.asm.AbstractClassGenerator
public abstract class AbstractClassGenerator
An abstract class generator based on the org.objectweb.asm
package.
This class generator takes as parameter the name of a super class and a list
of interface names, and generates a sub class of the given super class that
implements all the given interfaces.
Note: since this class stores information about the class that is currently being generated in its fields, it should not be used by multiple threads simultaneously.
Field Summary | |
---|---|
ClassLoader |
classLoader
The class loader to be used to load auxiliary classes, if needed. |
ClassWriter |
cw
The class that is being generated. |
List |
interfaces
The interfaces to be implemented by the class that is being generated. |
Loader |
loader
The loader to be used to load or generate auxiliary classes, if needed. |
String |
name
The internal name of the class that is being generated. |
String |
parameters
The parameters used to generate the class that is being generated. |
String |
superClass
The internal name of the super class of the class that is being generated. |
Constructor Summary | |
---|---|
AbstractClassGenerator()
|
Method Summary | |
---|---|
protected boolean |
computeMaxs()
Returns true if maxStack and maxLocals must be automatically computed. |
byte[] |
generateClass(String name,
Tree args,
Loader loader,
ClassLoader classLoader)
Generates a sub class of the given class that implements the given interfaces. |
protected void |
generateConstructor()
Generates the constructor of the class to be generated. |
protected void |
generateDefaultMethods()
Generates the default methods of the class to be generated. |
protected void |
generateHeader()
Generates the header of the class to be generated. |
protected void |
generateInterfaceMethods()
Generates the methods of the interfaces to be implemented by the class to be generated. |
protected abstract void |
generateMethod(Method m)
Generates a method of an interface to be implemented by the class to be generated. |
protected List |
getImplementedInterfaces()
Returns all the interfaces implemented by the class to be generated. |
static int |
getOpcodeOffset(Class type)
Returns the offset which must be added to some opcodes to get an opcode of the given type. |
static int |
getSize(Class type)
Returns the size of the given type. |
protected String |
getSource()
Returns the source of the class to be generated. |
protected void |
parseArgs(Tree args)
Initializes this class generator with the given arguments. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public ClassWriter cw
public String name
public String superClass
public List interfaces
public String parameters
public Loader loader
public ClassLoader classLoader
Constructor Detail |
---|
public AbstractClassGenerator()
Method Detail |
---|
public byte[] generateClass(String name, Tree args, Loader loader, ClassLoader classLoader) throws ClassGenerationException
parseArgs
, generateHeader
,
generateConstructor
, generateDefaultMethods
and generateInterfaceMethods
, in this order, in
order to generate the specified class.
generateClass
in interface ClassGenerator
name
- the name of the class that must be generated.args
- the parameters that described how the class must be generated.loader
- the loader to be used to load auxiliary classes.classLoader
- the class loader to be used to load auxiliary classes.
ClassGenerationException
- if the class cannot be generated.protected void parseArgs(Tree args)
args
- the descriptor of the class to be generated.protected boolean computeMaxs()
ClassWriter
).protected void generateHeader() throws ClassGenerationException
ClassGenerationException
- if a problem occurs.protected String getSource()
protected List getImplementedInterfaces() throws ClassGenerationException
interfaces
interfaces, and some
default interfaces such as Generated
. This method is used by
generateHeader
.
ClassGenerationException
- if a problem occurs.protected void generateConstructor() throws ClassGenerationException
ClassGenerationException
- if a problem occurs.protected void generateDefaultMethods() throws ClassGenerationException
getFcGeneratorParameters
method.
ClassGenerationException
- if a problem occurs.protected void generateInterfaceMethods() throws ClassGenerationException
generateMethod
for
each method of each interface to be implemented (generateMethod
is called only once per method, even for those that are
specified in several interfaces).
ClassGenerationException
- if a problem occurs.protected abstract void generateMethod(Method m) throws ClassGenerationException
m
- the method to be generated.
ClassGenerationException
- if a problem occurs.public static int getOpcodeOffset(Class type)
type
- a Java class representing a Java type (primitive or not).
public static int getSize(Class type)
type
- a Java class representing a Java type (primitive or not).
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |