A java DEBUG flag

Bryce McKinlay bryce@albatross.co.nz
Fri Nov 24 02:20:00 GMT 2000


Mark Wielaard wrote:

> > > If we used something like
> > > System.getProperty("gnu.java.io.serialisation.debugging") to set these
> > > constants (you can even do that in an interface)
> >
> > I don't think so ;-)
>
> What don't you think so?
> What I meant was something like the following:
>
> interface I {
>     boolean SERIALISATION_DEBUG =
>         Boolean.getBoolean("gnu.java.io.serialisation.debugging");
> }

But this is not a constant! It can only be evaluated at runtime. A bytecode
compiler or native compiler like gcj cannot determine the value of the flag, and
must emit a branch. Granted, a smart JIT will be able to take advantage of it
being a final field and eliminate the debug code from what it generates. However,
if it is used extensively in the runtime then it is probable that the flag would
be evaluated before the system property is set, making it useless.

regards

  [ bryce ]




More information about the Java mailing list