[Fb-contrib-commit] SF.net SVN: fb-contrib: [608] trunk/fb-contrib/samples
Brought to you by:
dbrosius
From: <dbr...@us...> - 2006-08-12 01:15:35
|
Revision: 608 Author: dbrosius Date: 2006-08-11 18:15:27 -0700 (Fri, 11 Aug 2006) ViewCVS: http://svn.sourceforge.net/fb-contrib/?rev=608&view=rev Log Message: ----------- fix some false positives with LEST Modified Paths: -------------- trunk/fb-contrib/samples/LEST_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java Modified: trunk/fb-contrib/samples/LEST_Sample.java =================================================================== --- trunk/fb-contrib/samples/LEST_Sample.java 2006-08-12 00:47:46 UTC (rev 607) +++ trunk/fb-contrib/samples/LEST_Sample.java 2006-08-12 01:15:27 UTC (rev 608) @@ -30,4 +30,32 @@ throw new IllegalArgumentException(pe.getMessage(), pe); } } + + public Date testLestFP1(String input) throws ParseException + { + try + { + DateFormat df = new SimpleDateFormat("YYYY"); + return df.parse(input); + } + catch (ParseException pe) + { + throw pe; + } + } + + public Date testLestFP2(String input) + { + try + { + DateFormat df = new SimpleDateFormat("YYYY"); + return df.parse(input); + } + catch (ParseException pe) + { + IllegalArgumentException iae = new IllegalArgumentException(pe.getMessage()); + iae.initCause(pe); + throw iae; + } + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-12 00:47:46 UTC (rev 607) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2006-08-12 01:15:27 UTC (rev 608) @@ -20,9 +20,11 @@ import java.util.ArrayList; import java.util.BitSet; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import org.apache.bcel.Constants; @@ -32,6 +34,7 @@ import org.apache.bcel.classfile.JavaClass; import org.apache.bcel.classfile.Method; +import com.mebigfatguy.fbcontrib.utils.Integer14; import com.mebigfatguy.fbcontrib.utils.RegisterUtils; import edu.umd.cs.findbugs.BugInstance; @@ -60,6 +63,7 @@ private OpcodeStack stack; private CodeException[] exceptions; private Set<CatchInfo> catchInfos; + private Map<Integer, Boolean> exReg; /** * constructs a LEST detector given the reporter to report bugs on @@ -82,12 +86,14 @@ if ((throwableClass != null) && (majorVersion >= Constants.MAJOR_1_4)) { stack = new OpcodeStack(); catchInfos = new HashSet<CatchInfo>(); + exReg = new HashMap<Integer, Boolean>(); super.visitClassContext(classContext); } } finally { stack = null; catchInfos = null; exceptions = null; + exReg = null; } } @@ -121,6 +127,7 @@ stack.resetForMethodEntry(this); catchInfos.clear(); exceptions = collectExceptions(obj.getExceptionTable()); + exReg.clear(); super.visitCode(obj); } } @@ -168,7 +175,9 @@ CatchInfo catchInfo = it.next(); if (pc == catchInfo.getStart()) { if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { - catchInfo.setReg(RegisterUtils.getAStoreReg(this, seen)); + int reg = RegisterUtils.getAStoreReg(this, seen); + catchInfo.setReg(reg); + exReg.put(Integer14.valueOf(reg), Boolean.TRUE); break; } } else if (pc > catchInfo.getFinish()) { @@ -190,7 +199,13 @@ String className = getClassConstantOperand(); JavaClass exClass = Repository.lookupClass(className); if (exClass.instanceOf(throwableClass)) { - markAsValid = true; + if (stack.getStackDepth() > 1) { + OpcodeStack.Item itm = stack.getStackItem(1); + int reg = itm.getRegisterNumber(); + if (reg >= 0) + exReg.put(Integer14.valueOf(reg), Boolean.TRUE); + markAsValid = true; // Fixes javac generated code + } } } else if (seen == ATHROW) { if (stack.getStackDepth() > 0) { @@ -205,6 +220,15 @@ break; } } + } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + exReg.put(Integer14.valueOf(RegisterUtils.getAStoreReg(this, seen)), (Boolean)itm.getUserValue()); + } + } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) { + Boolean valid = exReg.get(Integer14.valueOf(RegisterUtils.getALoadReg(this, seen))); + if (valid != null) + markAsValid = valid.booleanValue(); } } } catch (ClassNotFoundException cnfe) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |