/**
* 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)
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);
}
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);