aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorpatriot1burke <patriot1burke@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2004-04-20 21:50:37 +0000
committerpatriot1burke <patriot1burke@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2004-04-20 21:50:37 +0000
commit3fb5f5033c1c79dc7a2337dbef6a0677c6178db0 (patch)
tree6259a36fffd80251129e7f3b840fc477cc8cebf9 /src
parent8c3207c2518f3f88bceff9e20cb168bb177a5771 (diff)
downloadjavassist-3fb5f5033c1c79dc7a2337dbef6a0677c6178db0.tar.gz
javassist-3fb5f5033c1c79dc7a2337dbef6a0677c6178db0.zip
put back callback to ClassPool.writeAsClass. This callback to ClassPool instance
is required to be able to override how dynamic class creation works git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@91 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src')
-rw-r--r--src/main/javassist/ClassPool.java39
-rw-r--r--src/main/javassist/CtClass.java2
2 files changed, 25 insertions, 16 deletions
diff --git a/src/main/javassist/ClassPool.java b/src/main/javassist/ClassPool.java
index 8139ac5d..ee41d992 100644
--- a/src/main/javassist/ClassPool.java
+++ b/src/main/javassist/ClassPool.java
@@ -260,21 +260,30 @@ public class ClassPool {
return classLoader.loadClass(name);
}
- static Class loadClass(String classname, byte[] classfile)
- throws NotFoundException, IOException, CannotCompileException
- {
- if (classLoader == null)
- classLoader = new SimpleLoader();
-
- try {
- return classLoader.loadClass(classname, classfile);
- }
- catch (ClassFormatError e) {
- throw new CannotCompileException(e, classname);
- }
- }
-
- /**
+ /**
+ * Callback to write the class and create a Class object
+ * ClassPool can be extended to override this behavior
+ * @param classname
+ * @param classfile
+ * @return
+ * @throws NotFoundException
+ * @throws IOException
+ * @throws CannotCompileException
+ */
+ public Class writeAsClass(String classname, byte[] classfile)
+ throws CannotCompileException
+ {
+ try {
+ if (classLoader == null)
+ classLoader = new SimpleLoader();
+ return classLoader.loadClass(classname, classfile);
+ }
+ catch (ClassFormatError e) {
+ throw new CannotCompileException(e, classname);
+ }
+ }
+
+ /**
* Reads a class file and constructs a <code>CtClass</code>
* object with a new name.
* This method is useful if you want to generate a new class as a copy
diff --git a/src/main/javassist/CtClass.java b/src/main/javassist/CtClass.java
index bfca85fa..d3bc5379 100644
--- a/src/main/javassist/CtClass.java
+++ b/src/main/javassist/CtClass.java
@@ -849,7 +849,7 @@ public abstract class CtClass {
public Class toClass()
throws NotFoundException, IOException, CannotCompileException
{
- return ClassPool.loadClass(getName(), toBytecode());
+ return getClassPool().writeAsClass(getName(), toBytecode());
}
/**