Missing throws declaration for NullPointerException in Proxy#getInvocationHandler

Chen Liang chen.l.liang at oracle.com
Thu May 22 20:06:14 UTC 2025


Hello, I have created https://bugs.openjdk.org/browse/JDK-8357597 for this.
Your analysis isn't quite correct - if you look at the method documentation, you would anticipate this to fail with an IllegalArgumentException instead of a NullPointerException. However, this mismatch has been there since 2006, so it's best to update the docs to match the actual longstanding behavior.
P.S. In the future, you can also report bugs via https://bugs.java.com/

Regard, Chen
________________________________
From: core-libs-dev <core-libs-dev-retn at openjdk.org> on behalf of Steffen Nießing <zuniquex at protonmail.com>
Sent: Thursday, May 22, 2025 1:12 PM
To: core-libs-dev at openjdk.org <core-libs-dev at openjdk.org>
Subject: Missing throws declaration for NullPointerException in Proxy#getInvocationHandler

Hi,

recently I've come across the documentation of Proxy#getInvocationHandler(Object) and recognized that there's a missing throws declaration for a NullPointerException. The expression Proxy.getInvocationHandler(null) fails, because proxy.getClass() is called without asserting that proxy is not null.

I'd be happy to provide the JavaDoc update, if anyone would like to sponsor me the JBS issue for this one.

Cheers
Steffen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20250522/2866d211/attachment.htm>


More information about the core-libs-dev mailing list