I am a big fan of Intellij IDEA and the command line :
>sh build.sh clean >sh build.sh deploy >etc...
bah - chmod 700 on build.sh and add an alias :)
You don't want to use finalize() it isn't guaranteed to be called and even if does get
called, it wrecks gc performance.
A real solution would be to do caller side analysis/weaving:
POJOResource pr = new POJOResource;
becomes (pseudo code)
POJOResource pr = POJOResourceManager.get();
But this requires a fair bit of analysis of the bytecode.
A simpler solution would be to assume the resource has a close() method
and that it is called by the client. You would just identify the close operation
in the metadata.
The handles are just "proxies".