JDK-8250224 : Proxy::newProxyInstance spec should specify the behavior if a given proxy interface is hidden
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 16
  • Submitted: 2020-07-23
  • Updated: 2020-07-28
  • Resolved: 2020-07-28
Related Reports
CSR :  
Description
Summary
-------

Update the spec of `Proxy::newProxyInstance` to specify `IllegalArgumentException thrown if a given proxy interface is hidden.

Problem
-------

The current spec of `Proxy::newProxyInstance` throws IAE if a given proxy interface cannot be found by the given class loader.   This covers for the case of a hidden proxy interface since it is not discoverable by any class loader.  It should explicitly list in the [restrictions](https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/reflect/Proxy.html#restrictions) section that the given interfaces must be non-hidden interfaces.

Solution
--------

Update the spec of  `Proxy::newProxyInstance` to require all proxy interfaces be non-hidden.   There is no behavioral change.  The current implementation already throws IAE if any one of the given interfaces is hidden.

Specification
-------------

Update the spec of `Proxy::newProxyInstance`

```
      * <a id="restrictions">{@code IllegalArgumentException} will be thrown
      * 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.
```


Comments
Moving to Approved; thanks for the clarification.
28-07-2020