From 1330b1783963dcda4cd4ea0f526464ff6edfbc9a Mon Sep 17 00:00:00 2001 From: chiba Date: Fri, 17 Feb 2006 14:28:34 +0000 Subject: [PATCH] replaced individual calls to Thread.currentThread().getContextClassLoader() with a call to ClassPool#getContextClassLoader(), which simply forward to Thread.current... git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@249 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- src/main/javassist/ClassPool.java | 10 +++++++++- src/main/javassist/CtClassType.java | 5 +++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/javassist/ClassPool.java b/src/main/javassist/ClassPool.java index b0d8f9e9..25332d76 100644 --- a/src/main/javassist/ClassPool.java +++ b/src/main/javassist/ClassPool.java @@ -762,7 +762,15 @@ public class ClassPool { * @see #toClass(CtClass, java.lang.ClassLoader) */ public Class toClass(CtClass clazz) throws CannotCompileException { - return toClass(clazz, Thread.currentThread().getContextClassLoader()); + return toClass(clazz, getContextClassLoader()); + } + + /** + * Obtains a class loader that seems appropriate to look up a class + * by name. + */ + static ClassLoader getContextClassLoader() { + return Thread.currentThread().getContextClassLoader(); } /** diff --git a/src/main/javassist/CtClassType.java b/src/main/javassist/CtClassType.java index d4830676..cf41cc27 100644 --- a/src/main/javassist/CtClassType.java +++ b/src/main/javassist/CtClassType.java @@ -411,7 +411,7 @@ class CtClassType extends CtClass { } Object[] result = new Object[size1 + size2]; - ClassLoader cl = Thread.currentThread().getContextClassLoader(); + ClassLoader cl = ClassPool.getContextClassLoader(); for (int i = 0; i < size1; i++) result[i] = anno1[i].toAnnotationType(cl, cp); @@ -434,7 +434,7 @@ class CtClassType extends CtClass { return new Object[0][]; Object[][] result = new Object[numParameters][]; - ClassLoader cl = Thread.currentThread().getContextClassLoader(); + ClassLoader cl = ClassPool.getContextClassLoader(); for (int i = 0; i < numParameters; i++) { Annotation[] anno1, anno2; int size1, size2; @@ -460,6 +460,7 @@ class CtClassType extends CtClass { result[i] = new Object[size1 + size2]; for (int j = 0; j < size1; ++j) result[i][j] = anno1[j].toAnnotationType(cl, cp); + for (int j = 0; j < size2; ++j) result[i][j + size1] = anno2[j].toAnnotationType(cl, cp); } -- 2.39.5