diff --git a/src/java.base/share/classes/java/lang/reflect/Proxy.java b/src/java.base/share/classes/java/lang/reflect/Proxy.java index 1a2d7f668ab..2f2ec3bba34 100644 --- a/src/java.base/share/classes/java/lang/reflect/Proxy.java +++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java @@ -674,12 +674,6 @@ public class Proxy implements java.io.Serializable { { Map, Boolean> interfaceSet = new IdentityHashMap<>(interfaces.size()); for (Class intf : interfaces) { - /* - * Verify that the class loader resolves the name of this - * interface to the same Class object. - */ - ensureVisible(loader, intf); - /* * Verify that the Class object actually represents an * interface. @@ -688,6 +682,16 @@ public class Proxy implements java.io.Serializable { throw new IllegalArgumentException(intf.getName() + " is not an interface"); } + if (intf.isHidden()) { + throw new IllegalArgumentException(intf.getName() + " is a hidden interface"); + } + + /* + * Verify that the class loader resolves the name of this + * interface to the same Class object. + */ + ensureVisible(loader, intf); + /* * Verify that this interface is not a duplicate. */ @@ -905,7 +909,8 @@ public class Proxy implements java.io.Serializable { * if any of the following restrictions is violated: *