If it ever happens that an object with a non-trivial finalizer is optimized
away, that would be a serious JDK bug, so I would remove the constructor
code for MyObject (what are you protecting against?).  See my sample code
in previous msg.

WeakReference<?> ref = new WeakReference<Object>(new Object() {
             protected void finalize() { finalizeDone.countDown(); }});

  43         public MyObject() {
  44             /* Make sure object allocation/deallocation is not
optimized out */
  45             wasInitialized = true;
  46         }

Reply via email to