]> source.dussan.org Git - javassist.git/commitdiff
put back callback to ClassPool.writeAsClass. This callback to ClassPool instance
authorpatriot1burke <patriot1burke@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Tue, 20 Apr 2004 21:50:37 +0000 (21:50 +0000)
committerpatriot1burke <patriot1burke@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Tue, 20 Apr 2004 21:50:37 +0000 (21:50 +0000)
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

src/main/javassist/ClassPool.java
src/main/javassist/CtClass.java

index 8139ac5d6388e09b46ba91ed3282fba54101779c..ee41d99282e2ae0c2910cfaf6619817f5d0d4fcd 100644 (file)
@@ -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
index bfca85fa840f8e53dd2d098f1f9e124faaa340ae..d3bc537928ec0e5ba5ee7082a569ee5b3a74697d 100644 (file)
@@ -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());
     }
 
     /**