Are all final variables captured by anonymous classes?
I thought I knew the answer to this, but I can't find any confirmation after an hour or so of searching. In this code: public class Outer { // other code private void method1() { final SomeObject obj1 = new SomeObject(...); final SomeObject obj2 = new SomeObject(...); someManager.registerCallback(new SomeCallbackClass() { @Override public void onEvent() { System.out.println(obj1.getName()); } }); } } Assume that registerCallback saves its parameter somewhere, so that the object of the anonymous subclass will live for a while. Obviously this object has to maintain a reference to obj1 so that