Conditional compilation is not available in Java - and Java's platform
independence is the cited (and largely justified) reason. Nevertheless, one
valuable use of conditional compilation, which is to cleanly insert debug
code into applications, is thereby lost.
Several methods to work around this disadvantage are available. Joe Chou
details these approaches in previous issues of Java Developer's Journal (see
www.sys-con.com/java/archives/0312/chou/index_b.html).
In this article I propose an approach that's arguably simpler, more scalable,
and more flexible than any existing method. Although it can potentially be
used for full-fledged conditional compilation, we'll limit ourselves to the
problem of clean debug code.
Problem Statement
Diagnostic messages: Designed to remain in the code even after release. These
are what an as-released application writes out into its lo... (more)