[1113] in java-interest
Re: assertions in Java
daemon@ATHENA.MIT.EDU (John D. Mitchell)
Sat Aug 19 00:02:10 1995
Date: Fri, 18 Aug 1995 17:49:17 -0700
From: "John D. Mitchell" <johnm@emf2-003.emf.net>
To: phil@bolthole.com (Philip Brown)
cc: java-interest@java.sun.com
In-Reply-To: <199508181900.MAA29986@shell1.best.com>
Philip Brown writes:
> >
> > class foo {
> > static final boolean debug = false;
> >
> > void bar() {
> > if (debug) {
> > for (int i = 0; i < 10000000; i++)
> > System.out.println("Ouch");
> > }
> > System.out.println("It hurts!");
> > }
> > }
> >
> > The compiler currently deletes the unreachable code inside the if
> > (debug) statement.
>
> Ick.
> Then either the compiler needs to be fixed, or a keyword "volatile"
> needs to be added.
Me thinks you misread the example. That's exactly the behavior one wants
when the *known* constant boolean test expression in the if is false. It,
of course, does *not* delete the code in the if statement if it's true or
if it's not a known constant (that's what the 'static final' part means).
Take care,
John
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com