: eval 'exec perl -w -S `echo $0 | sed "s/.*\///" ` ${1+"$@"}' if 0; @a=@ARGV; @flags=grep(/^-/,@a); @other=(); @other=grep(!/^-/,@a); if ( grep( /^-h(elp)?$/,@flags) || scalar(@other) != 1) { $scriptName = $0; $scriptName =~ s%^.*/%%; print <<"END"; Usage: $scriptName [-h -help] Class Print out a prototype of a new java class that implements finalize(). END exit;} $rN="\n"; $rN="\n" if ( ! -d "/var" ); $Class=$a[0]; print <<"END"; public class $Class { /** Call this method when you are finished with the object to free resources */ public synchronized void dispose() { if(!_isNull) { _isNull = true; // free resources here } } /* Call the dispose() method explicitly to free resources. This finalize method may never be called by the garbage collector. */ \@Override protected void finalize() throws Throwable { try {dispose();} finally {super.finalize();} } /* Check the value of _isNull internally if you fear someone will try to use the object after it is disposed */ private boolean _isNull = false; } END