From: kabir.khan@jboss.com Date: Mon, 29 Mar 2010 12:32:16 +0000 (+0000) Subject: [JASSIST-111] Handle class array types as annotation values X-Git-Tag: rel_3_17_1_ga~132 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b4988a237d1de458b8d856f62543d8af685db1e4;p=javassist.git [JASSIST-111] Handle class array types as annotation values git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@518 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- diff --git a/src/main/javassist/bytecode/annotation/MemberValue.java b/src/main/javassist/bytecode/annotation/MemberValue.java index 98c3e034..5ce70cb7 100644 --- a/src/main/javassist/bytecode/annotation/MemberValue.java +++ b/src/main/javassist/bytecode/annotation/MemberValue.java @@ -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.