diff options
Diffstat (limited to 'src/main/javassist/bytecode/SignatureAttribute.java')
-rw-r--r-- | src/main/javassist/bytecode/SignatureAttribute.java | 35 |
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); |