[josm-dev] Switch to Java 6?
Jiri Klement
jiri.klement at gmail.com
Sun Nov 29 09:15:05 GMT 2009
>> Simple use normal if/then. Java VM will recompile it at runtime. This
>> probably
>> wont work in java5 if compiled for java6 :-(
>> http://www.devx.com/tips/Tip/13342
>
> Runtime handling is no usuable solution. When you have conditionals you
> don't want specific code in a version (e.g. commercial software shipped with
> debug code is somewhat strange).
if you declare the DEBUG field as public static final boolean and set
DEBUG to false, then debug code will not be in compiled class at all.
You can try to compile following class and then look at generated code
using javap:
public class a {
public static final boolean DEBUG = false;
public static void main(String[] args) {
if (DEBUG) {
System.out.println("debug");
}
}
The debug part won't be in the dissambled code and even the "debug"
string won't be in generated class file.
--
Jiri
More information about the josm-dev
mailing list