Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: Any similar technique like C's #ifdef in Java?
|
Posted: Aug 14, 2003 4:25 PM
|
|
In conjunction with this, you could write a simple script that goes through all the java files in your project and modifies the line matching something like "^\s*public static final boolean DEBUG = (false|true);\s*$" (I'm not a regualar expression guru, so it can probably be improved upon) to either true or false as appropriate (debug vs. release).
<mount object="soapbox">Incidentally, I think the knowledge of conditionally-compiled code makes people a bit too anal retentive on this issue. That is, using a system property as in a previous suggestion is probably acceptible -- and more flexible -- in most cases. Once people become aware of the idea that a trace or log message can be conditionally compiled out, they get this notion that if it doesn't, it will have some huge impact on the performance of the program. This is usually not the case. In the small number of cases where it is, it can be specifically addressed.</mount>
|
|