log4j LogWrapper investigaion Julius Davies http://juliusdavies.ca/ August 2, 2006 Question: ------------------------ Does the LogWrapper.java I'm proposing work with different JVM's? Can it handle log4j.jar being unavailable no matter which JVM is being used? Answer: ------------------------ Yes! More JVM's need to be tested, but I think this is a pretty good starting point. Compiled with Sun 1.4.2_12* no-log4j yes-log4j Linux ------------------------------------------- Sun 1.3.1_18 x x Sun 1.4.2_12 x x Sun 1.5.0_07 x x Sun 1.6.0-beta2 x x JRockit 1.4.2_08 x x JRockit 1.5.0_06 x x Blackdown 1.4.2_03 x x IBM 1.4.2-SR4-1 x x IBM 1.5.0-J9-2.3 x x Windows ------------------------------------------- Sun 1.4.2_05 x x Sun 1.5.0_07 x x *Note: compiling with Sun 1.3.1_18 causes line 31 of Main.java to fail if log4j.jar is not present. This is because Java 1.3's compiler creates bytecode that is more strict with dependency checking. The technique I'm proposing still works with a Java 1.3 compiler, and even inspection via reflection of LogWrapper is fine. Inspection (via reflection) of the underlying LogHelper (the situation on line 31) is what fails at runtime if we use a "Java 1.3" _compiler_. Inspection of LogHelper should usually fail, anyway, because LogHelper is not a public class. Thanks to Quy Nguyen for explaining the differences between javac 1.3 and javac 1.4 to me.