classUtils.javassist.sample.evolve
Class Evolution
java.lang.Object
classUtils.javassist.sample.evolve.Evolution
- All Implemented Interfaces:
- Translator
public class Evolution
- extends java.lang.Object
- implements Translator
Evolution provides a set of methods for instrumenting bytecodes.
For class evolution, updatable class A is renamed to B. Then an
abstract class named A is produced as the super class of B. If the
original class A has a public method m(), then the abstract class A
has an abstract method m().
abstract class A
abstract m()
_makeInstance()
|
class A --------> class B
m() m()
Also, all the other classes are translated so that "new A(i)"
in the methods is replaced with "_makeInstance(i)". This makes
it possible to change the behavior of the instantiation of
the class A.
Method Summary |
void |
makeUpdatable(java.lang.String classname)
|
void |
onWrite(ClassPool _pool,
java.lang.String classname)
Is invoked by a ClassPool for notifying that
a class is written out to an output stream. |
void |
start(ClassPool _pool)
Is invoked by a ClassPool for initialization
when the object is attached to a ClassPool object. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
handlerMethod
public static final java.lang.String handlerMethod
- See Also:
- Constant Field Values
latestVersionField
public static final java.lang.String latestVersionField
- See Also:
- Constant Field Values
versionManagerMethod
public static final java.lang.String versionManagerMethod
- See Also:
- Constant Field Values
Evolution
public Evolution()
start
public void start(ClassPool _pool)
throws NotFoundException
- Description copied from interface:
Translator
- Is invoked by a
ClassPool
for initialization
when the object is attached to a ClassPool
object.
- Specified by:
start
in interface Translator
- Parameters:
_pool
- the ClassPool
that this translator
is attached to.
- Throws:
NotFoundException
- See Also:
ClassPool.ClassPool(ClassPool,Translator)
,
ClassPool.getDefault(Translator)
onWrite
public void onWrite(ClassPool _pool,
java.lang.String classname)
throws NotFoundException,
CannotCompileException
- Description copied from interface:
Translator
- Is invoked by a
ClassPool
for notifying that
a class is written out to an output stream.
If CtClass.frozen() is true, that is, if the class has been
already modified and written, then onWrite() is not invoked.
- Specified by:
onWrite
in interface Translator
- Parameters:
_pool
- the ClassPool
that this translator
is attached to.classname
- a fully-qualified class name
- Throws:
NotFoundException
CannotCompileException
- See Also:
ClassPool.writeFile(String)
,
ClassPool.writeFile(String, String)
,
ClassPool.write(String)
,
ClassPool.write(String,DataOutputStream)
makeUpdatable
public void makeUpdatable(java.lang.String classname)
throws NotFoundException,
CannotCompileException
- Throws:
NotFoundException
CannotCompileException