summaryrefslogtreecommitdiffstats
path: root/sample
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2004-04-14 15:49:55 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2004-04-14 15:49:55 +0000
commit3f73777f2cdf408d47bd85417611635235bdd7ed (patch)
treec0d6156cae1ca72e8ec2f3c36b8b83bcaae30916 /sample
parent2d7afcd04b007ef3322b132d82f3f32889414232 (diff)
downloadjavassist-3f73777f2cdf408d47bd85417611635235bdd7ed.tar.gz
javassist-3f73777f2cdf408d47bd85417611635235bdd7ed.zip
modified the ClassPool framework.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@84 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
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;
}