RFR: 8319436: Proxy.newProxyInstance throws NPE if loader is null and interface not visible from class loader

Mandy Chung mchung at openjdk.org
Mon Nov 6 20:02:29 UTC 2023


On Mon, 6 Nov 2023 19:46:40 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> This is a regression caused by JDK-8302791.   IAE should be thrown when an interface is not visible to the given class loader but NPE is thrown instead when the loader is null.   The boot loader has no name and so the fix will print `null` in the exception message.   `test/jdk/java/lang/reflect/Proxy/ClassRestrictions.java` is converted to junit and updated to test IAE thrown because proxy interface is not visible to null loader.
>
> test/jdk/java/lang/reflect/Proxy/ClassRestrictions.java line 90:
> 
>> 88:         } catch (IllegalArgumentException e) {
>> 89:             System.err.println(e.getMessage());
>> 90:             // assume exception is for intended failure
> 
> The "throw new Error(message)" could be replaced with fail(message) or use assertThrows(IllegalArgument.class, () -> Proxy.getProxyClass(...)).

Will do.  I should clean up more of the existing code.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16525#discussion_r1383905730


More information about the core-libs-dev mailing list