From 5c06195efb1b70db28297fa1a3b632e62996a296 Mon Sep 17 00:00:00 2001 From: Simon Kitching Date: Thu, 2 Jun 2005 06:31:52 +0000 Subject: [PATCH] Ensure an ExceptionInInitializerError occurs when trying to create an instance of these classes in pre-1.4 JVMs. Without this, an InvocationTargetException could be thrown when calling the constructor but that could also be caused by a number of other reasons which we don't want to ignore. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@179529 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/logging/impl/Jdk13LumberjackLogger.java | 8 ++++++++ src/java/org/apache/commons/logging/impl/Jdk14Logger.java | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/src/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java b/src/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java index 80792b1..b099ac6 100644 --- a/src/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java +++ b/src/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java @@ -57,6 +57,14 @@ public class Jdk13LumberjackLogger implements Log, Serializable { private boolean classAndMethodFound = false; + /** + * This member variable simply ensures that any attempt to initialise + * this class in a pre-1.4 JVM will result in an ExceptionInInitializerError. + * It must not be private, as an optimising compiler could detect that it + * is not used and optimise it away. + */ + protected static final Level dummyLevel = Level.FINE; + // ----------------------------------------------------------- Constructors diff --git a/src/java/org/apache/commons/logging/impl/Jdk14Logger.java b/src/java/org/apache/commons/logging/impl/Jdk14Logger.java index ba2cb8e..56c1e1c 100644 --- a/src/java/org/apache/commons/logging/impl/Jdk14Logger.java +++ b/src/java/org/apache/commons/logging/impl/Jdk14Logger.java @@ -38,6 +38,13 @@ import org.apache.commons.logging.Log; public class Jdk14Logger implements Log, Serializable { + /** + * This member variable simply ensures that any attempt to initialise + * this class in a pre-1.4 JVM will result in an ExceptionInInitializerError. + * It must not be private, as an optimising compiler could detect that it + * is not used and optimise it away. + */ + protected static final Level dummyLevel = Level.FINE; // ----------------------------------------------------------- Constructors