summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2007-07-14 08:53:57 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2007-07-14 08:53:57 +0000
commit82e918f2e4d778e8de26f76da73275fce226e366 (patch)
treee040b2ffe1647bd631058edaebdd3a877d9975e8
parent46900e9c1fbf7d34ab649d0ca53c1821e4c8c210 (diff)
downloadjavassist-82e918f2e4d778e8de26f76da73275fce226e366.tar.gz
javassist-82e918f2e4d778e8de26f76da73275fce226e366.zip
changed CtMethod#copy() and updated related javadoc comments
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@396 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
-rw-r--r--src/main/javassist/ClassMap.java21
-rw-r--r--src/main/javassist/CtBehavior.java2
-rw-r--r--src/main/javassist/CtConstructor.java3
-rw-r--r--src/main/javassist/CtMethod.java3
4 files changed, 25 insertions, 4 deletions
diff --git a/src/main/javassist/ClassMap.java b/src/main/javassist/ClassMap.java
index 98e5cc9e..28f646f0 100644
--- a/src/main/javassist/ClassMap.java
+++ b/src/main/javassist/ClassMap.java
@@ -82,7 +82,7 @@ public class ClassMap extends java.util.HashMap {
* <code>oldname</code> to <code>newname</code>. See
* <code>fix</code> method.
*
- * @param oldname the original class name
+ * @param oldname the original class name.
* @param newname the substituted class name.
* @see #fix(String)
*/
@@ -96,6 +96,25 @@ public class ClassMap extends java.util.HashMap {
super.put(oldname2, toJvmName(newname));
}
+ /**
+ * Is equivalent to <code>put()</code> except that
+ * the given mapping is not recorded into the hashtable
+ * if another mapping from <code>oldname</code> is
+ * already included.
+ *
+ * @param oldname the original class name.
+ * @param newname the substituted class name.
+ */
+ public void putIfNone(String oldname, String newname) {
+ if (oldname == newname)
+ return;
+
+ String oldname2 = toJvmName(oldname);
+ String s = (String)get(oldname2);
+ if (s == null)
+ super.put(oldname2, toJvmName(newname));
+ }
+
protected final void put0(Object oldname, Object newname) {
super.put(oldname, newname);
}
diff --git a/src/main/javassist/CtBehavior.java b/src/main/javassist/CtBehavior.java
index 2be691f3..bcae803f 100644
--- a/src/main/javassist/CtBehavior.java
+++ b/src/main/javassist/CtBehavior.java
@@ -59,7 +59,7 @@ public abstract class CtBehavior extends CtMember {
if (srcSuperName.equals(CtClass.javaLangObject))
patch = true;
else
- map.put(srcSuperName, destSuperName);
+ map.putIfNone(srcSuperName, destSuperName);
}
// a stack map table is copied from srcInfo.
diff --git a/src/main/javassist/CtConstructor.java b/src/main/javassist/CtConstructor.java
index 54c89669..e457eb2e 100644
--- a/src/main/javassist/CtConstructor.java
+++ b/src/main/javassist/CtConstructor.java
@@ -74,7 +74,8 @@ public final class CtConstructor extends CtBehavior {
* with the name of the class and the superclass that
* the created constructor is added to.
* This is done whichever <code>map</code> is null or not.
- * To prevent this replacement, call <code>ClassMap.fix()</code>.
+ * To prevent this replacement, call <code>ClassMap.fix()</code>
+ * or <code>put()</code> to explicitly specify replacement.
*
* <p><b>Note:</b> if the <code>.class</code> notation (for example,
* <code>String.class</code>) is included in an expression, the
diff --git a/src/main/javassist/CtMethod.java b/src/main/javassist/CtMethod.java
index 3ed6aa77..0c85783d 100644
--- a/src/main/javassist/CtMethod.java
+++ b/src/main/javassist/CtMethod.java
@@ -83,7 +83,8 @@ public final class CtMethod extends CtBehavior {
* with the name of the class and the superclass that the
* created method is added to.
* This is done whichever <code>map</code> is null or not.
- * To prevent this replacement, call <code>ClassMap.fix()</code>.
+ * To prevent this replacement, call <code>ClassMap.fix()</code>
+ * or <code>put()</code> to explicitly specify replacement.
*
* <p><b>Note:</b> if the <code>.class</code> notation (for example,
* <code>String.class</code>) is included in an expression, the