Can someone explain the java/clojure code in the article? I'm assuming the jvm is able to make some sort of optimization because o was set to null which it wouldn't have been able to do otherwise?
The code clears the stack slot for the count method argument. If the object referenced by the argument is not referenced elsewhere, then the object is eligible for gc during the execution of the count method. In the case where the argument is a lazy sequence, this changes the memory requirement from the entire realized sequence to a single item in the sequence.
This trick is employed everywhere in the Clojure implementation where a lazy sequence might be retained. It's not specific to the count function.