[Fb-contrib-commit] SF.net SVN: fb-contrib:[1068] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/d
Brought to you by:
dbrosius
From: <dbr...@us...> - 2008-08-08 15:56:18
|
Revision: 1068 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1068&view=rev Author: dbrosius Date: 2008-08-08 15:56:24 +0000 (Fri, 08 Aug 2008) Log Message: ----------- add checks for slf4j Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2008-08-08 15:50:35 UTC (rev 1067) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LoggerOddities.java 2008-08-08 15:56:24 UTC (rev 1068) @@ -104,11 +104,28 @@ else if (seen == INVOKESTATIC) { String clsName = getClassConstantOperand(); String mthName = getNameConstantOperand(); - if ("org/apache/log4j/Logger".equals(clsName) + + String loggingClassName = null; + + if ("org/slf4j/LoggerFactory".equals(clsName) && "getLogger".equals(mthName)) { String signature = getSigConstantOperand(); - String loggingClassName = null; + if ("(Ljava/lang/Class;)Lorg/slf4j/Logger;".equals(signature)) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + loggingClassName = (String)item.getUserValue(); + } + } else if ("(Ljava/lang/String;)Lorg/slf4j/Logger;".equals(signature)) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + loggingClassName = (String)item.getConstant(); + } + } + } else if ("org/apache/log4j/Logger".equals(clsName) + && "getLogger".equals(mthName)) { + String signature = getSigConstantOperand(); + if ("(Ljava/lang/Class;)Lorg/apache/log4j/Logger;".equals(signature)) { if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); @@ -125,19 +142,19 @@ loggingClassName = (String)item.getConstant(); } } - - if (loggingClassName != null) { - if (stack.getStackDepth() > 0) { - OpcodeStack.Item item = stack.getStackItem(0); - if ((loggingClassName != null) && !loggingClassName.equals(clsName)) { - bugReporter.reportBug(new BugInstance(this, "LO_SUSPECT_LOG_CLASS", clsName.contains("$") ? LOW_PRIORITY : NORMAL_PRIORITY) - .addClass(this) - .addMethod(this) - .addSourceLine(this)); - } - } - } } + + if (loggingClassName != null) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item item = stack.getStackItem(0); + if ((loggingClassName != null) && !loggingClassName.equals(clsName)) { + bugReporter.reportBug(new BugInstance(this, "LO_SUSPECT_LOG_CLASS", clsName.contains("$") ? LOW_PRIORITY : NORMAL_PRIORITY) + .addClass(this) + .addMethod(this) + .addSourceLine(this)); + } + } + } } } finally { stack.sawOpcode(this, seen); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |