[Fb-contrib-commit] SF.net SVN: fb-contrib: [874] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
From: <dbr...@us...> - 2007-03-11 05:04:50
|
Revision: 874 http://svn.sourceforge.net/fb-contrib/?rev=874&view=rev Author: dbrosius Date: 2007-03-10 21:04:49 -0800 (Sat, 10 Mar 2007) Log Message: ----------- Fix for 1676812 OCP flags overriding methods - while at it, short-circuit methods that have no object parameters Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2007-03-11 04:43:41 UTC (rev 873) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/OverlyConcreteParameter.java 2007-03-11 05:04:49 UTC (rev 874) @@ -54,13 +54,13 @@ public class OverlyConcreteParameter extends BytecodeScanningDetector { private BugReporter bugReporter; - private JavaClass[] interfaces; + private JavaClass[] constrainingClasses; private Map<Integer, Map<JavaClass, List<MethodInfo>>> parameterDefiners; private Set<Integer> usedParameters; private JavaClass objectClass; private OpcodeStack stack; private int parmCount; - private boolean methodImplementsInterface; + private boolean methodSignatureIsConstrained; private boolean methodIsStatic; /** @@ -80,7 +80,11 @@ @Override public void visitClassContext(ClassContext classContext) { try { - interfaces = classContext.getJavaClass().getAllInterfaces(); + JavaClass[] infs = classContext.getJavaClass().getAllInterfaces(); + JavaClass[] sups = classContext.getJavaClass().getSuperClasses(); + constrainingClasses = new JavaClass[infs.length + sups.length]; + System.arraycopy(infs, 0, constrainingClasses, 0, infs.length); + System.arraycopy(sups, 0, constrainingClasses, infs.length, sups.length); parameterDefiners = new HashMap<Integer, Map<JavaClass, List<MethodInfo>>>(); usedParameters = new HashSet<Integer>(); stack = new OpcodeStack(); @@ -88,7 +92,7 @@ } catch (ClassNotFoundException cnfe) { bugReporter.reportMissingClass(cnfe); } finally { - interfaces = null; + constrainingClasses = null; parameterDefiners = null; usedParameters = null; stack = null; @@ -97,33 +101,34 @@ @Override public void visitMethod(Method obj) { - methodImplementsInterface = false; + methodSignatureIsConstrained = false; String methodName = obj.getName(); if (!"<init>".equals(methodName) && !"<clinit>".equals(methodName)) { String methodSig = obj.getSignature(); + String parms = methodSig.split("\\(|\\)")[1]; + if (parms.indexOf(";") >= 0) { - outer:for (JavaClass inf : interfaces) { - Method[] methods = inf.getMethods(); - for (Method m : methods) { - if (methodName.equals(m.getName())) { - if (methodSig.equals(m.getSignature())) { - methodImplementsInterface = true; - break outer; + outer:for (JavaClass cls : constrainingClasses) { + Method[] methods = cls.getMethods(); + for (Method m : methods) { + if (methodName.equals(m.getName())) { + if (methodSig.equals(m.getSignature())) { + methodSignatureIsConstrained = true; + break outer; + } } } } } } - - super.visitMethod(obj); } @Override public void visitCode(final Code obj) { try { - if (methodImplementsInterface) + if (methodSignatureIsConstrained) return; parameterDefiners.clear(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |