Browse Source

minor bug fixes


git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@319 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
tags/rel_3_17_1_ga
chiba 18 years ago
parent
commit
a0860e0b8c
2 changed files with 42 additions and 4 deletions
  1. 36
    0
      src/main/javassist/ClassMap.java
  2. 6
    4
      src/main/javassist/CtBehavior.java

+ 36
- 0
src/main/javassist/ClassMap.java View File

@@ -61,12 +61,21 @@ public class ClassMap extends java.util.HashMap {

/**
* Maps a class name to another name in this hashtable.
* If the hashtable contains another mapping from the same
* class name, the old mapping is replaced.
* This method translates the given class names into the
* internal form used in the JVM before putting it in
* the hashtable.
*
* <p>If <code>oldname</code> is equivalent to
* <code>newname</code>, then this method does not
* perform anything; it does not record the mapping from
* <code>oldname</code> to <code>newname</code>. See
* <code>fix</code> method.
*
* @param oldname the original class name
* @param newname the substituted class name.
* @see #fix(String)
*/
public void put(String oldname, String newname) {
if (oldname == newname)
@@ -78,6 +87,33 @@ public class ClassMap extends java.util.HashMap {
super.put(oldname2, toJvmName(newname));
}

/**
* Maps a class name to another name unless another mapping
* has been already recorded.
* This method translates the given class names into the
* internal form used in the JVM before putting it in
* the hashtable.
*
* <p>If <code>oldname</code> is equivalent to
* <code>newname</code>, then this method does not
* perform anything; it does not record the mapping from
* <code>oldname</code> to <code>newname</code>. See
* <code>fix</code> method.
*
* @param oldname the original class name
* @param newname the substituted class name.
* @see #fix(String)
*/
public void add(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);
}

+ 6
- 4
src/main/javassist/CtBehavior.java View File

@@ -47,18 +47,20 @@ public abstract class CtBehavior extends CtMember {
if (map == null)
map = new ClassMap();

map.put(srcClass.getName(), declaring.getName());
map.add(srcClass.getName(), declaring.getName());
try {
boolean patch = false;
CtClass srcSuper = srcClass.getSuperclass();
String destSuperName = declaring.getSuperclass().getName();
if (srcSuper != null) {
CtClass destSuper = declaring.getSuperclass();
String destSuperName = null;
if (srcSuper != null && destSuper != null) {
String srcSuperName = srcSuper.getName();
destSuperName = destSuper.getName();
if (!srcSuperName.equals(destSuperName))
if (srcSuperName.equals(CtClass.javaLangObject))
patch = true;
else
map.put(srcSuperName, destSuperName);
map.add(srcSuperName, destSuperName);
}

methodInfo = new MethodInfo(cp, srcInfo.getName(), srcInfo, map);

Loading…
Cancel
Save