RFR 8187222 : ClassLoader.getSystemClassLoader not clear if recursive initialization leads to ISE or unspecified error
mandy chung
mandy.chung at oracle.com
Thu Nov 30 22:57:31 UTC 2017
On 11/30/17 1:35 PM, Brent Christian wrote:
> Hi,
>
> Please review the following change:
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8187222
> Webrev: http://cr.openjdk.java.net/~bchristi/8187222/webrev.00/
>
Thanks for fixing it.
This is indeed a bug that should throw ISE when
ClassLoader.getSystemClassLoader is called during the initialization of
the system class loader, as the spec states.
line 1921: I suggest to revise the message to make it clearer:
"getSystemClassLoader cannot be called during the system class
loader instantiation"
In ClassLoader::initSystemClassLoader (line 1971), when the exception is
thrown via Constructor::newInstance, it would be good to the cause of an
InvocationTargetException like:
+ Throwable t = e;
+ if (e instanceof InvocationTargetException) {
+ t = e.getCause();
+ }
+ throw new Error(t.getMessage(), t);
InitSystemLoaderTest.java verifies a working custom system class
loader. This recursive custom system loader test fits better as a new
test rather a test case in InitSystemLoaderTest.java.
I suggest to rename ThrowingCustomLoader as RecursiveSystemLoader and
make it as jtreg test with a static void main (maybe it should validate
what getSystemClassLoader returns). It can be made simpler e.g. line
30-31, 45-47 and 54 are not needed.
Mandy
More information about the core-libs-dev
mailing list