--- old/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java 2019-02-06 14:45:50.000000000 +0530 +++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java 2019-02-06 14:45:49.000000000 +0530 @@ -208,11 +208,13 @@ CImage cimage = CImage.getCreator().createFromImage(image, observer); boolean imageAutoSize = target.isImageAutoSize(); - cimage.execute(imagePtr -> { - execute(ptr -> { - setNativeImage(ptr, imagePtr, imageAutoSize); + if (cimage != null) { + cimage.execute(imagePtr -> { + execute(ptr -> { + setNativeImage(ptr, imagePtr, imageAutoSize); + }); }); - }); + } } private native void setNativeImage(final long model, final long nsimage, final boolean autosize); @@ -357,7 +359,7 @@ class IconObserver implements ImageObserver { @Override public boolean imageUpdate(Image image, int flags, int x, int y, int width, int height) { - if (image != target.getImage()) // if the image has been changed + if (target == null || image != target.getImage()) //if the image has been changed { return false; }