[kaffe] Bug in ThreadGroup

Hervé Roussain Herve.Roussain@univ-ubs.fr
Tue Apr 8 17:07:04 2003


This is a multi-part message in MIME format.
--------------020502080108060402030806
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi!

The 'parentOf' method doesn't work

Here's the output of the test, using JDK 1.3 and Kaffe CVS:

roussain@shiva:~/java-tests$ sun-java ThreadGroupTest
daddy.parentOf(child)=true
child.parentOf(daddy)=false
roussain@shiva:~/java-tests$ kaffe ThreadGroupTest
daddy.parentOf(child)=true
child.parentOf(daddy)=true

The method is
final public boolean parentOf(ThreadGroup g) {
         return ((parent == g) || (parentOf(g.getParent())));
}

but should be something like this:
final public boolean parentOf(ThreadGroup g) {
         return (g != null && this == g.getParent())
                 || parentOf(g.getParent());
}

Best regards,
Hervé

--------------020502080108060402030806
Content-Type: text/x-java;
 name="ThreadGroupTest.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ThreadGroupTest.java"

class ThreadGroupTest {
  public static void main(String[] args) {
    ThreadGroup daddy = new ThreadGroup("daddy");
    ThreadGroup child = new ThreadGroup(daddy, "child");
    System.out.println("daddy.parentOf(child)=" + daddy.parentOf(child));
    System.out.println("child.parentOf(daddy)=" + child.parentOf(daddy));
  }
}


--------------020502080108060402030806--