RFR: 8259267: Refactor LoaderLeak shell test as java test. [v14]

Ivan Šipka isipka at openjdk.java.net
Wed Mar 3 19:56:08 UTC 2021


On Wed, 3 Mar 2021 18:26:19 GMT, Igor Ignatyev <iignatyev at openjdk.org> wrote:

>> Ivan Šipka has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8166026: Refactor java/lang shell tests to java
>
> test/jdk/java/lang/annotation/LoaderLeakTest.java line 74:
> 
>> 72:             catch (NullPointerException npe) {
>> 73:                 throw new AssertionError("c.get() should never return null", npe);
>> 74:             }
> 
> I don't think it's the right way to handle that, you don't know if this NPE is from `c.get`, so the exception messages might be misleading. I'd just remove try/catch, if NPE occurs jtreg will report the test as failed w/ NPE as a reason, so whoever analyzes it will be able to understand.
> 
> alternatively, you can save c.get into a local variable which you nulls later one, e.g.
>  ```
> static void doTest(boolean readAnn) throws Exception {
> ...
> var tmp = c.get();
> if (t == null) throw new AssertionError("c.get is null");
> if (t.getClassLoader() != loader) throw new AssertionError("wrong classloader");
> t = null;

@iignatev I just reemove the try catch I think the comments are informative and will help with analysis with potential NPE

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

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


More information about the core-libs-dev mailing list