Affects Version/s: Release 1.3
Fix Version/s: None
Environment:OS X, Java 1.6.0?
It appears to be impossible to override Object.finalize() using proxy. If the method is defined using proxy, then it cannot be called straightforwardly (see below), and it is not called as a finalizer during normal program execution (not demonstrated below).
See extensive discussion at: https://groups.google.com/group/clojure/browse_thread/thread/a1e2fca45af6c1af
user=> (def m (proxy [java.util.HashMap] 
user=> (.hashCode m)
user=> (.finalize m)
IllegalArgumentException No matching field found: finalize for class user.proxy$java.util.HashMap$0 clojure.lang.Reflector.getInstanceField (Reflector.java:289)
There is at least one of two bugs here (thanks to Cedric Greevey for summarising this way):
- If the inability to override finalize() is unintentional, that's a bug.
- If it's intentional for some reason, then (a) that's not documented, and (b) the failure is silent, in the sense that an explicit call produces an apparently completely unrelated error (above), and the failure to call the method during object finalization is completely silent.