aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/bytecode/SignatureAttribute.java
diff options
context:
space:
mode:
authorchibash <chiba@javassist.org>2014-09-11 00:54:08 +0900
committerchibash <chiba@javassist.org>2014-09-11 00:54:08 +0900
commit4cdb575d4ea4ebed471f691d60f9d40b372a9fd1 (patch)
tree6cb7f2562a42abdc4625bc436cbf5943035b9883 /src/main/javassist/bytecode/SignatureAttribute.java
parent1d3ff9f328f1f90be71799857fc0ce9814eea4df (diff)
downloadjavassist-4cdb575d4ea4ebed471f691d60f9d40b372a9fd1.tar.gz
javassist-4cdb575d4ea4ebed471f691d60f9d40b372a9fd1.zip
fixed a bug of accesses to annotation arguments.
If foo.Bar.Baz is a nested class in foo.Bar, then the argument of @MyAnnotation(foo.bar.Baz.class) could not be obtained. The test code is javassist.JvstTest4#testAnnArg().
Diffstat (limited to 'src/main/javassist/bytecode/SignatureAttribute.java')
-rw-r--r--src/main/javassist/bytecode/SignatureAttribute.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main/javassist/bytecode/SignatureAttribute.java b/src/main/javassist/bytecode/SignatureAttribute.java
index 64b53952..0e05f24e 100644
--- a/src/main/javassist/bytecode/SignatureAttribute.java
+++ b/src/main/javassist/bytecode/SignatureAttribute.java
@@ -591,6 +591,13 @@ public class SignatureAttribute extends AttributeInfo {
sbuf.append(ts[i]);
}
}
+
+ /**
+ * Returns the type name in the JVM internal style.
+ * For example, if the type is a nested class {@code foo.Bar.Baz},
+ * then {@code foo.Bar$Baz} is returned.
+ */
+ public String jvmTypeName() { return toString(); }
}
/**
@@ -746,6 +753,34 @@ public class SignatureAttribute extends AttributeInfo {
return sbuf.toString();
}
+ /**
+ * Returns the type name in the JVM internal style.
+ * For example, if the type is a nested class {@code foo.Bar.Baz},
+ * then {@code foo.Bar$Baz} is returned.
+ */
+ public String jvmTypeName() {
+ StringBuffer sbuf = new StringBuffer();
+ ClassType parent = getDeclaringClass();
+ if (parent != null)
+ sbuf.append(parent.jvmTypeName()).append('$');
+
+ sbuf.append(name);
+ if (arguments != null) {
+ sbuf.append('<');
+ int n = arguments.length;
+ for (int i = 0; i < n; i++) {
+ if (i > 0)
+ sbuf.append(", ");
+
+ sbuf.append(arguments[i].toString());
+ }
+
+ sbuf.append('>');
+ }
+
+ return sbuf.toString();
+ }
+
void encode(StringBuffer sb) {
sb.append('L');
encode2(sb);