Submitting a JEP

Daniel Trebbien dtrebbien at
Fri Oct 6 14:30:02 UTC 2017

On Fri, Oct 6, 2017 at 7:24 AM, David Lloyd <david.lloyd at> wrote:

> On Thu, Oct 5, 2017 at 10:17 PM, Brian Goetz <brian.goetz at>
> wrote:
> > The proposal is a bad fit for the assertion facility, since the assertion
> > facility is designed to be disabled, and what you want is something that
> > can't be disabled.
> I believe that in the document, Mr. Trebbien explicitly explained why
> the assertion facility is a bad fit, and was specifically not
> suggesting it be used, but rather using it as an example and template
> for the new feature.

Specifically, in the Alternatives section (
), I discuss why neither allowing the proposed "unreachable assertions" to
be disabled, nor amending §14.21 Unreachable Statements to allow
unreachable `assert false' statements, is preferred.

The JLS specifies in §14.10 that an assertion is either enabled or
disabled.  However, the JLS does not specify how assertions are enabled or

Unless I am mistaken, there is no standard way to guarantee that assertions
compiled into a CLASS file will be disabled at runtime.  Therefore, unless
the distributor of Java software uses some sort of post-compilation
assertion stripping from CLASS files, the programmers must assume that
assertions might be enabled at runtime.

> But here's an alternative:
> >
> >     throw new UnreachableAssertionException("why");
> >
> > This doesn't need a language feature.
> It does, because you cannot put "throw" statements in places where the
> compiler has statically determined that control flow cannot reach,
> which is a key part of the justification of the feature described in
> the document.
> This is a feature that I for one have sorely missed for many years
> now, especially in more complex state-oriented code where exit points
> cannot be made visually clear.

Yes.  §14.21 Unreachable Statements requires unreachable statements to be
compile-time errors, so you currently cannot place a statement like `throw
new UnreachableAssertionException("why");' at points defined to be

More information about the discuss mailing list