addComponent and setParent: inapplicability?

Good day!
Could you look at the AbstractComponentContainer::addComponent code:


...
 if (c.getParent() != null) {
   // If the component already has a parent, try to remove it
    ComponentContainer oldParent = (ComponentContainer) c.getParent();
    oldParent.removeComponent(c);
}
c.setParent(this);
...

Everything is ok - if the c component has a parent, remove one from the parent and then set the new parent.
But if the c component has a parent, the following AbstactComponent::setParent will always fail:


...
    // If the parent is not changed, don't do anything
    if (parent == this.parent) {
        return;
     }
     if (parent != null && this.parent != null) {
        throw new IllegalStateException(getClass().getName()
           + " already has a parent.");
      }
...

Could you please answer it is by design?

Thanks in advance,
Anatoly.

Ops: it is works because of removeComponent:


   public void removeComponent(Component c) {
        if (c.getParent() == this) {
            c.setParent(null);
            fireComponentDetachEvent(c);
        }
    }