/**
   * Changes a super constructor called by this constructor.
   *
   * <p>This method modifies a call to <code>super()</code>, which should be at the head of a
   * constructor body, so that a constructor in a different super class is called. This method does
   * not change actural parameters. Hence the new super class must have a constructor with the same
   * signature as the original one.
   *
   * <p>This method should be called when the super class of the class declaring this method is
   * changed.
   *
   * <p>This method does not perform anything unless this <code>MethodInfo</code> represents a
   * constructor.
   *
   * @param superclass the new super class
   */
  public void setSuperclass(String superclass) throws BadBytecode {
    if (!isConstructor()) return;

    CodeAttribute ca = getCodeAttribute();
    byte[] code = ca.getCode();
    CodeIterator iterator = ca.iterator();
    int pos = iterator.skipSuperConstructor();
    if (pos >= 0) { // not this()
      ConstPool cp = constPool;
      int mref = ByteArray.readU16bit(code, pos + 1);
      int nt = cp.getMethodrefNameAndType(mref);
      int sc = cp.addClassInfo(superclass);
      int mref2 = cp.addMethodrefInfo(sc, nt);
      ByteArray.write16bit(mref2, code, pos + 1);
    }
  }