[Fb-contrib-commit] SF.net SVN: fb-contrib:[1600] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2010-08-31 01:27:01
|
Revision: 1600
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1600&view=rev
Author: dbrosius
Date: 2010-08-31 01:26:54 +0000 (Tue, 31 Aug 2010)
Log Message:
-----------
weaken the LEST report, when the situation looks like it's synthetic, for instance throwing exceptions out of synchronized blocks
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2010-08-31 01:10:22 UTC (rev 1599)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LostExceptionStackTrace.java 2010-08-31 01:26:54 UTC (rev 1600)
@@ -85,7 +85,7 @@
@Override
public void visitClassContext(ClassContext classContext) {
try {
- if ((throwableClass != null) && (!isPre14Class(classContext.getJavaClass()))) {
+ if (throwableClass != null && !isPre14Class(classContext.getJavaClass())) {
stack = new OpcodeStack();
catchInfos = new HashSet<CatchInfo>();
exReg = new HashMap<Integer, Boolean>();
@@ -113,13 +113,13 @@
}
CodeException[] ce = code.getExceptionTable();
- if ((ce == null) || (ce.length == 0))
+ if (ce == null || ce.length == 0)
{
return false;
}
BitSet bytecodeSet = getClassContext().getBytecodeSet(method);
- return (bytecodeSet != null) && (bytecodeSet.get(Constants.ATHROW));
+ return bytecodeSet != null && bytecodeSet.get(Constants.ATHROW);
}
/**
@@ -148,7 +148,7 @@
public CodeException[] collectExceptions(CodeException[] exs) {
List<CodeException> filteredEx = new ArrayList<CodeException>();
for (CodeException ce : exs) {
- if ((ce.getCatchType() != 0) && (ce.getStartPC() < ce.getEndPC()) && (ce.getEndPC() <= ce.getHandlerPC())) {
+ if (ce.getCatchType() != 0 && ce.getStartPC() < ce.getEndPC() && ce.getEndPC() <= ce.getHandlerPC()) {
filteredEx.add(ce);
}
}
@@ -168,11 +168,11 @@
int pc = getPC();
for (CodeException ex : exceptions) {
if (pc == ex.getEndPC()) {
- if ((seen >= IRETURN) && (seen <= RETURN))
+ if (seen >= IRETURN && seen <= RETURN)
{
addCatchBlock(ex.getHandlerPC(), Integer.MAX_VALUE);
}
- else if ((seen == GOTO) || (seen == GOTO_W))
+ else if (seen == GOTO || seen == GOTO_W)
{
addCatchBlock(ex.getHandlerPC(), this.getBranchTarget());
}
@@ -198,15 +198,15 @@
} else if (pc > catchInfo.getFinish()) {
it.remove();
break;
- } else if ((pc > catchInfo.getStart()) && (pc <= catchInfo.getFinish())) {
+ } else if (pc > catchInfo.getStart() && pc <= catchInfo.getFinish()) {
if (seen == INVOKESPECIAL) {
if ("<init>".equals(getNameConstantOperand())) {
String className = getClassConstantOperand();
JavaClass exClass = Repository.lookupClass(className);
if (exClass.instanceOf(throwableClass)) {
String sig = getSigConstantOperand();
- if ((sig.indexOf("Exception") >= 0)
- || (sig.indexOf("Throwable") >= 0)) {
+ if (sig.indexOf("Exception") >= 0
+ || sig.indexOf("Throwable") >= 0) {
markAsValid = true;
break;
}
@@ -234,7 +234,7 @@
} else if (isPossibleExBuilder(catchInfo.getRegister())) {
markAsValid = true;
}
- } else if ((seen == INVOKEINTERFACE) || (seen == INVOKESTATIC)) {
+ } else if (seen == INVOKEINTERFACE || seen == INVOKESTATIC) {
if (isPossibleExBuilder(catchInfo.getRegister()))
{
markAsValid = true;
@@ -242,11 +242,24 @@
} else if (seen == ATHROW) {
if (stack.getStackDepth() > 0) {
OpcodeStack.Item itm = stack.getStackItem(0);
- if ((itm.getRegisterNumber() != catchInfo.getRegister())
- && (itm.getUserValue() == null)) {
+ if (itm.getRegisterNumber() != catchInfo.getRegister()
+ && itm.getUserValue() == null) {
if (!isPre14Class(itm.getJavaClass()))
{
- bugReporter.reportBug(new BugInstance(this, "LEST_LOST_EXCEPTION_STACK_TRACE", NORMAL_PRIORITY)
+ int priority = NORMAL_PRIORITY;
+
+ LocalVariableTable lvt = getCode().getLocalVariableTable();
+ if (lvt != null) {
+ LocalVariable lv = lvt.getLocalVariable(itm.getRegisterNumber(), getPC());
+ if (lv == null) {
+ /** It's probably synthetic, for instance throwing an exception
+ * out of a synchronized block
+ */
+ priority = LOW_PRIORITY;
+ }
+ }
+
+ bugReporter.reportBug(new BugInstance(this, "LEST_LOST_EXCEPTION_STACK_TRACE", priority)
.addClass(this)
.addMethod(this)
.addSourceLine(this));
@@ -255,7 +268,7 @@
break;
}
}
- } else if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) {
+ } else if (seen == ASTORE || seen >= ASTORE_0 && seen <= ASTORE_3) {
if (lastWasExitPoint) {
//crazy jdk6 finally block injection -- shut off detection
catchInfos.clear();
@@ -266,17 +279,17 @@
OpcodeStack.Item itm = stack.getStackItem(0);
int reg = RegisterUtils.getAStoreReg(this, seen);
exReg.put(Integer.valueOf(reg), (Boolean)itm.getUserValue());
- if ((reg == catchInfo.getRegister() && catchInfo.getFinish() == Integer.MAX_VALUE)) {
+ if (reg == catchInfo.getRegister() && catchInfo.getFinish() == Integer.MAX_VALUE) {
it.remove();
}
}
- } else if ((seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3))) {
+ } else if (seen == ALOAD || seen >= ALOAD_0 && seen <= ALOAD_3) {
Boolean valid = exReg.get(Integer.valueOf(RegisterUtils.getALoadReg(this, seen)));
if (valid != null)
{
markAsValid = valid.booleanValue();
}
- } else if ((seen >= IRETURN) && (seen <= RETURN)) {
+ } else if (seen >= IRETURN && seen <= RETURN) {
removeIndeterminateHandlers(pc);
break;
}
@@ -287,7 +300,7 @@
}
}
- lastWasExitPoint = ((seen >= IRETURN) && (seen <= RETURN)) || (seen == GOTO) || (seen == GOTO_W) || (seen == ATHROW);
+ lastWasExitPoint = seen >= IRETURN && seen <= RETURN || seen == GOTO || seen == GOTO_W || seen == ATHROW;
}
finally {
stack.sawOpcode(this, seen);
@@ -336,7 +349,7 @@
*/
private boolean isPre14Class(JavaClass cls)
{
- return (cls != null) && cls.getMajor() < Constants.MAJOR_1_4;
+ return cls != null && cls.getMajor() < Constants.MAJOR_1_4;
}
private void removePreviousHandlers(int pc)
@@ -357,7 +370,7 @@
Iterator<CatchInfo> it = catchInfos.iterator();
while (it.hasNext()) {
CatchInfo ci = it.next();
- if ((ci.getStart() < pc) && (ci.getFinish() == Integer.MAX_VALUE))
+ if (ci.getStart() < pc && ci.getFinish() == Integer.MAX_VALUE)
{
it.remove();
}
@@ -376,7 +389,7 @@
* @return whether the catch block is empty
*/
private boolean updateExceptionRegister(CatchInfo ci, int seen, int pc) {
- if ((seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3))) {
+ if (seen == ASTORE || seen >= ASTORE_0 && seen <= ASTORE_3) {
int reg = RegisterUtils.getAStoreReg(this, seen);
ci.setReg(reg);
exReg.put(Integer.valueOf(reg), Boolean.TRUE);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|