aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/reflect
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/javassist/reflect')
-rw-r--r--src/main/javassist/reflect/Compiler.java9
-rw-r--r--src/main/javassist/reflect/Loader.java5
-rw-r--r--src/main/javassist/reflect/Reflection.java10
3 files changed, 10 insertions, 14 deletions
diff --git a/src/main/javassist/reflect/Compiler.java b/src/main/javassist/reflect/Compiler.java
index 222683a6..6ab55583 100644
--- a/src/main/javassist/reflect/Compiler.java
+++ b/src/main/javassist/reflect/Compiler.java
@@ -91,7 +91,7 @@ public class Compiler {
{
Reflection implementor = new Reflection();
ClassPool pool = ClassPool.getDefault();
- pool.addTranslator(implementor);
+ implementor.start(pool);
for (int i = 0; i < n; ++i) {
CtClass c = pool.get(entries[i].classname);
@@ -121,8 +121,11 @@ public class Compiler {
System.err.println(c.getName() + ": not reflective");
}
- for (int i = 0; i < n; ++i)
- pool.writeFile(entries[i].classname);
+ for (int i = 0; i < n; ++i) {
+ CtClass c = pool.get(entries[i].classname);
+ implementor.onWrite(pool, c);
+ c.writeFile();
+ }
}
private static int parse(String[] args, CompiledClass[] result) {
diff --git a/src/main/javassist/reflect/Loader.java b/src/main/javassist/reflect/Loader.java
index 626c329e..68381956 100644
--- a/src/main/javassist/reflect/Loader.java
+++ b/src/main/javassist/reflect/Loader.java
@@ -128,14 +128,13 @@ public class Loader extends javassist.Loader {
/**
* Constructs a new class loader.
*/
- public Loader() {
+ public Loader() throws CannotCompileException, NotFoundException {
super();
delegateLoadingOf("javassist.reflect.Loader");
reflection = new Reflection();
ClassPool pool = ClassPool.getDefault();
- pool.addTranslator(reflection);
- setClassPool(pool);
+ addTranslator(pool, reflection);
}
/**
diff --git a/src/main/javassist/reflect/Reflection.java b/src/main/javassist/reflect/Reflection.java
index b199a7ec..44477ee9 100644
--- a/src/main/javassist/reflect/Reflection.java
+++ b/src/main/javassist/reflect/Reflection.java
@@ -21,9 +21,6 @@ import javassist.CtMethod.ConstParameter;
/**
* The class implementing the reflection mechanism.
*
- * <p>This class is used with <code>ClassPool</code>.
- * Note that it implements an interface <code>javassist.Translator</code>.
- *
* <p>If a class is reflective,
* then all the method invocations on every
* instance of that class are intercepted by the runtime
@@ -58,8 +55,6 @@ import javassist.CtMethod.ConstParameter;
* @see javassist.reflect.Metaobject
* @see javassist.reflect.Loader
* @see javassist.reflect.Compiler
- * @see javassist.ClassPool
- * @see javassist.Translator
*/
public class Reflection implements Translator {
@@ -120,11 +115,10 @@ public class Reflection implements Translator {
* Inserts hooks for intercepting accesses to the fields declared
* in reflective classes.
*/
- public void onWrite(ClassPool pool, String classname)
+ public void onWrite(ClassPool pool, CtClass clazz)
throws CannotCompileException, NotFoundException
{
- CtClass c = pool.get(classname);
- c.instrument(converter);
+ clazz.instrument(converter);
}
/**