Thursday, May 31, 2001 01:23 AM
This is a little off the point, but may be of interest to you in any case. I do not think that runtime compilation is possible (others can correct me if I'm wrong). It might be possible to do what you suggest in a roundabout way by using delegation to different classes chosen at runtime (but most likely known at compile time) which offer different implementations of certain methods - you would probably use reflection here. (You might be able to combine reflection and a properties file containing the names of the delegate classes to add more dynamism).
That's by way of introduction to my 'off-topic' point. You can put debug code into your classes for test purposes by doing a check against a public static final variable (e.g. called trace) which is set to true initially.
//... In member declaration
public static final boolean trace = true;
//... In methods
// System.out.println("Trace: blaah blaah");
If you later set this variable to false and recompile, most JDKs will optimise the compilation and remove the debug code blocks from the generated code.
Hope this helps,