On Thu, 18 Feb 2021 18:47:16 GMT, Jonathan Gibbons <j...@openjdk.org> wrote:

>> src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
>>  line 1082:
>> 
>>> 1080:                     default -> {
>>> 1081:                         assert false;
>>> 1082:                         return HtmlTree.EMPTY;
>> 
>> What is the reason to `assert false` here and in other places instead of, 
>> say, always throw a RuntimeException?
>
> This is the general discussion about the use of `assert`, and whether it is 
> better to throw an exception in production code, or "carry on regardless". I 
> wish Java had a should-not-happen statement or at least a ShoudNotHappen 
> exception.

In this case, `IllegalStateException` is a reasonable alternative

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

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

Reply via email to