aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/bytecode/SignatureAttribute.java
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2010-09-14 14:38:43 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2010-09-14 14:38:43 +0000
commit4b05c10a1e3591547e669d116538949c0cb3905f (patch)
tree8843334ad15199216862d0c5e217dd707302d81e /src/main/javassist/bytecode/SignatureAttribute.java
parent325084e1ad1d5de64953b5eb9bc8b064484b7f97 (diff)
downloadjavassist-4b05c10a1e3591547e669d116538949c0cb3905f.tar.gz
javassist-4b05c10a1e3591547e669d116538949c0cb3905f.zip
fixed JASSIST-128 and JASSIST-129
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@574 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/bytecode/SignatureAttribute.java')
-rw-r--r--src/main/javassist/bytecode/SignatureAttribute.java57
1 files changed, 13 insertions, 44 deletions
diff --git a/src/main/javassist/bytecode/SignatureAttribute.java b/src/main/javassist/bytecode/SignatureAttribute.java
index 267098f8..958e93f6 100644
--- a/src/main/javassist/bytecode/SignatureAttribute.java
+++ b/src/main/javassist/bytecode/SignatureAttribute.java
@@ -96,54 +96,16 @@ public class SignatureAttribute extends AttributeInfo {
}
static String renameClass(String desc, String oldname, String newname) {
- if (desc.indexOf(oldname) < 0)
- return desc;
-
- StringBuffer newdesc = new StringBuffer();
- int head = 0;
- int i = 0;
- for (;;) {
- int j = desc.indexOf('L', i);
- if (j < 0)
- break;
-
- int k = j;
- int p = 0;
- char c;
- boolean match = true;
- try {
- int len = oldname.length();
- while (isNamePart(c = desc.charAt(++k)))
- if (p >= len || c != oldname.charAt(p++))
- match = false;
- }
- catch (IndexOutOfBoundsException e) { break; }
- i = k + 1;
- if (match && p == oldname.length()) {
- newdesc.append(desc.substring(head, j));
- newdesc.append('L');
- newdesc.append(newname);
- newdesc.append(c);
- head = i;
- }
- }
-
- if (head == 0)
- return desc;
- else {
- int len = desc.length();
- if (head < len)
- newdesc.append(desc.substring(head, len));
-
- return newdesc.toString();
- }
+ Map map = new java.util.HashMap();
+ map.put(oldname, newname);
+ return renameClass(desc, map);
}
static String renameClass(String desc, Map map) {
if (map == null)
return desc;
- StringBuffer newdesc = new StringBuffer();
+ StringBuilder newdesc = new StringBuilder();
int head = 0;
int i = 0;
for (;;) {
@@ -151,12 +113,19 @@ public class SignatureAttribute extends AttributeInfo {
if (j < 0)
break;
- StringBuffer nameBuf = new StringBuffer();
+ StringBuilder nameBuf = new StringBuilder();
int k = j;
char c;
try {
- while (isNamePart(c = desc.charAt(++k)))
+ while ((c = desc.charAt(++k)) != ';') {
nameBuf.append(c);
+ if (c == '<') {
+ while ((c = desc.charAt(++k)) != '>')
+ nameBuf.append(c);
+
+ nameBuf.append(c);
+ }
+ }
}
catch (IndexOutOfBoundsException e) { break; }
i = k + 1;