|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.objectweb.fractal.julia.asm.MergeClassGenerator
public class MergeClassGenerator
A class generator to merge several classes into a single one. This class generator copies all the non static fields and all the non static methods of the given classes (and of their super class, super super class, and so on) into a new class, with the following exceptions:
Controller
interface are merged into a single method.Controller
method, the fields and methods of the
classes to be merged should all be distinct: otherwise the generated class
will not be valid, because of duplicated field or method declarations.
As an example, the merging of the B and C classes below:
public class A { public int a; public void m () { ... } } public class B extends A implements I { private int b; private J weaveableJ; private K weaveableOptK; public void m () { super.m(); ... } public void n () { weaveableJ.o(weaveableOptK); } } public class C implement J { public void o (K k) { p(); } public static p () { q(); } private static q () { ... } }is the following class:
public class XYZ implements I, J, Generated { public int a; // copied from B's super class private int b; // copied from B // weaveableJ // NOT copied // weaveableOptK // NOT copied private void m$0 () { ... } // copied from B's super class public void m () { m$0(); ... } // copied from B public void n () { o(null); } // copied from B public void o (K k) { C.p(); } // copied from C // p // NOT copied (static) // q // NOT copied (static) public String getFcGeneratorParameters () { return "(...MergeClassGenerator java.lang.Object B C)"; } }
Field Summary | |
---|---|
ClassLoader |
classLoader
The class loader to be used to load auxiliary classes, if needed. |
Loader |
loader
The loader to be used to load or generate auxiliary classes, if needed. |
String |
parameters
The parameters used to generate the merged class. |
Constructor Summary | |
---|---|
MergeClassGenerator()
|
Method Summary | |
---|---|
byte[] |
generateClass(String name,
Tree args,
Loader loader,
ClassLoader classLoader)
Generates a class by merging the given classes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public Loader loader
public ClassLoader classLoader
public String parameters
Constructor Detail |
---|
public MergeClassGenerator()
Method Detail |
---|
public byte[] generateClass(String name, Tree args, Loader loader, ClassLoader classLoader) throws ClassGenerationException
generateClass
in interface ClassGenerator
name
- the name of the class to be generated.args
- a tree of the form "(objectDescriptor superClassName
className1 ... classNameN)", where className1 ... classNameN are the
names of the classes to be merged, and superClassName is the name of
the super class to be used for the merged class.loader
- the loader to be used to load or generate auxiliary classes,
if needed.classLoader
- the class loader to be used to load auxiliary classes,
if needed.
ClassGenerationException
- if a problem occurs during the generation
of the class.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |