summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authoradrian <adrian@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2006-03-15 17:46:52 +0000
committeradrian <adrian@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2006-03-15 17:46:52 +0000
commit163f2ece3197b5222b5967f6ce3a034913c01491 (patch)
tree7e67d51ab0bf241bac9ecc11fad67638ee7446e4 /src/main
parent42d7a2b9d57bb1aff44d1a68534727d11a992dda (diff)
downloadjavassist-163f2ece3197b5222b5967f6ce3a034913c01491.tar.gz
javassist-163f2ece3197b5222b5967f6ce3a034913c01491.zip
Allow a ClassPool to override the "guess" at the classloader to use.
The default is still the thread context classloader. git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@259 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main')
-rw-r--r--src/main/javassist/ClassPool.java18
-rw-r--r--src/main/javassist/CtClassType.java2
2 files changed, 17 insertions, 3 deletions
diff --git a/src/main/javassist/ClassPool.java b/src/main/javassist/ClassPool.java
index 25332d76..cd869285 100644
--- a/src/main/javassist/ClassPool.java
+++ b/src/main/javassist/ClassPool.java
@@ -754,7 +754,10 @@ public class ClassPool {
* To load the class, this method uses the context class loader
* of the current thread. If the program is running on some application
* server, the context class loader might be inappropriate to load the
- * class.
+ * class.<p>
+ *
+ * This can be changed by subclassing the pool and changing
+ * the getClassLoader() method.
*
* <p>This method is provided for convenience. If you need more
* complex functionality, you should write your own class loader.
@@ -762,10 +765,21 @@ public class ClassPool {
* @see #toClass(CtClass, java.lang.ClassLoader)
*/
public Class toClass(CtClass clazz) throws CannotCompileException {
- return toClass(clazz, getContextClassLoader());
+ return toClass(clazz, getClassLoader());
}
/**
+ * Get the classloader for this pool.<p>
+ *
+ * The default is the context class loader.
+ *
+ * @return the classloader for the pool
+ */
+ public ClassLoader getClassLoader() {
+ return getContextClassLoader();
+ }
+
+ /**
* Obtains a class loader that seems appropriate to look up a class
* by name.
*/
diff --git a/src/main/javassist/CtClassType.java b/src/main/javassist/CtClassType.java
index 86dbf3b2..ed3d9051 100644
--- a/src/main/javassist/CtClassType.java
+++ b/src/main/javassist/CtClassType.java
@@ -496,7 +496,7 @@ class CtClassType extends CtClass {
throws ClassNotFoundException
{
try {
- ClassLoader cl = ClassPool.getContextClassLoader();
+ ClassLoader cl = cp.getClassLoader();
return anno.toAnnotationType(cl, cp);
}
catch (ClassNotFoundException e) {