diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2003-08-22 17:25:14 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2003-08-22 17:25:14 +0000 |
commit | fe122bdfe25febcb190a9e91a07eb3c3268d1e75 (patch) | |
tree | 00a7aecb34be6bcb2435649e4ecdbcbceadb3bb6 /src/main/javassist | |
parent | c8eb33fc60e880e0f8c75d442fa6df7660c87939 (diff) | |
download | javassist-fe122bdfe25febcb190a9e91a07eb3c3268d1e75.tar.gz javassist-fe122bdfe25febcb190a9e91a07eb3c3268d1e75.zip |
changed the behavior of CtClassType.setSuperclass().
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@35 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist')
-rw-r--r-- | src/main/javassist/bytecode/ClassFile.java | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/src/main/javassist/bytecode/ClassFile.java b/src/main/javassist/bytecode/ClassFile.java index 3fc6fdb6..c1b99257 100644 --- a/src/main/javassist/bytecode/ClassFile.java +++ b/src/main/javassist/bytecode/ClassFile.java @@ -171,46 +171,26 @@ public final class ClassFile { /** * Sets the super class. * - * <p>Unless the old super class is - * <code>java.lang.Object</code>, this method substitutes the new name - * for all occurrences of the old class name in the class file. - * If the old super class is <code>java.lang.Object</code>, - * only the calls to a super constructor are modified. + * <p>This method modifies constructors so that they call + * constructors declared in the new super class. */ public void setSuperclass(String superclass) throws CannotCompileException { - if (constPool.getClassInfo(superClass).equals("java.lang.Object")) { - if (superclass != null) - try { - superClass = constPool.addClassInfo(superclass); - setSuperclass2(superclass); - } - catch (BadBytecode e) { - throw new CannotCompileException(e); - } - } - else { - if (superclass == null) - superclass = "java.lang.Object"; + if (superclass == null) + superclass = "java.lang.Object"; - renameClass(constPool.getClassInfo(superClass), superclass); + try { + superClass = constPool.addClassInfo(superclass); + LinkedList list = methods; + int n = list.size(); + for (int i = 0; i < n; ++i) { + MethodInfo minfo = (MethodInfo)list.get(i); + minfo.setSuperclass(superclass); + } } - } - - /* If the original super class is java.lang.Object, a special - * treatment is needed. Some occurrences of java.lang.Object - * in the class file should not be changed into the new super - * class name. For example, the call of Vector.addElement(Object) - * should not be changed into the call of Vector.addElement(X), - * where X is the new super class. - */ - private void setSuperclass2(String superclass) throws BadBytecode { - LinkedList list = methods; - int n = list.size(); - for (int i = 0; i < n; ++i) { - MethodInfo minfo = (MethodInfo)list.get(i); - minfo.setSuperclass(superclass); + catch (BadBytecode e) { + throw new CannotCompileException(e); } } |