[OpenJDK 2D-Dev] [9] RFR: JDK-8154057, , [macosx] getPrintJob doesn't throw NPE if Frame is null AND type is COMMON

prasanta sadhukhan prasanta.sadhukhan at oracle.com
Wed Apr 13 08:13:08 UTC 2016


Hi Phil,

Yes, it seems code does not use this frame as parent/owner.
Actually, xxxToolkit will call initPrintJob2D() after checking for 
frame==null, followed by PrintJob2D.printDialog() which will just store 
the frame in the attribute
if (frame != null) {
              attributes.add(new DialogOwner(frame));
          }
and then call ServiceUI.printDialog()
which just pass null as owner to ServiceDialog() for now.

// For now we set owner to null. In the future, it may be passed
         // as an argument.
         Window owner = null;

dialog = new ServiceDialog(gc,
                                        x,
                                        y,
                                        services, defaultIndex,
                                        flavor, attributes,
                                        (Dialog)owner);
and so this behaviour is common to all platforms.

I guess we should populate WIndow owner with this frame object.

But since this NPE problem is specific to mac,can we fix this bug first
as the other platforms has same null check code in Toolkit.getPrintJob() 
and create another bug for this frame usage. Please let me know your 
thoughts.

BTW,
It was not seen (ie NPE is thrown) for native dialog in mac as in 
initPrintJob2D() we have this check
if (frame == null &&
             (jobAttributes == null ||
              jobAttributes.getDialog() == DialogType.NATIVE)) {
             throw new NullPointerException("Frame must not be null");
         }

Regards
Prasanta
On 4/12/2016 10:43 PM, Phil Race wrote:
> hmm .. if it does not throw NPE when the dialog type is common that 
> could mean
> that the code is not referencing the frame as a modal parent /owner in 
> that case which could
> be another bug.
> Did you check into how this is used relative to other platforms ?
>
> -phil.
>
>
> On 04/12/2016 04:16 AM, prasanta sadhukhan wrote:
>> Hi All,
>>
>> Please review a fix for jdk9.
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8154057
>> webrev: http://cr.openjdk.java.net/~psadhukhan/8154057/webrev.00/
>>
>> As per spec, Toolkit.getPrintJob() should throw NPE if null frame 
>> object is passed to it.
>> But on macos, it seems getPrintJob() does not check for null frame 
>> and show the print dialog.
>>
>> Fix is to check for null frame which is same as what we do in windows 
>> (WToolkit) and linux (XToolkit).
>>
>> Regards
>> Prasanta
>




More information about the 2d-dev mailing list