Top Description Methods
javassist

public Interface Translator

Known Direct Implementers
javassist.tools.reflect.Reflection, javassist.tools.rmi.StubGenerator

An observer of Loader. The users can define a class implementing this interface and attach an instance of that class to a Loader object so that it can translate a class file when the class file is loaded into the JVM.
See Also
Loader#addTranslator(ClassPool, Translator)

Method Summary

Modifier and TypeMethod and Description
public void
onLoad(ClassPool
the ClassPool that this translator should use.
pool
,
String
the name of the class being loaded.
classname
)

Is invoked by a Loader for notifying that a class is loaded.

public void
start(ClassPool
the ClassPool that this translator should use.
pool
)

Is invoked by a Loader for initialization when the object is attached to the Loader object.

Method Detail

onLoadback to summary
public void onLoad(ClassPool pool, String classname) throws NotFoundException, CannotCompileException

Is invoked by a Loader for notifying that a class is loaded. The Loader calls

pool.get(classname).toBytecode()
to read the class file after onLoad() returns.

classname may be the name of a class that has not been created yet. If so, onLoad() must create that class so that the Loader can read it after onLoad() returns.

Parameters
pool:ClassPool

the ClassPool that this translator should use.

classname:String

the name of the class being loaded.

Exceptions
NotFoundException:
if a CtClass cannot be found.
CannotCompileException:
if the code transformation by this method fails.
See Also
Loader
startback to summary
public void start(ClassPool pool) throws NotFoundException, CannotCompileException

Is invoked by a Loader for initialization when the object is attached to the Loader object. This method can be used for getting (for caching) some CtClass objects that will be accessed in onLoad() in Translator.

Parameters
pool:ClassPool

the ClassPool that this translator should use.

Exceptions
NotFoundException:
if a CtClass cannot be found.
CannotCompileException:
if the initialization by this method fails.
See Also
Loader