Do Java8 lambdas maintain a reference to their enclosing instance like anonymous classes?

Lambda expressions and method references capture a reference to this only if required, i.e. when this is referenced directly or an instance (non-static) member is accessed.

Of course, if your lambda expression captures the value of a local variable and that value contains a reference to this it implies referencing this as well…

Leave a Comment