aboutsummaryrefslogtreecommitdiffstats
path: root/sample
diff options
context:
space:
mode:
Diffstat (limited to 'sample')
-rw-r--r--sample/Test.java2
-rw-r--r--sample/evolve/DemoLoader.java3
-rw-r--r--sample/evolve/Evolution.java5
-rw-r--r--sample/vector/VectorAssistant.java4
4 files changed, 6 insertions, 8 deletions
diff --git a/sample/Test.java b/sample/Test.java
index 810b6b61..1e2b49c2 100644
--- a/sample/Test.java
+++ b/sample/Test.java
@@ -37,7 +37,7 @@ public class Test {
CtMethod fMethod = cc.getDeclaredMethod("f");
CtMethod gMethod = CtNewMethod.copy(fMethod, "g", cc, null);
cc.addMethod(gMethod);
- pool.writeFile("sample.Test"); // update the class file
+ cc.writeFile(); // update the class file
System.out.println("g() was added.");
}
}
diff --git a/sample/evolve/DemoLoader.java b/sample/evolve/DemoLoader.java
index 1d8c33f9..f1474a1f 100644
--- a/sample/evolve/DemoLoader.java
+++ b/sample/evolve/DemoLoader.java
@@ -31,9 +31,8 @@ public class DemoLoader {
public static void main(String[] args) throws Throwable {
Evolution translator = new Evolution();
ClassPool cp = ClassPool.getDefault();
- cp.addTranslator(translator);
Loader cl = new Loader();
- cl.setClassPool(cp);
+ cl.addTranslator(cp, translator);
translator.makeUpdatable("sample.evolve.WebPage");
cl.run("sample.evolve.DemoServer", args);
diff --git a/sample/evolve/Evolution.java b/sample/evolve/Evolution.java
index 810f1986..ad6d1281 100644
--- a/sample/evolve/Evolution.java
+++ b/sample/evolve/Evolution.java
@@ -43,16 +43,15 @@ public class Evolution implements Translator {
trapMethod = _pool.getMethod("sample.evolve.Sample", "make");
}
- public void onWrite(ClassPool _pool, String classname)
+ public void onWrite(ClassPool _pool, CtClass clazz)
throws NotFoundException, CannotCompileException
{
- onWriteUpdatable(classname);
+ onWriteUpdatable(clazz.getName());
/*
* Replaces all the occurrences of the new operator with a call
* to _makeInstance().
*/
- CtClass clazz = _pool.get(classname);
CtClass absClass = updatableClass;
CodeConverter converter = new CodeConverter();
converter.replaceNew(absClass, absClass, handlerMethod);
diff --git a/sample/vector/VectorAssistant.java b/sample/vector/VectorAssistant.java
index 44fdd41c..27d5f702 100644
--- a/sample/vector/VectorAssistant.java
+++ b/sample/vector/VectorAssistant.java
@@ -96,7 +96,7 @@ public class VectorAssistant implements Assistant {
vec.addMethod(CtNewMethod.copy(addmethod, "add", vec, map));
vec.addMethod(CtNewMethod.copy(atmethod, "at", vec, map));
- pool.writeFile(vec.getName());
+ vec.writeFile();
return vec;
}
@@ -125,7 +125,7 @@ public class VectorAssistant implements Assistant {
m = CtNewMethod.wrapped(type, "at", args2,
null, atmethod, null, vec);
vec.addMethod(m);
- pool.writeFile(vec.getName());
+ vec.writeFile();
return vec;
}