aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/javassist/CtClass.java2
-rw-r--r--src/main/javassist/bytecode/AnnotationDefaultAttribute.java22
-rw-r--r--src/main/javassist/bytecode/AttributeInfo.java2
-rw-r--r--src/main/javassist/bytecode/SignatureAttribute.java164
-rw-r--r--src/main/javassist/bytecode/annotation/ArrayMemberValue.java25
-rw-r--r--src/main/javassist/bytecode/annotation/ClassMemberValue.java15
-rw-r--r--src/main/javassist/bytecode/annotation/EnumMemberValue.java15
-rw-r--r--src/main/javassist/bytecode/annotation/MemberValue.java9
-rw-r--r--src/main/javassist/compiler/MemberCodeGen.java2
-rwxr-xr-xsrc/main/javassist/util/proxy/SecurityActions.java1
-rw-r--r--src/test/javassist/JvstTest.java1
-rw-r--r--src/test/javassist/JvstTest2.java6
-rw-r--r--src/test/javassist/bytecode/BytecodeTest.java10
-rw-r--r--src/test/javassist/bytecode/SignatureAttributeTest.java83
-rw-r--r--src/test/test2/AddCatchForConstructor.classbin488 -> 0 bytes
-rw-r--r--src/test/test2/AddLocalVar.classbin395 -> 0 bytes
-rw-r--r--src/test/test2/ArrayInit.classbin465 -> 0 bytes
-rw-r--r--src/test/test2/ArrayLenTest.classbin366 -> 0 bytes
-rw-r--r--src/test/test2/ArrayLength.classbin238 -> 0 bytes
-rw-r--r--src/test/test2/Brennan.classbin471 -> 0 bytes
-rw-r--r--src/test/test2/CodeGen.classbin2052 -> 0 bytes
-rw-r--r--src/test/test2/CodeGen2.classbin700 -> 0 bytes
-rw-r--r--src/test/test2/ConstBody.classbin500 -> 0 bytes
-rw-r--r--src/test/test2/ConstField.classbin578 -> 0 bytes
-rw-r--r--src/test/test2/DotClass.classbin1337 -> 0 bytes
-rw-r--r--src/test/test2/DotClass2.classbin578 -> 0 bytes
-rw-r--r--src/test/test2/DotClass4.classbin810 -> 0 bytes
-rw-r--r--src/test/test2/Finally.classbin1125 -> 0 bytes
-rw-r--r--src/test/test2/Imported.classbin166 -> 0 bytes
-rw-r--r--src/test/test2/Importer.classbin401 -> 0 bytes
-rw-r--r--src/test/test2/IncOp.classbin221 -> 0 bytes
-rw-r--r--src/test/test2/Inherit.classbin991 -> 0 bytes
-rw-r--r--src/test/test2/Inner.classbin1411 -> 0 bytes
-rw-r--r--src/test/test2/Inner.java5
-rw-r--r--src/test/test2/Inner2.java23
-rw-r--r--src/test/test2/InsertAt.classbin686 -> 0 bytes
-rw-r--r--src/test/test2/InsertLocal.classbin1088 -> 0 bytes
-rw-r--r--src/test/test2/LocalVar.classbin550 -> 0 bytes
-rw-r--r--src/test/test2/MakeStaticMethod.classbin281 -> 0 bytes
-rw-r--r--src/test/test2/MethodCall.classbin475 -> 0 bytes
-rw-r--r--src/test/test2/Nested$Inner3.classbin593 -> 0 bytes
-rw-r--r--src/test/test2/Nested.classbin904 -> 0 bytes
-rw-r--r--src/test/test2/Nested2$Inner.classbin1081 -> 0 bytes
-rw-r--r--src/test/test2/Nested2.classbin1230 -> 0 bytes
-rw-r--r--src/test/test2/Nested3$Inner.classbin678 -> 0 bytes
-rw-r--r--src/test/test2/Nested3.classbin944 -> 0 bytes
-rw-r--r--src/test/test2/Nested4$Inner.classbin301 -> 0 bytes
-rw-r--r--src/test/test2/Nested4.classbin482 -> 0 bytes
-rw-r--r--src/test/test2/NewArray.classbin864 -> 0 bytes
-rw-r--r--src/test/test2/NewExprInTry.classbin681 -> 0 bytes
-rw-r--r--src/test/test2/NewExprTry.classbin948 -> 0 bytes
-rw-r--r--src/test/test2/NewOp.classbin855 -> 0 bytes
-rw-r--r--src/test/test2/NullArgTest.classbin426 -> 0 bytes
-rw-r--r--src/test/test2/Remove.classbin445 -> 0 bytes
-rw-r--r--src/test/test2/RemoveCall.classbin539 -> 0 bytes
-rw-r--r--src/test/test2/ReplaceClassName.classbin538 -> 0 bytes
-rw-r--r--src/test/test2/SetExceptions.classbin387 -> 0 bytes
-rw-r--r--src/test/test2/SetSuper.classbin218 -> 0 bytes
-rw-r--r--src/test/test2/SetSuperIntf.classbin134 -> 0 bytes
-rw-r--r--src/test/test2/SetSuperParent.classbin178 -> 0 bytes
-rw-r--r--src/test/test2/StaticFinal.classbin608 -> 0 bytes
-rw-r--r--src/test/test2/StaticMember.classbin863 -> 0 bytes
-rw-r--r--src/test/test2/StaticMember2.classbin888 -> 0 bytes
-rw-r--r--src/test/test2/SuperCall.classbin628 -> 0 bytes
-rw-r--r--src/test/test2/SuperInterface3.classbin349 -> 0 bytes
-rw-r--r--src/test/test2/Switch.classbin784 -> 0 bytes
-rw-r--r--src/test/test2/Synch.classbin503 -> 0 bytes
67 files changed, 346 insertions, 39 deletions
diff --git a/src/main/javassist/CtClass.java b/src/main/javassist/CtClass.java
index f227019f..f1a47342 100644
--- a/src/main/javassist/CtClass.java
+++ b/src/main/javassist/CtClass.java
@@ -1423,7 +1423,7 @@ public abstract class CtClass {
public void detach() {
ClassPool cp = getClassPool();
CtClass obj = cp.removeCached(getName());
- if (obj != this)
+ if (obj != null && obj != this)
cp.cacheCtClass(getName(), obj, false);
}
diff --git a/src/main/javassist/bytecode/AnnotationDefaultAttribute.java b/src/main/javassist/bytecode/AnnotationDefaultAttribute.java
index 43021ecf..8c7084c0 100644
--- a/src/main/javassist/bytecode/AnnotationDefaultAttribute.java
+++ b/src/main/javassist/bytecode/AnnotationDefaultAttribute.java
@@ -117,6 +117,28 @@ public class AnnotationDefaultAttribute extends AttributeInfo {
}
}
+ @Override
+ void renameClass(String oldname, String newname) {
+ try {
+ MemberValue defaultValue = getDefaultValue();
+ defaultValue.renameClass(oldname, newname);
+ setDefaultValue(defaultValue);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ @Override
+ void renameClass(Map<String, String> classnames) {
+ try {
+ MemberValue defaultValue = getDefaultValue();
+ defaultValue.renameClass(classnames);
+ setDefaultValue(defaultValue);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
/**
* Obtains the default value represented by this attribute.
*/
diff --git a/src/main/javassist/bytecode/AttributeInfo.java b/src/main/javassist/bytecode/AttributeInfo.java
index be6e2a21..3aa0bd31 100644
--- a/src/main/javassist/bytecode/AttributeInfo.java
+++ b/src/main/javassist/bytecode/AttributeInfo.java
@@ -254,7 +254,7 @@ public class AttributeInfo {
/* The following two methods are used to implement
* ClassFile.renameClass().
* Only CodeAttribute, LocalVariableAttribute,
- * AnnotationsAttribute, and SignatureAttribute
+ * AnnotationDefaultAttribute, AnnotationsAttribute, and SignatureAttribute
* override these methods.
*/
void renameClass(String oldname, String newname) {}
diff --git a/src/main/javassist/bytecode/SignatureAttribute.java b/src/main/javassist/bytecode/SignatureAttribute.java
index 1a8a62dc..ff160f82 100644
--- a/src/main/javassist/bytecode/SignatureAttribute.java
+++ b/src/main/javassist/bytecode/SignatureAttribute.java
@@ -19,6 +19,7 @@ package javassist.bytecode;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -110,42 +111,34 @@ public class SignatureAttribute extends AttributeInfo {
}
static String renameClass(String desc, Map<String,String> map) {
- if (map == null)
+ if (map == null || map.isEmpty())
return desc;
StringBuilder newdesc = new StringBuilder();
int head = 0;
int i = 0;
for (;;) {
- int j = desc.indexOf('L', i);
+ final int j = desc.indexOf('L', i);
if (j < 0)
break;
- StringBuilder nameBuf = new StringBuilder();
- int k = j;
- char c;
- try {
- while ((c = desc.charAt(++k)) != ';') {
- nameBuf.append(c);
- if (c == '<') {
- while ((c = desc.charAt(++k)) != '>')
- nameBuf.append(c);
+ final ArrayList<StringBuilder> nameBufs = new ArrayList<>();
+ final ArrayList<StringBuilder> genericParamBufs = new ArrayList<>();
+ i = parseClassName(nameBufs, genericParamBufs, desc, j) + 1;
+ if (i < 0)
+ break;
- nameBuf.append(c);
- }
- }
- }
- catch (IndexOutOfBoundsException e) { break; }
- i = k + 1;
- String name = nameBuf.toString();
- String name2 = map.get(name);
- if (name2 != null) {
- newdesc.append(desc.substring(head, j));
- newdesc.append('L');
- newdesc.append(name2);
- newdesc.append(c);
- head = i;
+ String name = String.join("$", nameBufs.toArray(new StringBuilder[0]));
+ String newname = map.get(name);
+ if (newname != null) {
+ if (makeNewClassName(desc, map, name, newname, newdesc, head, j,
+ nameBufs, genericParamBufs))
+ head = i;
}
+ else
+ if (replaceTypeArguments(desc, map, newdesc, head, j,
+ nameBufs, genericParamBufs))
+ head = i;
}
if (head == 0)
@@ -157,6 +150,127 @@ public class SignatureAttribute extends AttributeInfo {
return newdesc.toString();
}
+ private static int parseClassName(ArrayList<StringBuilder> nameBufs,
+ ArrayList<StringBuilder> genericParamBufs,
+ String desc, int j)
+ {
+ StringBuilder nameBuf = new StringBuilder();
+ StringBuilder genericParamBuf = new StringBuilder();
+ int k = j;
+ char c;
+ try {
+ while ((c = desc.charAt(++k)) != ';') {
+ if (c == '<') {
+ genericParamBuf.append(c);
+ int level = 1;
+ while (level > 0) {
+ c = desc.charAt(++k);
+ genericParamBuf.append(c);
+ if (c == '<')
+ ++level;
+ else if (c == '>')
+ --level;
+ }
+ }
+ else if (c == '.') {
+ nameBufs.add(nameBuf);
+ genericParamBufs.add(genericParamBuf);
+ nameBuf = new StringBuilder();
+ genericParamBuf = new StringBuilder();
+ }
+ else
+ nameBuf.append(c);
+ }
+ }
+ catch (IndexOutOfBoundsException e) {
+ return -2; // error
+ }
+
+ nameBufs.add(nameBuf);
+ genericParamBufs.add(genericParamBuf);
+ return k;
+ }
+
+ private static boolean makeNewClassName(String desc,
+ Map<String,String> map, String name,
+ String newname, StringBuilder newdesc,
+ int head, int j,
+ ArrayList<StringBuilder> nameBufs,
+ ArrayList<StringBuilder> genericParamBufs)
+ {
+ final String[] nameSplit = name.split("\\$");
+ final String[] newnameSplit = newname.split("\\$");
+ if (nameSplit.length == newnameSplit.length) {
+ final String[] newnames = new String[nameBufs.size()];
+ for (int start = 0, z = 0; z < nameBufs.size(); z++) {
+ final int toAggregate = (int) nameBufs.get(z).chars().filter(ch -> ch == '$').count() + 1;
+ String s = String.join("$", Arrays.copyOfRange(newnameSplit, start, start + toAggregate));
+ start += toAggregate;
+ newnames[z] = s;
+ }
+
+ newdesc.append(desc.substring(head, j));
+ newdesc.append('L');
+ for (int z = 0; z < newnames.length; z++) {
+ if (z > 0)
+ newdesc.append('.');
+
+ newdesc.append(newnames[z]);
+ final String newgenericParam;
+ final StringBuilder genericParamBufCurrent = genericParamBufs.get(z);
+ if (genericParamBufCurrent.length() > 0)
+ newgenericParam = "<" + renameClass(genericParamBufCurrent.substring(1, genericParamBufCurrent.length() - 1), map) + ">";
+ else
+ newgenericParam = genericParamBufCurrent.toString(); //empty string
+
+ newdesc.append(newgenericParam);
+ }
+ newdesc.append(';'); //the final semicolon
+ return true;
+ }
+ else
+ return false;
+ }
+
+ private static boolean replaceTypeArguments(String desc,
+ Map<String,String> map,
+ StringBuilder newdesc,
+ int head, int j,
+ ArrayList<StringBuilder> nameBufs,
+ ArrayList<StringBuilder> genericParamBufs)
+ {
+ final ArrayList<String> newGenericParamBufs = new ArrayList<String>();
+ boolean changed = false;
+ for (int z = 0; z < genericParamBufs.size(); z++) {
+ final String newGenericParam;
+ final StringBuilder genericParamBufCurrent = genericParamBufs.get(z);
+ if (genericParamBufCurrent.length() > 0) {
+ newGenericParam = "<" + renameClass(genericParamBufCurrent.substring(1, genericParamBufCurrent.length() - 1), map) + ">";
+ changed = changed || !genericParamBufCurrent.toString().equals(newGenericParam);
+ }
+ else
+ newGenericParam = genericParamBufCurrent.toString(); //empty string
+
+ newGenericParamBufs.add(newGenericParam);
+ }
+
+ if (changed) {
+ newdesc.append(desc.substring(head, j));
+ newdesc.append('L');
+ for (int z = 0; z < genericParamBufs.size(); z++) {
+ if (z > 0)
+ newdesc.append('.');
+
+ newdesc.append(nameBufs.get(z));
+ newdesc.append(newGenericParamBufs.get(z));
+ }
+ newdesc.append(';');
+ return true;
+ }
+ else
+ return false;
+ }
+
@SuppressWarnings("unused")
private static boolean isNamePart(int c) {
return c != ';' && c != '<';
diff --git a/src/main/javassist/bytecode/annotation/ArrayMemberValue.java b/src/main/javassist/bytecode/annotation/ArrayMemberValue.java
index d1eeb271..f6bc6150 100644
--- a/src/main/javassist/bytecode/annotation/ArrayMemberValue.java
+++ b/src/main/javassist/bytecode/annotation/ArrayMemberValue.java
@@ -18,6 +18,7 @@ package javassist.bytecode.annotation;
import java.io.IOException;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
+import java.util.Map;
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
@@ -87,6 +88,30 @@ public class ArrayMemberValue extends MemberValue {
return a.getClass();
}
+ @Override
+ public void renameClass(String oldname, String newname) {
+ if (type != null) {
+ type.renameClass(oldname, newname);
+ }
+ if (values != null) {
+ for (MemberValue value : values) {
+ value.renameClass(oldname, newname);
+ }
+ }
+ }
+
+ @Override
+ public void renameClass(Map<String, String> classnames) {
+ if (type != null) {
+ type.renameClass(classnames);
+ }
+ if (values != null) {
+ for (MemberValue value : values) {
+ value.renameClass(classnames);
+ }
+ }
+ }
+
/**
* Obtains the type of the elements.
*
diff --git a/src/main/javassist/bytecode/annotation/ClassMemberValue.java b/src/main/javassist/bytecode/annotation/ClassMemberValue.java
index e9fd7ec4..495a1e2a 100644
--- a/src/main/javassist/bytecode/annotation/ClassMemberValue.java
+++ b/src/main/javassist/bytecode/annotation/ClassMemberValue.java
@@ -18,6 +18,7 @@ package javassist.bytecode.annotation;
import java.io.IOException;
import java.lang.reflect.Method;
+import java.util.Map;
import javassist.ClassPool;
import javassist.bytecode.BadBytecode;
@@ -95,6 +96,20 @@ public class ClassMemberValue extends MemberValue {
return loadClass(cl, "java.lang.Class");
}
+ @Override
+ public void renameClass(String oldname, String newname) {
+ String value = cp.getUtf8Info(valueIndex);
+ String newValue = Descriptor.rename(value, oldname, newname);
+ setValue(Descriptor.toClassName(newValue));
+ }
+
+ @Override
+ public void renameClass(Map<String, String> classnames) {
+ String value = cp.getUtf8Info(valueIndex);
+ String newValue = Descriptor.rename(value, classnames);
+ setValue(Descriptor.toClassName(newValue));
+ }
+
/**
* Obtains the value of the member.
*
diff --git a/src/main/javassist/bytecode/annotation/EnumMemberValue.java b/src/main/javassist/bytecode/annotation/EnumMemberValue.java
index a0a4e036..0f37178a 100644
--- a/src/main/javassist/bytecode/annotation/EnumMemberValue.java
+++ b/src/main/javassist/bytecode/annotation/EnumMemberValue.java
@@ -18,6 +18,7 @@ package javassist.bytecode.annotation;
import java.io.IOException;
import java.lang.reflect.Method;
+import java.util.Map;
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
@@ -76,6 +77,20 @@ public class EnumMemberValue extends MemberValue {
return loadClass(cl, getType());
}
+ @Override
+ public void renameClass(String oldname, String newname) {
+ String type = cp.getUtf8Info(typeIndex);
+ String newType = Descriptor.rename(type, oldname, newname);
+ setType(Descriptor.toClassName(newType));
+ }
+
+ @Override
+ public void renameClass(Map<String, String> classnames) {
+ String type = cp.getUtf8Info(typeIndex);
+ String newType = Descriptor.rename(type, classnames);
+ setType(Descriptor.toClassName(newType));
+ }
+
/**
* Obtains the enum type name.
*
diff --git a/src/main/javassist/bytecode/annotation/MemberValue.java b/src/main/javassist/bytecode/annotation/MemberValue.java
index da99885c..0f132a83 100644
--- a/src/main/javassist/bytecode/annotation/MemberValue.java
+++ b/src/main/javassist/bytecode/annotation/MemberValue.java
@@ -18,6 +18,7 @@ package javassist.bytecode.annotation;
import java.io.IOException;
import java.lang.reflect.Method;
+import java.util.Map;
import javassist.ClassPool;
import javassist.bytecode.ConstPool;
@@ -74,6 +75,14 @@ public abstract class MemberValue {
return classname;
}
+ /* The following two methods are used to implement
+ * ClassFile.renameClass().
+ * Only ArrayMemberValue, ClassMemberValue, EnumMemberValue
+ * override these methods.
+ */
+ public void renameClass(String oldname, String newname) {}
+ public void renameClass(Map<String, String> classnames) {}
+
/**
* Accepts a visitor.
*/
diff --git a/src/main/javassist/compiler/MemberCodeGen.java b/src/main/javassist/compiler/MemberCodeGen.java
index 48acd137..e8e9912b 100644
--- a/src/main/javassist/compiler/MemberCodeGen.java
+++ b/src/main/javassist/compiler/MemberCodeGen.java
@@ -648,7 +648,7 @@ public class MemberCodeGen extends CodeGen {
throw new CompileError("no such constructor: " + targetClass.getName());
if (declClass != thisClass && AccessFlag.isPrivate(acc)) {
- if (declClass.getClassFile().getMajorVersion() < ClassFile.JAVA_11
+ if (declClass.getClassFile().getMajorVersion() < ClassFile.JAVA_8
|| !isFromSameDeclaringClass(declClass, thisClass)) {
desc = getAccessibleConstructor(desc, declClass, minfo);
bytecode.addOpcode(Opcode.ACONST_NULL); // the last parameter
diff --git a/src/main/javassist/util/proxy/SecurityActions.java b/src/main/javassist/util/proxy/SecurityActions.java
index c940561b..6873e01b 100755
--- a/src/main/javassist/util/proxy/SecurityActions.java
+++ b/src/main/javassist/util/proxy/SecurityActions.java
@@ -213,7 +213,6 @@ class SecurityActions extends SecurityManager
if (e.getCause() instanceof NoSuchFieldException)
throw new ClassNotFoundException("No such instance.", e.getCause());
if (e.getCause() instanceof IllegalAccessException
- || e.getCause() instanceof IllegalAccessException
|| e.getCause() instanceof SecurityException)
throw new ClassNotFoundException("Security denied access.", e.getCause());
throw new RuntimeException(e.getCause());
diff --git a/src/test/javassist/JvstTest.java b/src/test/javassist/JvstTest.java
index 47a61083..3ed16827 100644
--- a/src/test/javassist/JvstTest.java
+++ b/src/test/javassist/JvstTest.java
@@ -1181,6 +1181,7 @@ public class JvstTest extends JvstTestRoot {
suite.addTestSuite(test.javassist.convert.ArrayAccessReplaceTest.class);
suite.addTestSuite(test.javassist.convert.ArrayAccessReplaceTest2.class);
suite.addTestSuite(test.javassist.bytecode.analysis.DomTreeTest.class);
+ suite.addTestSuite(javassist.bytecode.SignatureAttributeTest.class);
return suite;
}
}
diff --git a/src/test/javassist/JvstTest2.java b/src/test/javassist/JvstTest2.java
index 0ea4571b..5d01961d 100644
--- a/src/test/javassist/JvstTest2.java
+++ b/src/test/javassist/JvstTest2.java
@@ -275,10 +275,8 @@ public class JvstTest2 extends JvstTestRoot {
String src =
"public void sampleMethod() throws Exception {"
+ "java.util.Properties props = new java.util.Properties();"
- + "java.rmi.activation.ActivationGroupDesc.CommandEnvironment ace "
- + " = null;"
- + "java.rmi.activation.ActivationGroupDesc agd "
- + " = new java.rmi.activation.ActivationGroupDesc(props,ace);}";
+ + "test2.Inner2.Child ace = null;"
+ + "test2.Inner2 agd = new test2.Inner2(props, ace);}";
CtMethod newmethod = CtNewMethod.make(src, target);
target.addMethod(newmethod);
diff --git a/src/test/javassist/bytecode/BytecodeTest.java b/src/test/javassist/bytecode/BytecodeTest.java
index 7aef1cce..eac420bc 100644
--- a/src/test/javassist/bytecode/BytecodeTest.java
+++ b/src/test/javassist/bytecode/BytecodeTest.java
@@ -475,10 +475,14 @@ public class BytecodeTest extends TestCase {
changeMsig2("<S:Ljava/lang/Object;>(TS;[TS;)Ljava/lang/Objec;", "java/lang/Object",
"<S:Ljava/lang/Object2;>(TS;[TS;)Ljava/lang/Objec;", "java/lang/Object2");
String sig = "<T:Ljava/lang/Exception;>LPoi$Foo<Ljava/lang/String;>;LBar;LBar2;";
- //String res = "<T:Ljava/lang/Exception;>LPoi$Foo<Ljava/lang/String2;>;LBar;LBar2;";
- changeMsig(sig, "java/lang/String", sig, "java/lang/String2");
- changeMsig2(sig, "java/lang/String", sig, "java/lang/String2");
+ String res = "<T:Ljava/lang/Exception;>LPoi$Foo<Ljava/lang/String2;>;LBar;LBar2;";
+ changeMsig(sig, "java/lang/String", res, "java/lang/String2");
+ changeMsig2(sig, "java/lang/String", res, "java/lang/String2");
changeMsig("Ltest<TE;>.List;", "ist", "Ltest<TE;>.List;", "IST");
+ changeMsig("Ljava/lang/String<Ljava/lang/Object;>;", "java/lang/String",
+ "Ljava/lang/String2<Ljava/lang/Object;>;", "java/lang/String2");
+ changeMsig2("Ljava/lang/String<Ljava/lang/Object;>;", "java/lang/String",
+ "Ljava/lang/String2<Ljava/lang/Object;>;", "java/lang/String2");
}
private void changeMsig(String old, String oldname, String result, String newname) {
diff --git a/src/test/javassist/bytecode/SignatureAttributeTest.java b/src/test/javassist/bytecode/SignatureAttributeTest.java
new file mode 100644
index 00000000..aac33f21
--- /dev/null
+++ b/src/test/javassist/bytecode/SignatureAttributeTest.java
@@ -0,0 +1,83 @@
+package javassist.bytecode;
+
+import junit.framework.TestCase;
+import java.util.HashMap;
+
+public class SignatureAttributeTest extends TestCase {
+ public void test1() {
+ final String signature = "TX;TY;La/b/C$D$E$J$K;"; //a sequence of three ReferenceTypeSignature
+ final HashMap<String, String> map = new HashMap<>();
+ map.put("a/b/C$D$E$J$K", "o/p/Q$R$S$T$U");
+ map.put("e/F$G$H$I", "v/W$X$Y$Z");
+ final String signatureRenamed = SignatureAttribute.renameClass(signature, map);
+ assertEquals("TX;TY;Lo/p/Q$R$S$T$U;", signatureRenamed);
+ }
+
+ public void test2() {
+ final String signature = "La/b/C<TA;TB;>.D<Ljava/lang/Integer;>;"; //a ClassTypeSignature
+ final HashMap<String, String> map = new HashMap<>();
+ map.put("a/b/C$D", "o/p/Q$R");
+ map.put("java/lang/Integer", "java/lang/Long");
+ final String signatureRenamed = SignatureAttribute.renameClass(signature, map);
+ assertEquals("Lo/p/Q<TA;TB;>.R<Ljava/lang/Long;>;", signatureRenamed);
+ }
+
+ public void test3() {
+ final String signature = "BJLB<TX;Lc/D$E;>.F<TY;>;TZ;"; //a sequence of four JavaTypeSignature
+ final HashMap<String, String> map = new HashMap<>();
+ map.put("B$F", "P$T");
+ map.put("c/D$E", "q/R$S");
+ final String signatureRenamed = SignatureAttribute.renameClass(signature, map);
+ assertEquals("BJLP<TX;Lq/R$S;>.T<TY;>;TZ;", signatureRenamed);
+ }
+
+ public void test4() {
+ final String signature = "La/b/C<TX;>;[[Ld/E<+TY;-Ljava/lang/Object;*>;Z"; //a sequence of three JavaTypeSignature
+ final HashMap<String, String> map = new HashMap<>();
+ map.put("java/lang/Object", "java/util/Map");
+ map.put("d/E", "F");
+ final String signatureRenamed = SignatureAttribute.renameClass(signature, map);
+ assertEquals("La/b/C<TX;>;[[LF<+TY;-Ljava/util/Map;*>;Z", signatureRenamed);
+ }
+
+ public void test5() {
+ final String signature = "La/b/C$D$E<TX;Le/F$G<TY;TZ;>.H$I<TU;TV;>;>.J$K;"; //a ClassTypeSignature
+ final HashMap<String, String> map = new HashMap<>();
+ map.put("a/b/C$D$E$J$K", "o/p/Q$R$S$T$U");
+ map.put("e/F$G$H$I", "v/W$X$Y$Z");
+ final String signatureRenamed = SignatureAttribute.renameClass(signature, map);
+ assertEquals("Lo/p/Q$R$S<TX;Lv/W$X<TY;TZ;>.Y$Z<TU;TV;>;>.T$U;", signatureRenamed);
+ }
+
+ public void test6() {
+ final String signature = "<X:La/B$C<TY;>.D<TZ;>;:Le/F$G;>Lh/I$J;"; //a ClassSignature
+ final HashMap<String, String> map = new HashMap<>();
+ map.put("a/B$C$D", "o/P$Q$R");
+ map.put("e/F$G", "s/T$U");
+ map.put("h/I$J", "v/W$X");
+ final String signatureRenamed = SignatureAttribute.renameClass(signature, map);
+ assertEquals("<X:Lo/P$Q<TY;>.R<TZ;>;:Ls/T$U;>Lv/W$X;", signatureRenamed);
+ }
+
+ public void test7() {
+ final String signature = "<A:La/B$C;:Ld/E<TX;>.F<TY;>;:TZ;B:Ljava/lang/Thread;>(LX;TA;LA;)V^Ljava/lang/Exception;"; //a MethodSignature
+ final HashMap<String, String> map = new HashMap<>();
+ map.put("A", "P");
+ map.put("a/B$C", "s/T$U");
+ map.put("d/E$F", "v/W$X");
+ map.put("X", "V");
+ map.put("java/lang/Exception", "java/lang/RuntimeException");
+ final String signatureRenamed = SignatureAttribute.renameClass(signature, map);
+ assertEquals("<A:Ls/T$U;:Lv/W<TX;>.X<TY;>;:TZ;B:Ljava/lang/Thread;>(LV;TA;LP;)V^Ljava/lang/RuntimeException;", signatureRenamed);
+ }
+
+ public static void main(String[] s) {
+ new SignatureAttributeTest().test1();
+ new SignatureAttributeTest().test2();
+ new SignatureAttributeTest().test3();
+ new SignatureAttributeTest().test4();
+ new SignatureAttributeTest().test5();
+ new SignatureAttributeTest().test6();
+ new SignatureAttributeTest().test7();
+ }
+}
diff --git a/src/test/test2/AddCatchForConstructor.class b/src/test/test2/AddCatchForConstructor.class
deleted file mode 100644
index 9b5e937f..00000000
--- a/src/test/test2/AddCatchForConstructor.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/AddLocalVar.class b/src/test/test2/AddLocalVar.class
deleted file mode 100644
index ad5f1d94..00000000
--- a/src/test/test2/AddLocalVar.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/ArrayInit.class b/src/test/test2/ArrayInit.class
deleted file mode 100644
index 1786a0e6..00000000
--- a/src/test/test2/ArrayInit.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/ArrayLenTest.class b/src/test/test2/ArrayLenTest.class
deleted file mode 100644
index 0987cc07..00000000
--- a/src/test/test2/ArrayLenTest.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/ArrayLength.class b/src/test/test2/ArrayLength.class
deleted file mode 100644
index 9577874c..00000000
--- a/src/test/test2/ArrayLength.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Brennan.class b/src/test/test2/Brennan.class
deleted file mode 100644
index 9c7f3954..00000000
--- a/src/test/test2/Brennan.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/CodeGen.class b/src/test/test2/CodeGen.class
deleted file mode 100644
index 65c24e6c..00000000
--- a/src/test/test2/CodeGen.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/CodeGen2.class b/src/test/test2/CodeGen2.class
deleted file mode 100644
index fea25cc5..00000000
--- a/src/test/test2/CodeGen2.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/ConstBody.class b/src/test/test2/ConstBody.class
deleted file mode 100644
index 41175d14..00000000
--- a/src/test/test2/ConstBody.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/ConstField.class b/src/test/test2/ConstField.class
deleted file mode 100644
index 5f7a4d8b..00000000
--- a/src/test/test2/ConstField.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/DotClass.class b/src/test/test2/DotClass.class
deleted file mode 100644
index 6cc7a6bd..00000000
--- a/src/test/test2/DotClass.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/DotClass2.class b/src/test/test2/DotClass2.class
deleted file mode 100644
index aa67fb10..00000000
--- a/src/test/test2/DotClass2.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/DotClass4.class b/src/test/test2/DotClass4.class
deleted file mode 100644
index 48e51b7e..00000000
--- a/src/test/test2/DotClass4.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Finally.class b/src/test/test2/Finally.class
deleted file mode 100644
index f680dbc3..00000000
--- a/src/test/test2/Finally.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Imported.class b/src/test/test2/Imported.class
deleted file mode 100644
index 3ae65fdd..00000000
--- a/src/test/test2/Imported.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Importer.class b/src/test/test2/Importer.class
deleted file mode 100644
index 24da5de9..00000000
--- a/src/test/test2/Importer.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/IncOp.class b/src/test/test2/IncOp.class
deleted file mode 100644
index f75a9eb1..00000000
--- a/src/test/test2/IncOp.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Inherit.class b/src/test/test2/Inherit.class
deleted file mode 100644
index ef886ce1..00000000
--- a/src/test/test2/Inherit.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Inner.class b/src/test/test2/Inner.class
deleted file mode 100644
index d7506a62..00000000
--- a/src/test/test2/Inner.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Inner.java b/src/test/test2/Inner.java
index 15e08663..bfc95044 100644
--- a/src/test/test2/Inner.java
+++ b/src/test/test2/Inner.java
@@ -4,9 +4,8 @@ package test2;
public class Inner {
public void sample() throws Exception {
java.util.Properties props = new java.util.Properties();
- java.rmi.activation.ActivationGroupDesc.CommandEnvironment ace = null;
- java.rmi.activation.ActivationGroupDesc agd = new
- java.rmi.activation.ActivationGroupDesc(props,ace);
+ test2.Inner2.Child ace = null;
+ test2.Inner2 agd = new test2.Inner2(props, ace);
}
public static void main(String args[]) {
System.out.println("Inner");
diff --git a/src/test/test2/Inner2.java b/src/test/test2/Inner2.java
new file mode 100644
index 00000000..b9d81667
--- /dev/null
+++ b/src/test/test2/Inner2.java
@@ -0,0 +1,23 @@
+package test2;
+
+/**
+ * Used by test2.Inner
+ */
+public class Inner2 {
+ public static class Child {
+ public int value;
+ }
+
+ private java.util.Properties p;
+ private Child c;
+
+ public Inner2(java.util.Properties props, Child child) {
+ p = props;
+ c = child;
+ }
+
+ public void print() {
+ System.out.println(p);
+ System.out.println(c);
+ }
+}
diff --git a/src/test/test2/InsertAt.class b/src/test/test2/InsertAt.class
deleted file mode 100644
index b8194bae..00000000
--- a/src/test/test2/InsertAt.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/InsertLocal.class b/src/test/test2/InsertLocal.class
deleted file mode 100644
index d0f32f27..00000000
--- a/src/test/test2/InsertLocal.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/LocalVar.class b/src/test/test2/LocalVar.class
deleted file mode 100644
index a1d93574..00000000
--- a/src/test/test2/LocalVar.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/MakeStaticMethod.class b/src/test/test2/MakeStaticMethod.class
deleted file mode 100644
index 320f0f3a..00000000
--- a/src/test/test2/MakeStaticMethod.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/MethodCall.class b/src/test/test2/MethodCall.class
deleted file mode 100644
index 6b8fc153..00000000
--- a/src/test/test2/MethodCall.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Nested$Inner3.class b/src/test/test2/Nested$Inner3.class
deleted file mode 100644
index 21afc9a0..00000000
--- a/src/test/test2/Nested$Inner3.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Nested.class b/src/test/test2/Nested.class
deleted file mode 100644
index 529317ae..00000000
--- a/src/test/test2/Nested.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Nested2$Inner.class b/src/test/test2/Nested2$Inner.class
deleted file mode 100644
index 0267e5e5..00000000
--- a/src/test/test2/Nested2$Inner.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Nested2.class b/src/test/test2/Nested2.class
deleted file mode 100644
index 7cb3b346..00000000
--- a/src/test/test2/Nested2.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Nested3$Inner.class b/src/test/test2/Nested3$Inner.class
deleted file mode 100644
index dbc70b60..00000000
--- a/src/test/test2/Nested3$Inner.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Nested3.class b/src/test/test2/Nested3.class
deleted file mode 100644
index a1e2a736..00000000
--- a/src/test/test2/Nested3.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Nested4$Inner.class b/src/test/test2/Nested4$Inner.class
deleted file mode 100644
index b770ef79..00000000
--- a/src/test/test2/Nested4$Inner.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Nested4.class b/src/test/test2/Nested4.class
deleted file mode 100644
index 550fb403..00000000
--- a/src/test/test2/Nested4.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/NewArray.class b/src/test/test2/NewArray.class
deleted file mode 100644
index 9dfbbe63..00000000
--- a/src/test/test2/NewArray.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/NewExprInTry.class b/src/test/test2/NewExprInTry.class
deleted file mode 100644
index 79ca894a..00000000
--- a/src/test/test2/NewExprInTry.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/NewExprTry.class b/src/test/test2/NewExprTry.class
deleted file mode 100644
index f70141e6..00000000
--- a/src/test/test2/NewExprTry.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/NewOp.class b/src/test/test2/NewOp.class
deleted file mode 100644
index da62b7c3..00000000
--- a/src/test/test2/NewOp.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/NullArgTest.class b/src/test/test2/NullArgTest.class
deleted file mode 100644
index 79dd7195..00000000
--- a/src/test/test2/NullArgTest.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Remove.class b/src/test/test2/Remove.class
deleted file mode 100644
index d2bab30b..00000000
--- a/src/test/test2/Remove.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/RemoveCall.class b/src/test/test2/RemoveCall.class
deleted file mode 100644
index 1b818395..00000000
--- a/src/test/test2/RemoveCall.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/ReplaceClassName.class b/src/test/test2/ReplaceClassName.class
deleted file mode 100644
index db3611b3..00000000
--- a/src/test/test2/ReplaceClassName.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/SetExceptions.class b/src/test/test2/SetExceptions.class
deleted file mode 100644
index 2331eb9c..00000000
--- a/src/test/test2/SetExceptions.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/SetSuper.class b/src/test/test2/SetSuper.class
deleted file mode 100644
index 55861734..00000000
--- a/src/test/test2/SetSuper.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/SetSuperIntf.class b/src/test/test2/SetSuperIntf.class
deleted file mode 100644
index d5595567..00000000
--- a/src/test/test2/SetSuperIntf.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/SetSuperParent.class b/src/test/test2/SetSuperParent.class
deleted file mode 100644
index 2825d7d7..00000000
--- a/src/test/test2/SetSuperParent.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/StaticFinal.class b/src/test/test2/StaticFinal.class
deleted file mode 100644
index 69be9939..00000000
--- a/src/test/test2/StaticFinal.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/StaticMember.class b/src/test/test2/StaticMember.class
deleted file mode 100644
index 10a72092..00000000
--- a/src/test/test2/StaticMember.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/StaticMember2.class b/src/test/test2/StaticMember2.class
deleted file mode 100644
index fe46c673..00000000
--- a/src/test/test2/StaticMember2.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/SuperCall.class b/src/test/test2/SuperCall.class
deleted file mode 100644
index b7294c22..00000000
--- a/src/test/test2/SuperCall.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/SuperInterface3.class b/src/test/test2/SuperInterface3.class
deleted file mode 100644
index 4b6c7b73..00000000
--- a/src/test/test2/SuperInterface3.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Switch.class b/src/test/test2/Switch.class
deleted file mode 100644
index 78e8ea94..00000000
--- a/src/test/test2/Switch.class
+++ /dev/null
Binary files differ
diff --git a/src/test/test2/Synch.class b/src/test/test2/Synch.class
deleted file mode 100644
index c5a5ddd1..00000000
--- a/src/test/test2/Synch.class
+++ /dev/null
Binary files differ