--- old/src/java.desktop/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java 2016-07-22 11:53:29.442419004 -0700 +++ new/src/java.desktop/share/classes/javax/imageio/spi/ImageReaderWriterSpi.java 2016-07-22 11:53:29.302419006 -0700 @@ -604,14 +604,23 @@ } } + // If updating this method also see the same in IIOMetadata.java private Class getMetadataFormatClass(String formatClassName) { Module thisModule = ImageReaderWriterSpi.class.getModule(); Module targetModule = this.getClass().getModule(); - Class c = Class.forName(targetModule, formatClassName); + Class c = null; + try { + ClassLoader cl = this.getClass().getClassLoader(); + c = Class.forName(formatClassName, false, cl); + if (!IIOMetadataFormat.class.isAssignableFrom(c)) { + return null; + } + } catch (ClassNotFoundException e) { + } if (thisModule.equals(targetModule) || c == null) { return c; } - if (thisModule.isNamed()) { + if (targetModule.isNamed()) { int i = formatClassName.lastIndexOf("."); String pn = i > 0 ? formatClassName.substring(0, i) : ""; if (!targetModule.isExported(pn, thisModule)) {