diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2006-03-08 07:19:35 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2006-03-08 07:19:35 +0000 |
commit | 003dce367a611ae6ddc516519e56f39281b3c953 (patch) | |
tree | 64232939bb6b320355da5ec634a856dc670d8285 /src | |
parent | 51c2a8c834d40b1ec2fd0ae71deb3fdfaaba7562 (diff) | |
download | javassist-003dce367a611ae6ddc516519e56f39281b3c953.tar.gz javassist-003dce367a611ae6ddc516519e56f39281b3c953.zip |
fixed a minor problem of CtClassType
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@257 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src')
-rw-r--r-- | src/main/javassist/CtClass.java | 2 | ||||
-rw-r--r-- | src/main/javassist/CtClassType.java | 23 |
2 files changed, 18 insertions, 7 deletions
diff --git a/src/main/javassist/CtClass.java b/src/main/javassist/CtClass.java index aee49094..fe6597a1 100644 --- a/src/main/javassist/CtClass.java +++ b/src/main/javassist/CtClass.java @@ -1137,7 +1137,7 @@ public abstract class CtClass { * @param directoryName it must end without a directory separator. */ public void writeFile(String directoryName) - throws NotFoundException, CannotCompileException, IOException + throws CannotCompileException, IOException { String classname = getName(); String filename = directoryName + File.separatorChar diff --git a/src/main/javassist/CtClassType.java b/src/main/javassist/CtClassType.java index 770d5724..86dbf3b2 100644 --- a/src/main/javassist/CtClassType.java +++ b/src/main/javassist/CtClassType.java @@ -437,12 +437,11 @@ class CtClassType extends CtClass { } Object[] result = new Object[size1 + size2]; - ClassLoader cl = ClassPool.getContextClassLoader(); for (int i = 0; i < size1; i++) - result[i] = anno1[i].toAnnotationType(cl, cp); + result[i] = toAnnoType(anno1[i], cp); for (int j = 0; j < size2; j++) - result[j + size1] = anno2[j].toAnnotationType(cl, cp); + result[j + size1] = toAnnoType(anno2[j], cp); return result; } @@ -460,7 +459,6 @@ class CtClassType extends CtClass { return new Object[0][]; Object[][] result = new Object[numParameters][]; - ClassLoader cl = ClassPool.getContextClassLoader(); for (int i = 0; i < numParameters; i++) { Annotation[] anno1, anno2; int size1, size2; @@ -485,15 +483,28 @@ 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); + result[i][j] = toAnnoType(anno1[j], cp); for (int j = 0; j < size2; ++j) - result[i][j + size1] = anno2[j].toAnnotationType(cl, cp); + result[i][j + size1] = toAnnoType(anno2[j], cp); } return result; } + private static Object toAnnoType(Annotation anno, ClassPool cp) + throws ClassNotFoundException + { + try { + ClassLoader cl = ClassPool.getContextClassLoader(); + return anno.toAnnotationType(cl, cp); + } + catch (ClassNotFoundException e) { + ClassLoader cl2 = cp.getClass().getClassLoader(); + return anno.toAnnotationType(cl2, cp); + } + } + public boolean subclassOf(CtClass superclass) { if (superclass == null) return false; |