On Wed, 3 Mar 2021 15:55:03 GMT, Ivan Šipka <[email protected]> wrote:
>> Refactor `test/jdk/java/lang/annotation/loaderLeak/LoaderLeak.sh` as java
>> test.
>
> 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;
-------------
PR: https://git.openjdk.java.net/jdk/pull/1577