8140314: Verify IIOMetadataFormat class on loading
Reviewed-by: bpb
This commit is contained in:
parent
13f9c0a307
commit
f3b4127564
@ -414,14 +414,23 @@ public abstract class IIOMetadata {
|
||||
}
|
||||
}
|
||||
|
||||
// If updating this method also see the same in ImageReaderWriterSpi.java
|
||||
private Class<?> getMetadataFormatClass(String formatClassName) {
|
||||
Module thisModule = IIOMetadata.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)) {
|
||||
|
@ -604,14 +604,23 @@ public abstract class ImageReaderWriterSpi extends IIOServiceProvider {
|
||||
}
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
|
@ -22,7 +22,7 @@
|
||||
#
|
||||
|
||||
# @test
|
||||
# @bug 8081729
|
||||
# @bug 8081729 8140314
|
||||
# @summary Test external plugin as classpath jar and as a modular jar.
|
||||
# Test both cases with and without a security manager.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user