Null pointer checks in event handler / filter registration methods

Lubomir Nerad lubomir.nerad at oracle.com
Fri Jan 13 07:12:01 PST 2012


Hi,

I am working on http://javafx-jira.kenai.com/browse/RT-18865 (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