I found a bad synchronization idiom in a couple of the QA test programs for outrigger. I've done what I can to grep for it, but be alert in case it shows up in code you are reading.

A non-final class needs to assign a unique number to each object of the class, or any of its direct or indirect subclasses:

// Declared in the class
private static int nextID=0;

// Inside a constructor, or a method called from the constructor
synchronized(getClass()){
  id = nextID++;
}

The synchronization is ineffective, because getClass() can return different Class objects in a non-final class' constructor.

Patricia



Reply via email to