[Fb-contrib-commit] SF.net SVN: fb-contrib:[1152] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
From: <dbr...@us...> - 2009-04-10 15:44:07
|
Revision: 1152 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1152&view=rev Author: dbrosius Date: 2009-04-10 15:44:00 +0000 (Fri, 10 Apr 2009) Log Message: ----------- fix FP due to missed differences with LDC, LDC_W instructions Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java 2009-04-07 02:09:47 UTC (rev 1151) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/CopiedOverriddenMethod.java 2009-04-10 15:44:00 UTC (rev 1152) @@ -22,6 +22,7 @@ import java.util.Map; import org.apache.bcel.classfile.Code; +import org.apache.bcel.classfile.ConstantClass; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; import org.apache.bcel.generic.ConstantPoolGen; @@ -30,7 +31,9 @@ import org.apache.bcel.generic.InstructionHandle; import org.apache.bcel.generic.InstructionList; import org.apache.bcel.generic.InvokeInstruction; +import org.apache.bcel.generic.LDC; import org.apache.bcel.generic.ReferenceType; +import org.apache.bcel.generic.Type; import edu.umd.cs.findbugs.BugInstance; import edu.umd.cs.findbugs.BugReporter; @@ -114,7 +117,9 @@ public void visitCode(Code obj) { Method m = getMethod(); if (!m.isPublic() && !m.isProtected() && !m.isAbstract()) + { return; + } Code superCode = superclassCode.get(curMethodInfo); if (superCode != null) { @@ -141,16 +146,22 @@ byte[] parentBytes = parent.getCode(); if ((childBytes == null) || (parentBytes == null)) + { return false; + } if (childBytes.length != parentBytes.length) + { return false; + } InstructionHandle[] childihs = new InstructionList(childBytes).getInstructionHandles(); InstructionHandle[] parentihs = new InstructionList(parentBytes).getInstructionHandles(); if (childihs.length != parentihs.length) + { return false; + } for (int i = 0; i < childihs.length; i++) { InstructionHandle childih = childihs[i]; @@ -159,40 +170,79 @@ Instruction parentin = parentih.getInstruction(); if (!childin.getName().equals(parentin.getName())) + { return false; + } if (childin instanceof FieldInstruction) { String childFName = ((FieldInstruction) childin).getFieldName(childPoolGen); String parentFName = ((FieldInstruction) parentin).getFieldName(parentPoolGen); if (!childFName.equals(parentFName)) + { return false; + } String childFSig = ((FieldInstruction) childin).getSignature(childPoolGen); String parentFSig = ((FieldInstruction) parentin).getSignature(parentPoolGen); if (!childFSig.equals(parentFSig)) + { return false; + } if (childFSig.charAt(0) == 'L') { ReferenceType childRefType = ((FieldInstruction) childin).getReferenceType(childPoolGen); ReferenceType parentRefType = ((FieldInstruction) parentin).getReferenceType(parentPoolGen); if (!childRefType.getSignature().equals(parentRefType.getSignature())) + { return false; + } } } else if (childin instanceof InvokeInstruction) { String childClassName = ((InvokeInstruction) childin).getClassName(childPoolGen); String parentClassName = ((InvokeInstruction) parentin).getClassName(parentPoolGen); if (!childClassName.equals(parentClassName)) + { return false; + } String childMethodName = ((InvokeInstruction) childin).getMethodName(childPoolGen); String parentMethodName = ((InvokeInstruction) parentin).getMethodName(parentPoolGen); if (!childMethodName.equals(parentMethodName)) + { return false; + } String childSignature = ((InvokeInstruction) childin).getSignature(childPoolGen); String parentSignature = ((InvokeInstruction) parentin).getSignature(parentPoolGen); if (!childSignature.equals(parentSignature)) + { return false; - } else { + } + } else if (childin instanceof LDC) { + Type childType = ((LDC) childin).getType(childPoolGen); + Type parentType = ((LDC) parentin).getType(parentPoolGen); + if (!childType.equals(parentType)) + { + return false; + } + + Object childValue = ((LDC) childin).getValue(childPoolGen); + Object parentValue = ((LDC) parentin).getValue(parentPoolGen); + + if (childValue instanceof ConstantClass) + { + ConstantClass childClass = (ConstantClass)childValue; + ConstantClass parentClass = (ConstantClass)parentValue; + if (!childClass.getBytes(childPoolGen.getConstantPool()).equals(parentClass.getBytes(parentPoolGen.getConstantPool()))) + { + return false; + } + } + //TODO: Other Constant types + + } + else { if (!childin.equals(parentin)) + { return false; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |