On Tue, 7 Jun 2022 05:45:54 GMT, Jonathan Gibbons <j...@openjdk.org> wrote:
>> Hm... Which kind of "Error" would be thrown for which "other type"? I don't >> think that this method is ever called with an element other than a >> constructor or method; look: >> >> public ThrowsTaglet() { >> super(DocTree.Kind.THROWS, false, EnumSet.of(Location.CONSTRUCTOR, >> Location.METHOD)); >> } >> >> It is called for constructors regularly, but as you might imagine, it has no >> effect other than waste of resources and, what is more important, loss of >> code clarity. There are multiple types of executable elements. It's both >> clarifying and reassuring to see an assertion that establishes our >> programming assumptions as to which of those types we expect there, early in >> the method. > > Agreed on checking stuff up front, but I continue to think that `assert` is > little better than a stylized comment, since they are typically not enabled. I use assertions. If you don't find them useful, we can discuss it. Last time we discussed assertions internally, somebody sent me this article, which you might want to have a look at: https://blog.regehr.org/archives/1091. ------------- PR: https://git.openjdk.java.net/jdk/pull/8886