On Fri, 11 Feb 2022 20:36:26 GMT, Tim Prinzing <d...@openjdk.java.net> wrote:

> JDK-8281000 ClassLoader::registerAsParallelCapable throws NPE if caller is 
> null

Thanks for taking on these null caller issue.

To give more context to this issue, the spec of 
`ClassLoader::isRegisteredAsParallelCapable` returns true if this class loader 
is registered as parallel capable, otherwise false.  The current spec does not 
specify what if the caller class is not a class loader.  The current 
implementation throws NPE if caller is null.  I initially proposed to return 
false for simplicity.   However, if the caller is not a subclass of 
`ClassLoader`, the current implementation throws `ClassCastException`.  Both 
cases are invalid caller and they should be handled in the same way, either 
return false or throw an exception.

Having a second thought, since this API expects to be called by a class loader, 
I think throwing `IllegalCallerException` to indicate this method is called by 
an illegal caller.    This will need a CSR due to the spec change.

What do you think?

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

PR: https://git.openjdk.java.net/jdk/pull/7448

Reply via email to