8250219: Proxy::newProxyInstance spec should specify the behavior if a given proxy interface is hidden

Reviewed-by: alanb
This commit is contained in:
Mandy Chung 2020-08-04 10:36:02 -07:00
parent 38af8be984
commit f4de95a97c
2 changed files with 74 additions and 7 deletions

View file

@ -674,12 +674,6 @@ public class Proxy implements java.io.Serializable {
{
Map<Class<?>, 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:</a>
* <ul>
* <li>All of {@code Class} objects in the given {@code interfaces} array
* must represent interfaces, not classes or primitive types.
* must represent {@linkplain Class#isHidden() non-hidden} interfaces,
* not classes or primitive types.
*
* <li>No two elements in the {@code interfaces} array may
* refer to identical {@code Class} objects.