Community
Participate
Working Groups
Color, Cursor, Font, Image. Constructors all take a device, which is technically not supposed to be null. Except that we had to allow null for now (or else break lots of code). So if the app passes in null for the device, we use the current device (the display). If we ever figure out what we want to do here, we need to fix all of the graphics constructors that take device so that they 'fess up to the nullpointer exception, i.e. something like: * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if device is null [and there is no current device]</li> * </ul> NOTES:
PRODUCT VERSION: 0.9
SN to ensure the required discussion happens... Look for RFC template.
I don't think we can change this ever (I'm sorry). Go ask Silenio. Do we silently take null now?
Here is the typical code pattern: if (device == null) device = Device.getDevice(); if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); So quite likely, we will never throw. But it looks like we could.
I think we cannot remove the line below anymore (argh!!), but we should mention in the comment that we are going to throw ERROR_NULL_ARGUMENT if the device is null and we cannot get the default. Maybe people will stop passing null, when they see the comment. if (device == null) device = Device.getDevice();
This has been documented by CAR.