diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml new file mode 100755 index 00000000..9f3f7d80 --- /dev/null +++ b/.idea/codeStyleSettings.xml @@ -0,0 +1,38 @@ + + + + + + \ No newline at end of file diff --git a/slf4j-api/src/main/java/org/slf4j/helpers/Util.java b/slf4j-api/src/main/java/org/slf4j/helpers/Util.java index a729d3fb..4a205c02 100755 --- a/slf4j-api/src/main/java/org/slf4j/helpers/Util.java +++ b/slf4j-api/src/main/java/org/slf4j/helpers/Util.java @@ -26,7 +26,6 @@ package org.slf4j.helpers; /** - * * An internal utility class. * * @author Alexandre Dorokhine @@ -34,53 +33,54 @@ package org.slf4j.helpers; */ public final class Util { - private Util() {} + private Util() {} - /** - * In order to call {@link SecurityManager#getClassContext()}, which is a - * protected method, we add this wrapper which allows the method to be visible - * inside this package. - */ - private static final class ClassContextSecurityManager extends SecurityManager { - protected Class[] getClassContext() { - return super.getClassContext(); - } - }; - private static final ClassContextSecurityManager SECURITY_MANAGER = - new ClassContextSecurityManager(); - - /** - * Returns the name of the class which called the invoking method. - * @return the name of the class which called the invoking method. - */ - public static Class getCallingClass() { - Class[] trace = SECURITY_MANAGER.getClassContext(); - String thisClassName = Util.class.getName(); - - // Advance until Util is found - int i; - for (i = 0 ; i < trace.length ; i++) { - if (thisClassName.equals(trace[i].getName())) - break; + /** + * In order to call {@link SecurityManager#getClassContext()}, which is a + * protected method, we add this wrapper which allows the method to be visible + * inside this package. + */ + private static final class ClassContextSecurityManager extends SecurityManager { + protected Class[] getClassContext() { + return super.getClassContext(); + } } - // trace[i] = Util; trace[i+1] = caller; trace[i+2] = caller's caller - if (i >= trace.length || i + 2 >= trace.length) { - throw new IllegalStateException( - "Failed to find org.slf4j.helpers.Util or its caller in the stack; " + - "this should not happen"); + private static final ClassContextSecurityManager SECURITY_MANAGER = new ClassContextSecurityManager(); + + /** + * Returns the name of the class which called the invoking method. + * + * @return the name of the class which called the invoking method. + */ + public static Class getCallingClass() { + Class[] trace = SECURITY_MANAGER.getClassContext(); + String thisClassName = Util.class.getName(); + + // Advance until Util is found + int i; + for(i = 0; i < trace.length; i++) { + if(thisClassName.equals(trace[i].getName())) + break; + } + + // trace[i] = Util; trace[i+1] = caller; trace[i+2] = caller's caller + if(i >= trace.length || i + 2 >= trace.length) { + throw new IllegalStateException( + "Failed to find org.slf4j.helpers.Util or its caller in the stack; " + + "this should not happen"); + } + + return trace[i + 2]; } - return trace[i+2]; - } + static final public void report(String msg, Throwable t) { + System.err.println(msg); + System.err.println("Reported exception:"); + t.printStackTrace(); + } - static final public void report(String msg, Throwable t) { - System.err.println(msg); - System.err.println("Reported exception:"); - t.printStackTrace(); - } - - static final public void report(String msg) { - System.err.println("SLF4J: " +msg); - } + static final public void report(String msg) { + System.err.println("SLF4J: " + msg); + } }