assert facility

shudo@computer.org shudo@computer.org
Tue Jun 11 23:10:00 GMT 2002


From: Tom Tromey <tromey@redhat.com>
> FYI, I'm checking in the 1.4 assert facility. I still haven't written
> the new command-line arguments that actually enable assertions. I'll
> submit a PR for this.

Can we avoid performance penalty in case some assertions are compiled
into a binary and they are disabled by the command-line option?
If compilation is performed at runtime, conditional branches for
assertions can be eliminated by (runtime-)constant propagation.
But, I'm not sure whether it could be possible for GCJ.
> It also might make sense to add a gcj flag indicating that assertions
> will never be enabled. This could be useful for compiling production
> code.

Note that Sun does not provide means to eliminate assertions from
bytecode intentionally (*). And Sun recommends "conditional
compilation idiom" described in JLS 14.20, which means using `static
final boolean' flag for elimination.
(*) Programming With Assertions
 http://java.sun.com/j2se/1.4/docs/guide/lang/assert.html
 "1. Why not provide a compiler flag to completely eliminate assertions
 from object files?"
Should we provide a gcj flag to eliminate all assertions?
I'm not sure.
 Kazuyuki Shudo	shudo@computer.org	http://www.shudo.net/


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /