RFR: JDK-8279513: jdk/javadoc/doclet/testDocletExample/TestDocletExample.java fails after 8278795

Pavel Rappo prappo at openjdk.java.net
Wed May 25 17:27:49 UTC 2022


On Wed, 25 May 2022 16:59:25 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

>> test/langtools/jdk/javadoc/doclet/testDocletExample/TestDocletExample.java line 71:
>> 
>>> 69:         var entryPointSnippet = snippets.getSnippetById(dc, "entry-point");
>>> 70:         if (entryPointSnippet == null) {
>>> 71:             throw new Error("Cannot find snippet \"entry-point\"");
>> 
>> I understand it as follows. Although this code now throws generic `Error` instead of `NullPointerException`, which the bug reporter observed, we shouldn't see that `Error` in circumstances similar to those of bug reporter. This is because in those circumstances the code will throw `ConfigurationException` earlier, at construction time, so we won't reach this check. Do I understand it correctly?
>
> Yes. Although we could throw NPE even here, I was wanting to throw something that indicates the test is dysfunctional, as compared to failing or crashing.

The rationale that you provided reminds of `new FileInputStream(java.io.File)` that throws `FileNotFoundException`. Unlike not finding a file, not finding a particular snippet is an unexpected, unrecoverable programming error. I cannot imagine a reasonable test that checks that some snippet is not there.

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

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


More information about the compiler-dev mailing list