--- old/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java 2016-04-15 18:49:48.000000000 +0400 +++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java 2016-04-15 18:49:48.000000000 +0400 @@ -554,7 +554,7 @@ @Override public Image getImage(URL url) { - if (imageCached(url)) { + if (url == null || imageCached(url)) { return super.getImage(url); } --- old/src/java.desktop/share/classes/sun/awt/SunToolkit.java 2016-04-15 18:49:49.000000000 +0400 +++ new/src/java.desktop/share/classes/sun/awt/SunToolkit.java 2016-04-15 18:49:49.000000000 +0400 @@ -659,7 +659,7 @@ static Image getImageFromHash(Toolkit tk, URL url) { checkPermissions(url); synchronized (urlImgCache) { - String key = url.toString(); + String key = (url == null) ? null : url.toString(); Image img = (Image)urlImgCache.get(key); if (img == null) { try { --- /dev/null 2016-04-15 18:49:50.000000000 +0400 +++ new/test/java/awt/image/ToolkitImage/ToolkitGetNullImageTest.java 2016-04-15 18:49:50.000000000 +0400 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Toolkit; +import java.net.URL; + +/* + * @test + * @bug 8132706 + * @summary [macosx] Toolkit.getImage() throws NPE for null URL + * @run main ToolkitGetNullImageTest + */ +public class ToolkitGetNullImageTest { + + public static void main(String[] args) { + + Toolkit.getDefaultToolkit().getImage((String) null); + Toolkit.getDefaultToolkit().getImage((URL) null); + } +}