Null pointer checks in event handler / filter registration methods

Richard Bair richard.bair at
Fri Jan 13 07:21:50 PST 2012

I think you are fine, sounds like a bug to me as opposed to a change in intent. I'm assuming you will update the docs to indicate null is not allowed. If somebody binds onMouseClicked to null, that should not thrown exception but just unregister any previous handler and not register a new one, right?


On Jan 13, 2012, at 7:12 AM, Lubomir Nerad <lubomir.nerad at> wrote:

> Hi,
> I am working on (Adding null event handlers is allowed - later leads to NPE). To fix it I want to add null checks (with NPE throws) for event type and event handler or filter to the addEventHandler, removeEventHandler, addEventFilter and removeEventFilter methods of Node, Scene, Window, Task, Service, MenuItem, TableColumn and TreeItem. Passing null event type or event handler / filter to these methods clearly indicates programmer's error and so should be reported early. Failure to do that may result in an exception later in program execution which cause is then hard to guess.
> I don't know whether this change requires an explicit approval, but previously javadoc for these methods didn't specify possible NPE and so the API behavior will change in this respect.
> Thanks,
> Lubo

More information about the openjfx-dev mailing list