Thread: [Fb-contrib-commit] SF.net SVN: fb-contrib: [430] trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/det
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-04-09 21:02:45
|
Revision: 430 Author: dbrosius Date: 2006-04-09 14:02:41 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=430&view=rev Log Message: ----------- based on set not get Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 20:52:22 UTC (rev 429) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 21:02:41 UTC (rev 430) @@ -8,6 +8,7 @@ import org.apache.bcel.classfile.Code; import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; +import org.apache.bcel.generic.Type; import edu.umd.cs.findbugs.BugReporter; import edu.umd.cs.findbugs.BytecodeScanningDetector; @@ -26,10 +27,25 @@ tagClasses.add("javax.servlet.jsp.tagext.TagSupport"); tagClasses.add("javax.servlet.jsp.tagext.BodyTagSupport"); } + + private static final Set<String> validAttrTypes = new HashSet<String>(); + static { + validAttrTypes.add("B"); + validAttrTypes.add("C"); + validAttrTypes.add("D"); + validAttrTypes.add("F"); + validAttrTypes.add("I"); + validAttrTypes.add("J"); + validAttrTypes.add("S"); + validAttrTypes.add("Z"); + validAttrTypes.add("Ljava/lang/String;"); + validAttrTypes.add("Ljava/util/Date;"); + } + private BugReporter bugReporter; private Map<String, String> attributes; private boolean isAttribute; - private boolean sawPut; + private boolean sawSet; /** * constructs a NRTL detector given the reporter to report bugs on. @@ -90,16 +106,18 @@ Method[] methods = cls.getMethods(); for (Method m : methods) { String name = m.getName(); - if (name.startsWith("get") && m.isPublic() && !m.isStatic()) { + if (name.startsWith("set") && m.isPublic() && !m.isStatic()) { String sig = m.getSignature(); - if (sig.startsWith("()")) { - String retSig = sig.substring(sig.indexOf(")")+1); - if ((retSig.charAt(0) != 'L') && ("Ljava/lang/String;".equals(retSig))) { + Type ret = Type.getReturnType(sig); + Type[] args = Type.getArgumentTypes(sig); + if (ret.equals(Type.VOID) && (args.length == 1)) { + String parmSig = args[0].getSignature(); + if (validAttrTypes.contains(parmSig)) { Code code = m.getCode(); - if ((code != null) && code.getCode().length > MAX_ATTRIBUTE_CODE_LENGTH) { - attributes.put(name.substring("get".length()), retSig); + if ((code != null) && code.getCode().length < MAX_ATTRIBUTE_CODE_LENGTH) { + attributes.put(name.substring("set".length()), parmSig); isAttribute = true; - sawPut = false; + sawSet = false; super.visitMethod(m); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 22:55:07
|
Revision: 432 Author: dbrosius Date: 2006-04-09 15:54:58 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=432&view=rev Log Message: ----------- guard against npe's Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 21:44:03 UTC (rev 431) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 22:54:58 UTC (rev 432) @@ -176,7 +176,7 @@ String attType = entry.getValue(); Set<String> fields = methodWrites.get(methodInfo); - if (fields.size() != 1) + if ((fields != null) && fields.size() != 1) continue; String fieldInfo = fields.iterator().next(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 22:58:38
|
Revision: 433 Author: dbrosius Date: 2006-04-09 15:58:33 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=433&view=rev Log Message: ----------- fix the npe guard, right Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 22:54:58 UTC (rev 432) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 22:58:33 UTC (rev 433) @@ -176,7 +176,7 @@ String attType = entry.getValue(); Set<String> fields = methodWrites.get(methodInfo); - if ((fields != null) && fields.size() != 1) + if ((fields == null) || (fields.size() != 1)) continue; String fieldInfo = fields.iterator().next(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-09 23:13:14
|
Revision: 434 Author: dbrosius Date: 2006-04-09 16:13:10 -0700 (Sun, 09 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=434&view=rev Log Message: ----------- allow writes to attributes backing fields in the constructor Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 22:58:33 UTC (rev 433) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-09 23:13:10 UTC (rev 434) @@ -145,8 +145,10 @@ @Override public void visitCode(Code obj) { Method m = getMethod(); - String attName = m.getName() + ":" + m.getSignature(); - super.visitCode(obj); + if (!"<init>".equals(m.getName())) { + String attName = m.getName() + ":" + m.getSignature(); + super.visitCode(obj); + } } @Override @@ -160,6 +162,7 @@ } String fieldName = getNameConstantOperand(); String fieldSig = getSigConstantOperand(); + FieldAnnotation fa = new FieldAnnotation(getClassName(), fieldName, fieldSig, false); fa.setSourceLines(SourceLineAnnotation.fromVisitedInstruction(this)); fieldAnnotations.put(fieldName, fa); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-11 14:15:59
|
Revision: 438 Author: dbrosius Date: 2006-04-11 07:15:45 -0700 (Tue, 11 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=438&view=rev Log Message: ----------- remove unused Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-10 03:08:45 UTC (rev 437) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-11 14:15:45 UTC (rev 438) @@ -146,7 +146,6 @@ public void visitCode(Code obj) { Method m = getMethod(); if (!"<init>".equals(m.getName())) { - String attName = m.getName() + ":" + m.getSignature(); super.visitCode(obj); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-15 00:34:15
|
Revision: 443 Author: dbrosius Date: 2006-04-14 17:34:07 -0700 (Fri, 14 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=443&view=rev Log Message: ----------- add copyright Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-14 23:32:27 UTC (rev 442) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-15 00:34:07 UTC (rev 443) @@ -1,3 +1,21 @@ +/* + * fb-contrib - Auxilliary detectors for Java programs + * Copyright (C) 2005-2006 Dave Brosius + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.mebigfatguy.fbcontrib.detect; import java.util.HashMap; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dbr...@us...> - 2006-04-19 00:57:14
|
Revision: 490 Author: dbrosius Date: 2006-04-18 17:57:10 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=490&view=rev Log Message: ----------- Manually cleanup memory now that StatelessDetector is removed. Modified Paths: -------------- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-19 00:56:13 UTC (rev 489) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/NonRecycleableTaglibs.java 2006-04-19 00:57:10 UTC (rev 490) @@ -33,14 +33,14 @@ import edu.umd.cs.findbugs.BytecodeScanningDetector; import edu.umd.cs.findbugs.FieldAnnotation; import edu.umd.cs.findbugs.SourceLineAnnotation; -import edu.umd.cs.findbugs.StatelessDetector; import edu.umd.cs.findbugs.ba.ClassContext; /** * looks for tag libraries that are not recycleable because backing members of taglib attributes are * set in areas besides the setter method for the attribute. */ -public class NonRecycleableTaglibs extends BytecodeScanningDetector implements StatelessDetector { +public class NonRecycleableTaglibs extends BytecodeScanningDetector +{ private static final int MAX_ATTRIBUTE_CODE_LENGTH = 60; private static final Set<String> tagClasses = new HashSet<String>(); @@ -84,17 +84,6 @@ } /** - * clone this detector so that it can be a StatelessDetector. - * - * @return a clone of this object - * @throws CloneNotSupportedException never - */ - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - /** * implements the visitor to look for classes that extend the TagSupport or BodyTagSupport class * * @param classContext the context object for the currently parsed class This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |