Why are all Group methods final?

I noticed that most if not all of the methods defined in the Group object are declared final. Why on earth is that?

I’m working on translating some animation code I wrote in Java3D to Xith3D, and in the Java3D version I relied on overriding the addChild() method of Group. I created an AnimatedGroup object that was a child of Group, and then also had Animation objects that are children of Node. When an Animation object is added to an AnimatedGroup object, I want to call some additional methods on that Animation object along with adding it to the group.

My AnimatedGroup.addChild() method looked like this:


public void addChild(Node node) {
  if (node instanceof Animation) {
    ... do stuff to animation object ...
  }
  super.addChild(node);
}

Obviously this doesn not work when addChild() is declared as final in the Group object. I suppose I could write a addAnimation() wrapper method in AnimatedGroup, but it looks sloppy to me. Is there a good reason that Group has all these methods declared as final?

Paul

I am not sure, it certainly is not a Java3D thing:

http://java.sun.com/products/java-media/3D/forDevelopers/J3D_1_3_API/j3dapi/javax/media/j3d/Group.html#addChild(javax.media.j3d.Node)

Will.

Hi,

After reviewing the current implementation of addChild() and other methods declared in Group, I see no reason of why they made final. This may come to the original design idea of David, but I do not see any problem to change this except that I can estimate increasing number of support request from new and mid users trying to extend Group, Node etc. - I would place BIG poster “Extend nodes on your own risk” before changing this, but, again, if you think we should change this, no pbs.

[OK, Java3D porting compatibility is a good reason]

Yuri