Event Handlers with Method References (original) (raw)

Brian Goetz brian.goetz at oracle.com
Sun Apr 1 07:23:40 PDT 2012


with some EventDispatcherImpl implementation that e.g. holds a List and dispatches to each in turn. Of course, for the reasons discussed in the lambda equality thread, in a real implementation we'd want to return a handle object from addEventHandler() so we can remove event handlers again later - but let's not worry about that for now.

Or just save the handler object you pass in. (This is not a new problem; we have exactly the same problem when using anonymous classes for listeners.)

Then I take it that this::onTemperatureChange is exactly equivalent to the lambda: (e) -> { onTemperatureChange(e);}

Correct. Method references can be thought of as shorthands for corresponding lambdas:

Foo::staticMethod ==> (args) -> staticMethod(args) Foo::instanceMethod ==> (arg0, rest) -> arg0.instanceMethod(rest) expr::instanceMethod ==> (args) -> expr.instanceMethod(args)

My question is, I'm using Henri Gomez's most recent Lambda build for OS X. I'm getting fairly regular (but not every time) crashes when running javadoc over TemperatureHandler (and occasional javac crashes as well) - is there a group that would be interested in the crash reports, or are we still expecting javac / javadoc to be inconsistently stable?

Yes! Post it here.



More information about the lambda-dev mailing list