[Fb-contrib-commit] SF.net SVN: fb-contrib: [448] trunk/fb-contrib/samples
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-04-17 00:44:30
|
Revision: 448 Author: dbrosius Date: 2006-04-16 17:44:22 -0700 (Sun, 16 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=448&view=rev Log Message: ----------- always write the source line annotation for the bad write, not the good write. Modified Paths: -------------- trunk/fb-contrib/samples/NRTL_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/samples/NRTL_Sample.java =================================================================== --- trunk/fb-contrib/samples/NRTL_Sample.java 2006-04-15 00:37:03 UTC (rev 447) +++ trunk/fb-contrib/samples/NRTL_Sample.java 2006-04-17 00:44:22 UTC (rev 448) @@ -4,6 +4,7 @@ public class NRTL_Sample extends TagSupport { private String sample; + private String sample2; public void setSample(String s) { sample = s; @@ -12,12 +13,17 @@ public int doStartTag() throws JspException { try { sample += Math.random(); - pageContext.getOut().print(sample); + sample2 += sample; + pageContext.getOut().print(sample2); } catch (Exception ex) { throw new JspTagException("NRTL_Sample: " + ex.getMessage()); } return SKIP_BODY; } + + public void setSample2(String s) { + sample2 = s; + } public int doEndTag() { return EVAL_PAGE; Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-15 00:37:03 UTC (rev 447) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-17 00:44:22 UTC (rev 448) @@ -71,7 +71,7 @@ /** * methodname:methodsig -> (fieldname:fieldtype)s */ - private Map<String, Set<String>> methodWrites; + private Map<String, Map<String, SourceLineAnnotation>> methodWrites; private Map<String, FieldAnnotation> fieldAnnotations; /** @@ -109,7 +109,7 @@ attributes = getAttributes(cls); if (attributes.size() > 0) { - methodWrites = new HashMap<String, Set<String>>(); + methodWrites = new HashMap<String, Map<String, SourceLineAnnotation>>(); fieldAnnotations = new HashMap<String, FieldAnnotation>(); super.visitClassContext(classContext); reportBugs(); @@ -172,18 +172,17 @@ public void sawOpcode(int seen) { if (seen == PUTFIELD) { String methodInfo = getMethodName() + ":" + getMethodSig(); - Set<String> fields = methodWrites.get(methodInfo); + Map<String, SourceLineAnnotation> fields = methodWrites.get(methodInfo); if (fields == null) { - fields = new HashSet<String>(); + fields = new HashMap<String, SourceLineAnnotation>(); methodWrites.put(methodInfo, fields); } String fieldName = getNameConstantOperand(); String fieldSig = getSigConstantOperand(); FieldAnnotation fa = new FieldAnnotation(getClassName(), fieldName, fieldSig, false); - fa.setSourceLines(SourceLineAnnotation.fromVisitedInstruction(this)); fieldAnnotations.put(fieldName, fa); - fields.add(fieldName + ":" + fieldSig); + fields.put(fieldName + ":" + fieldSig, SourceLineAnnotation.fromVisitedInstruction(this)); } } @@ -191,32 +190,35 @@ * generates all the bug reports for attributes that are not recycleable */ private void reportBugs() { - for (Map.Entry<String, String> entry : attributes.entrySet()) { - String methodInfo = entry.getKey(); - String attType = entry.getValue(); + for (Map.Entry<String, String> attEntry : attributes.entrySet()) { + String methodInfo = attEntry.getKey(); + String attType = attEntry.getValue(); - Set<String> fields = methodWrites.get(methodInfo); + Map<String, SourceLineAnnotation> fields = methodWrites.get(methodInfo); if ((fields == null) || (fields.size() != 1)) continue; - String fieldInfo = fields.iterator().next(); + + String fieldInfo = fields.keySet().iterator().next(); String fieldName = fieldInfo.substring(0, fieldInfo.indexOf(":")); String fieldType = fieldInfo.substring(fieldInfo.indexOf(":")+1); if (!attType.equals(fieldType)) continue; - int cnt = 0; - for (Set<String> allFields : methodWrites.values()) { - if (allFields.contains(fieldInfo)) - cnt++; + for (Map.Entry<String, Map<String, SourceLineAnnotation>> fwEntry : methodWrites.entrySet()) { + if (fwEntry.getKey().equals(methodInfo)) + continue; + + SourceLineAnnotation sla = fwEntry.getValue().get(fieldInfo); + if (sla != null) { + bugReporter.reportBug(new BugInstance(this, "NRTL_NON_RECYCLEABLE_TAG_LIB", NORMAL_PRIORITY) + .addClass(this) + .addField(fieldAnnotations.get(fieldName)) + .addSourceLine(sla)); + break; + } } - - if (cnt > 1) { - bugReporter.reportBug(new BugInstance(this, "NRTL_NON_RECYCLEABLE_TAG_LIB", NORMAL_PRIORITY) - .addClass(this) - .addField(fieldAnnotations.get(fieldName))); - } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |