]> source.dussan.org Git - javassist.git/commitdiff
[JASSIST-111] Handle class array types as annotation values
authorkabir.khan@jboss.com <kabir.khan@jboss.com@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Mon, 29 Mar 2010 12:32:16 +0000 (12:32 +0000)
committerkabir.khan@jboss.com <kabir.khan@jboss.com@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Mon, 29 Mar 2010 12:32:16 +0000 (12:32 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@518 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

src/main/javassist/bytecode/annotation/MemberValue.java

index 98c3e034c7a1ef8ad4663c678de40f09312229ad..5ce70cb74dd3e3ddb982ed237fdf706eee995c16 100644 (file)
@@ -17,7 +17,10 @@ package javassist.bytecode.annotation;
 
 import javassist.ClassPool;
 import javassist.bytecode.ConstPool;
+import javassist.bytecode.Descriptor;
+
 import java.io.IOException;
+import java.lang.reflect.Array;
 import java.lang.reflect.Method;
 
 /**
@@ -49,12 +52,29 @@ public abstract class MemberValue {
         throws ClassNotFoundException, NoSuchClassError
     {
         try {
-            return Class.forName(classname, true, cl);
+            return Class.forName(convertFromArray(classname), true, cl);
         }
         catch (LinkageError e) {
             throw new NoSuchClassError(classname, e);
         }
     }
+    
+    private static String convertFromArray(String classname)
+    {
+//       int index = classname.indexOf("[]"); 
+//       if (index != -1)
+//       {
+//          String rawType = classname.substring(0, index);
+//          StringBuffer sb = new StringBuffer(Descriptor.of(rawType));
+//          while (index != -1)
+//          {
+//             sb.insert(0, "[");
+//             index = classname.indexOf("[]", index + 1);
+//          }
+//          return sb.toString().replace('/', '.');
+//       }
+       return classname;
+    }
 
     /**
      * Accepts a visitor.