Package javassist
Interface Translator
-
- All Known Implementing Classes:
Reflection
,StubGenerator
public interface Translator
An observer ofLoader
. The users can define a class implementing this interface and attach an instance of that class to aLoader
object so that it can translate a class file when the class file is loaded into the JVM.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
onLoad(ClassPool pool, java.lang.String classname)
Is invoked by aLoader
for notifying that a class is loaded.void
start(ClassPool pool)
Is invoked by aLoader
for initialization when the object is attached to theLoader
object.
-
-
-
Method Detail
-
start
void start(ClassPool pool) throws NotFoundException, CannotCompileException
Is invoked by aLoader
for initialization when the object is attached to theLoader
object. This method can be used for getting (for caching) someCtClass
objects that will be accessed inonLoad()
inTranslator
.- Parameters:
pool
- theClassPool
that this translator should use.- Throws:
NotFoundException
- if aCtClass
cannot be found.CannotCompileException
- if the initialization by this method fails.- See Also:
Loader
-
onLoad
void onLoad(ClassPool pool, java.lang.String classname) throws NotFoundException, CannotCompileException
Is invoked by aLoader
for notifying that a class is loaded. TheLoader
callspool.get(classname).toBytecode()
to read the class file afteronLoad()
returns.classname
may be the name of a class that has not been created yet. If so,onLoad()
must create that class so that theLoader
can read it afteronLoad()
returns.- Parameters:
pool
- theClassPool
that this translator should use.classname
- the name of the class being loaded.- Throws:
NotFoundException
- if aCtClass
cannot be found.CannotCompileException
- if the code transformation by this method fails.- See Also:
Loader
-
-