Be explicit when the proper default for a switch is to do nothing
Of course, doing nothing isn't always the right behavior. Sometimes a previously-unhandled value is truly unexpected and one should fail by throwing an exception. It may not always be clear whether an exception or doing nothing is the right choice. For some `switch` statements affected by this commit, I initially guessed that throwing an exception was the right default behavior, but was proven wrong when doing so caused WALA regression test failures. That's strong evidence that the unmatched values were not really unexpected, but merely should have been handled by doing nothing as before.
This commit is contained in:
parent
ab791f8c41
commit
da5f925cab
|
@ -816,6 +816,8 @@ public class ClosureExtractor extends CAstRewriterExt {
|
|||
case CAstNode.CALL:
|
||||
case CAstNode.NEW:
|
||||
return false;
|
||||
default:
|
||||
// fall through to generic handlers below
|
||||
}
|
||||
for(int i=0;i<node.getChildCount();++i)
|
||||
if(!noJumpsAndNoCalls(node.getChild(i)))
|
||||
|
|
|
@ -1127,6 +1127,9 @@ public class PDG<T extends InstanceKey> implements NumberedGraph<Statement> {
|
|||
case HEAP_RET_CALLER:
|
||||
HeapStatement h = (HeapStatement) N;
|
||||
createHeapDataDependenceEdges(h.getLocation());
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1147,6 +1150,9 @@ public class PDG<T extends InstanceKey> implements NumberedGraph<Statement> {
|
|||
case HEAP_RET_CALLER:
|
||||
HeapStatement h = (HeapStatement) N;
|
||||
createHeapDataDependenceEdges(h.getLocation());
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ public class JavaScriptEclipseProjectPath extends EclipseProjectPath<IIncludePat
|
|||
resolveSourcePathEntry(JSLoader.JAVASCRIPT, true, cpeFromMainProject, e.getPath(), null, e.getExclusionPatterns(), "js");
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException(String.format("unexpected classpath entry kind %s", entryKind));
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -299,12 +299,8 @@ public class OfflineDynamicCallGraph {
|
|||
case CONSTANT_Class:
|
||||
entries.put(new CWStringItem(p.getCPClass(i), CONSTANT_Class), i);
|
||||
break;
|
||||
case CONSTANT_MethodHandle:
|
||||
case CONSTANT_MethodType:
|
||||
case CONSTANT_InvokeDynamic:
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException(String.format("unexpected constant-pool item type %s", itemType));
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1010,7 +1010,7 @@ public abstract class Compiler implements Constants {
|
|||
curOffset += 2;
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException(String.format("unexpected instruction opcode %s", opcode));
|
||||
// do nothing
|
||||
}
|
||||
} else {
|
||||
stackLenRef[0] = stackLen;
|
||||
|
|
Loading…
Reference in New Issue