question: public static CloseWatcher register ( Object o , Closeable closeable , boolean stackTrace ) { ReferenceQueue < Object > q = queue ; if ( q == null ) { q = new ReferenceQueue < Object > ( ) ; queue = q ; } CloseWatcher cw = new CloseWatcher ( o , q , closeable ) ; if ( stackTrace ) { Exception e = new Exception ( "Open Stack Trace" ) ; StringWriter s = new StringWriter ( ) ; e . printStackTrace ( new PrintWriter ( s ) ) ; cw . openStackTrace = s . toString ( ) ; } if ( refs == null ) { refs = createSet ( ) ; } refs . add ( cw ) ; return cw ; }
target:  Register an object. Before calling this method, pollUnclosed() should be called in a loop to remove old references.