Remove code that accounts for Java 1.1 and 1.2
This commit is contained in:
@@ -22,8 +22,6 @@ import java.io.InputStream;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
@@ -163,54 +161,29 @@ public class SimpleLog implements Log, Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the thread context class loader if available.
|
* Gets the thread context class loader if available. Otherwise return null.
|
||||||
* Otherwise return null.
|
|
||||||
*
|
*
|
||||||
* The thread context class loader is available for JDK 1.2
|
* The thread context class loader is available if certain security conditions are met.
|
||||||
* or later, if certain security conditions are met.
|
|
||||||
*
|
*
|
||||||
* @throws LogConfigurationException if a suitable class loader
|
* @throws LogConfigurationException if a suitable class loader cannot be identified.
|
||||||
* cannot be identified.
|
|
||||||
*/
|
*/
|
||||||
private static ClassLoader getContextClassLoader() {
|
private static ClassLoader getContextClassLoader() {
|
||||||
ClassLoader classLoader = null;
|
ClassLoader classLoader = null;
|
||||||
|
|
||||||
try {
|
|
||||||
// Are we running on a JDK 1.2 or later system?
|
|
||||||
final Method method = Thread.class.getMethod("getContextClassLoader", (Class[]) null);
|
|
||||||
|
|
||||||
// Get the thread context class loader (if there is one)
|
// Get the thread context class loader (if there is one)
|
||||||
try {
|
try {
|
||||||
classLoader = (ClassLoader) method.invoke(Thread.currentThread(), (Class[]) null);
|
classLoader = Thread.currentThread().getContextClassLoader();
|
||||||
} catch (final IllegalAccessException e) {
|
} catch (final SecurityException e) {
|
||||||
// ignore
|
|
||||||
} catch (final InvocationTargetException e) {
|
|
||||||
/**
|
/**
|
||||||
* InvocationTargetException is thrown by 'invoke' when
|
* getContextClassLoader() throws SecurityException when the context class loader isn't an ancestor of the calling class's class loader, or if
|
||||||
* the method being invoked (getContextClassLoader) throws
|
* security permissions are restricted.
|
||||||
* an exception.
|
|
||||||
*
|
*
|
||||||
* getContextClassLoader() throws SecurityException when
|
* In the first case (not related), we want to ignore and keep going. We cannot help but also ignore the second with the logic below, but other
|
||||||
* the context class loader isn't an ancestor of the
|
* calls elsewhere (to obtain a class loader) will trigger this exception where we can make a distinction.
|
||||||
* calling class's class loader, or if security
|
|
||||||
* permissions are restricted.
|
|
||||||
*
|
|
||||||
* In the first case (not related), we want to ignore and
|
|
||||||
* keep going. We cannot help but also ignore the second
|
|
||||||
* with the logic below, but other calls elsewhere (to
|
|
||||||
* obtain a class loader) will trigger this exception where
|
|
||||||
* we can make a distinction.
|
|
||||||
*/
|
*/
|
||||||
if (!(e.getTargetException() instanceof SecurityException)) {
|
|
||||||
// Capture 'e.getTargetException()' exception for details
|
// Capture 'e.getTargetException()' exception for details
|
||||||
// alternate: log 'e.getTargetException()', and pass back 'e'.
|
// alternate: log 'e.getTargetException()', and pass back 'e'.
|
||||||
throw new LogConfigurationException
|
throw new LogConfigurationException("Unexpected SecurityException", e);
|
||||||
("Unexpected InvocationTargetException", e.getTargetException());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (final NoSuchMethodException e) {
|
|
||||||
// Assume we are running on JDK 1.1
|
|
||||||
// ignore
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (classLoader == null) {
|
if (classLoader == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user