This commit is contained in:
Julian Dolby 2017-08-15 18:01:41 -04:00
commit 4a33c527d2
34 changed files with 138 additions and 82 deletions

View File

@ -48,7 +48,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=error
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore

View File

@ -38,7 +38,6 @@ public class Switch1 {
}
}
@SuppressWarnings("incomplete-switch")
public void testThree(String[] args) {
char ch = '?';
switch(Integer.parseInt(args[0])) {

View File

@ -39,7 +39,7 @@ package foo.bar.hello.world;
public class Misc {
@SuppressWarnings({ "cast", "incomplete-switch" })
@SuppressWarnings("cast")
public static void main(String args[]) {
if ( "hello" instanceof Object ) {
System.out.println("strings are objects in java");

View File

@ -47,7 +47,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.localVariableHiding=error
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=error
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=error
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error

View File

@ -1185,8 +1185,9 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
case Token.DEBUGGER: {
return Ast.makeConstant(null);
}
default:
throw new RuntimeException("unexpected keyword literal " + node + " (" + node.getType() +")");
}
throw new RuntimeException("unexpected keyword literal " + node + " (" + node.getType() +")");
}
@Override

View File

@ -47,7 +47,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.localVariableHiding=error
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=error
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=error
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error

View File

@ -25,6 +25,7 @@ import com.ibm.wala.cast.js.callgraph.fieldbased.WorklistBasedOptimisticCallgrap
import com.ibm.wala.cast.js.callgraph.fieldbased.flowgraph.vertices.ObjectVertex;
import com.ibm.wala.cast.js.html.JSSourceExtractor;
import com.ibm.wala.cast.js.html.WebPageLoaderFactory;
import com.ibm.wala.cast.js.ipa.callgraph.JSAnalysisOptions;
import com.ibm.wala.cast.js.ipa.callgraph.JSCallGraph;
import com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil;
import com.ibm.wala.cast.js.loader.JavaScriptLoader;
@ -54,7 +55,34 @@ import com.ibm.wala.util.functions.Function;
*
*/
public class FieldBasedCGUtil {
public static enum BuilderType { PESSIMISTIC, OPTIMISTIC, OPTIMISTIC_WORKLIST }
public static enum BuilderType {
PESSIMISTIC {
@Override
protected FieldBasedCallGraphBuilder fieldBasedCallGraphBuilderFactory(IClassHierarchy cha,
final JSAnalysisOptions makeOptions, IAnalysisCacheView cache, boolean supportFullPointerAnalysis) {
return new PessimisticCallGraphBuilder(cha, makeOptions, cache, supportFullPointerAnalysis);
}
},
OPTIMISTIC {
@Override
protected FieldBasedCallGraphBuilder fieldBasedCallGraphBuilderFactory(IClassHierarchy cha,
JSAnalysisOptions makeOptions, IAnalysisCacheView cache, boolean supportFullPointerAnalysis) {
return new OptimisticCallgraphBuilder(cha, makeOptions, cache, supportFullPointerAnalysis);
}
},
OPTIMISTIC_WORKLIST {
@Override
protected FieldBasedCallGraphBuilder fieldBasedCallGraphBuilderFactory(IClassHierarchy cha,
JSAnalysisOptions makeOptions, IAnalysisCacheView cache, boolean supportFullPointerAnalysis) {
return new WorklistBasedOptimisticCallgraphBuilder(cha, makeOptions, cache, supportFullPointerAnalysis);
}
};
protected abstract FieldBasedCallGraphBuilder fieldBasedCallGraphBuilderFactory(IClassHierarchy cha,
JSAnalysisOptions makeOptions, IAnalysisCacheView cache, boolean supportFullPointerAnalysis);
}
private final JavaScriptTranslatorFactory translatorFactory;
@ -100,21 +128,9 @@ public class FieldBasedCGUtil {
IClassHierarchy cha = ClassHierarchyFactory.make(scope, loaders, JavaScriptLoader.JS);
Util.checkForFrontEndErrors(cha);
Iterable<Entrypoint> roots = JSCallGraphUtil.makeScriptRoots(cha);
FieldBasedCallGraphBuilder builder = null;
IAnalysisCacheView cache = new AnalysisCacheImpl(AstIRFactory.makeDefaultFactory());
switch(builderType) {
case PESSIMISTIC:
builder = new PessimisticCallGraphBuilder(cha, JSCallGraphUtil.makeOptions(scope, cha, roots), cache, supportFullPointerAnalysis);
break;
case OPTIMISTIC:
builder = new OptimisticCallgraphBuilder(cha, JSCallGraphUtil.makeOptions(scope, cha, roots), cache, supportFullPointerAnalysis);
break;
case OPTIMISTIC_WORKLIST:
builder = new WorklistBasedOptimisticCallgraphBuilder(cha, JSCallGraphUtil.makeOptions(scope, cha, roots), cache, supportFullPointerAnalysis);
break;
}
final FieldBasedCallGraphBuilder builder = builderType.fieldBasedCallGraphBuilderFactory(cha,
JSCallGraphUtil.makeOptions(scope, cha, roots), cache, supportFullPointerAnalysis);
return builder.buildCallGraph(roots, monitor);
}

View File

@ -47,7 +47,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=error
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=error
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error

View File

@ -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)))

View File

@ -38,7 +38,7 @@ org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=error
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled

View File

@ -49,7 +49,7 @@ org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=error
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
@ -58,7 +58,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=error
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=error
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error

View File

@ -167,6 +167,8 @@ public class ArrayBoundsGraphBuilder {
this.upperBoundGraph.addEdge(piParent, piVar);
break;
default:
throw new UnsupportedOperationException(String.format("unexpected operator %s", op));
}
}

View File

@ -159,7 +159,8 @@ public class Util {
*/
public static <I, T extends IBasicBlock<I>> T resolveBranch(ControlFlowGraph<I, T> G, T bb, int c1, int c2) {
SSAConditionalBranchInstruction c = (SSAConditionalBranchInstruction) getLastInstruction(G, bb);
switch ((ConditionalBranchInstruction.Operator) c.getOperator()) {
final ConditionalBranchInstruction.Operator operator = (ConditionalBranchInstruction.Operator) c.getOperator();
switch (operator) {
case EQ:
if (c1 == c2)
return getTakenSuccessor(G, bb);
@ -190,10 +191,9 @@ public class Util {
return getTakenSuccessor(G, bb);
else
return getNotTakenSuccessor(G, bb);
default:
throw new UnsupportedOperationException(String.format("unexpected operator %s", operator));
}
Assertions.UNREACHABLE();
return null;
}
/**

View File

@ -84,6 +84,8 @@ public class ParameterState extends AbstractVariable<ParameterState> {
throw new IllegalArgumentException("Try to set " + prev + " to " + state);
}
break;
default:
throw new UnsupportedOperationException(String.format("unexpected previous state %s", prev));
}
}
params.put(varNum, state);

View File

@ -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
}
}

View File

@ -317,7 +317,8 @@ public final class TypeName implements Serializable {
boolean isPrimitive = (dim==-1) || (dim&ElementMask)==PrimitiveMask;
if (dim != -1) {
for (int d = (dim&ElementMask) == PrimitiveMask? dim>>ElementBits: dim; d != 0; d>>=ElementBits) {
switch (d&ElementMask) {
final int masked = d&ElementMask;
switch (masked) {
case ArrayMask:
result.append("[");
break;
@ -327,6 +328,8 @@ public final class TypeName implements Serializable {
case ReferenceMask:
result.append("&");
break;
default:
throw new UnsupportedOperationException(String.format("unexpected masked type-name component %X", masked));
}
}
}

View File

@ -46,12 +46,12 @@ org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=error
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=error
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=error
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error

View File

@ -169,8 +169,9 @@ public class BinaryLiteralOperation extends Instruction {
return IBinaryOpInstruction.Operator.DIV;
case REM_DOUBLE:
return IBinaryOpInstruction.Operator.REM;
default:
return null;
}
return null;
}
public boolean isFloat()

View File

@ -166,8 +166,9 @@ public class BinaryOperation extends Instruction {
return IBinaryOpInstruction.Operator.DIV;
case REM_DOUBLE:
return IBinaryOpInstruction.Operator.REM;
default:
return null;
}
return null;
}
public boolean isFloat()
{

View File

@ -138,8 +138,10 @@ public class Intent implements ContextItem, Comparable<Intent> {
explicit = Explicit.EXPLICIT;
break;
case EXPLICIT:
unbind();
break;
default:
throw new UnsupportedOperationException(String.format("unexpected explicitness setting %s", explicit));
}
}

View File

@ -20,7 +20,7 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=error
org.eclipse.jdt.core.compiler.problem.deadCode=error
org.eclipse.jdt.core.compiler.problem.deprecation=warning
@ -48,7 +48,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=error
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=error
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error

View File

@ -77,7 +77,8 @@ public class JavaEclipseProjectPath extends EclipseProjectPath<IClasspathEntry,
@Override
protected void resolveClasspathEntry(IJavaProject project, IClasspathEntry entry, ILoader loader, boolean includeSource, boolean cpeFromMainProject) {
entry = JavaCore.getResolvedClasspathEntry(entry);
switch (entry.getEntryKind()) {
final int entryKind = entry.getEntryKind();
switch (entryKind) {
case IClasspathEntry.CPE_SOURCE: {
resolveSourcePathEntry(includeSource? JavaSourceLoader.SOURCE: Loader.APPLICATION, includeSource, cpeFromMainProject, entry.getPath(), entry.getOutputLocation(), entry.getExclusionPatterns()
, "java");
@ -101,7 +102,10 @@ public class JavaEclipseProjectPath extends EclipseProjectPath<IClasspathEntry,
System.err.println(e);
Assertions.UNREACHABLE();
}
break;
}
default:
throw new UnsupportedOperationException(String.format("unexpected classpath entry kind %s", entryKind));
}
}

View File

@ -48,7 +48,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=error
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=error
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error

View File

@ -102,9 +102,13 @@ public class JavaScriptEclipseProjectPath extends EclipseProjectPath<IIncludePat
ILoader loader,
boolean includeSource, boolean cpeFromMainProject) {
IIncludePathEntry e = JavaScriptCore.getResolvedIncludepathEntry(entry);
switch (e.getEntryKind()) {
final int entryKind = e.getEntryKind();
switch (entryKind) {
case IIncludePathEntry.CPE_SOURCE:
resolveSourcePathEntry(JSLoader.JAVASCRIPT, true, cpeFromMainProject, e.getPath(), null, e.getExclusionPatterns(), "js");
break;
default:
// do nothing
}
}

View File

@ -38,7 +38,7 @@ org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=error
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=error
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
@ -47,7 +47,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=error
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=error
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error

View File

@ -77,19 +77,7 @@ public class IFDSExplorer {
System.err.println("Domain:\n" + r.getProblem().getDomain().toString());
}
String irFileName = null;
switch (DotUtil.getOutputType()) {
case PDF:
irFileName = "ir.pdf";
break;
case PS:
case EPS:
irFileName = "ir.ps";
break;
case SVG:
irFileName = "ir.svg";
break;
}
String irFileName = "ir." + DotUtil.getOutputType().suffix;
String outputFile = scratchDirectory + File.separatorChar + irFileName;
String dotFile = scratchDirectory + File.separatorChar + "ir.dt";

View File

@ -39,7 +39,7 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=error
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=error
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
org.eclipse.jdt.core.compiler.problem.fallthroughCase=error
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=error
org.eclipse.jdt.core.compiler.problem.finalParameterBound=error
@ -57,7 +57,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=error
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=error
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error

View File

@ -276,7 +276,8 @@ public class OfflineDynamicCallGraph {
{
ConstantPoolParser p = r.getCP();
for(int i = 1; i < p.getItemCount(); i++) {
switch (p.getItemType(i)) {
final byte itemType = p.getItemType(i);
switch (itemType) {
case CONSTANT_Integer:
entries.put(new Integer(p.getCPInt(i)), i);
break;
@ -298,9 +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:
default:
// do nothing
}
}
}

View File

@ -262,8 +262,9 @@ public class CopyWriter {
return w.addCPDouble(cp.getCPDouble(i));
case ClassConstants.CONSTANT_Utf8:
return w.addCPUtf8(cp.getCPUtf8(i));
default:
return -1;
}
return -1;
}
private void doClass(final ClassInstrumenter ci) throws Exception {
@ -292,7 +293,8 @@ public class CopyWriter {
int CPCount = cp.getItemCount();
if (1 < CPCount) {
switch (cp.getItemType(1)) {
final byte itemType = cp.getItemType(1);
switch (itemType) {
case ClassConstants.CONSTANT_Long:
case ClassConstants.CONSTANT_Double:
// item 1 is a double-word item, so the next real item is at 3
@ -302,6 +304,8 @@ public class CopyWriter {
if (r != 2)
throw new Error("Invalid constant pool index for dummy: " + r);
break;
default:
throw new UnsupportedOperationException(String.format("unexpected constant-pool item type %s", itemType));
}
}
for (int i = 2; i < CPCount; i++) {

View File

@ -579,6 +579,7 @@ public abstract class Compiler implements Constants {
if (!fallToConditional) {
break;
}
//$FALL-THROUGH$
case OP_aconst_null:
if (!fallToConditional && inBasicBlock(i, 2) && instructions[i + 1] instanceof ConditionalBranchInstruction) {
ConditionalBranchInstruction cbr = (ConditionalBranchInstruction) instructions[i + 1];
@ -593,6 +594,7 @@ public abstract class Compiler implements Constants {
break;
}
// by Xiangyu
//$FALL-THROUGH$
case OP_ifeq:
case OP_ifge:
case OP_ifgt:
@ -798,6 +800,7 @@ public abstract class Compiler implements Constants {
break;
}
}
//$FALL-THROUGH$
case OP_lload:
case OP_fload:
case OP_dload:
@ -1009,6 +1012,8 @@ public abstract class Compiler implements Constants {
writeShort(curOffset, allocateConstantPoolClassType(((InstanceofInstruction) instr).getType()));
curOffset += 2;
break;
default:
// do nothing
}
} else {
stackLenRef[0] = stackLen;

View File

@ -262,6 +262,8 @@ public class ClassWriter implements ClassConstants {
case CONSTANT_Utf8:
cachedCPEntries.put(cp.getCPUtf8(i), new Integer(i));
break;
default:
throw new UnsupportedOperationException(String.format("unexpected constant-pool item type %s", t));
}
}
}
@ -763,8 +765,9 @@ public class ClassWriter implements ClassConstants {
case CONSTANT_MethodHandle: {
offset = reserveBuf(4);
CWHandle handle = (CWHandle) item;
setUByte(buf, offset + 1, handle.getKind());
switch (handle.getKind()) {
final byte kind = handle.getKind();
setUByte(buf, offset + 1, kind);
switch (kind) {
case REF_getStatic:
case REF_getField:
case REF_putField:
@ -790,6 +793,8 @@ public class ClassWriter implements ClassConstants {
setUShort(buf, offset + 2, x);
break;
}
default:
throw new UnsupportedOperationException(String.format("unexpected ref kind %s", kind));
}
break;
}

View File

@ -17,6 +17,8 @@
package com.ibm.wala.sourcepos;
import com.ibm.wala.sourcepos.InvalidRangeException.Cause;
/**
* This class represents an entry in the CharacterRangeTable.
*
@ -117,13 +119,16 @@ public final class CRTData {
try {
range = new Range(source_start, source_end);
} catch (InvalidRangeException e) {
switch (e.getThisCause()) {
final Cause cause = e.getThisCause();
switch (cause) {
case END_BEFORE_START:
throw new InvalidCRTDataException(WARN_END_BEFORE_START, source_start.toString(), source_end.toString());
case START_UNDEFINED:
throw new InvalidCRTDataException(WARN_START_UNDEFINED);
case END_UNDEFINED:
throw new InvalidCRTDataException(WARN_END_UNDEFINED);
default:
throw new UnsupportedOperationException(String.format("cannot convert %s into an InvalidCRTDataException", cause));
}
} finally {
this.source_positions = range;

View File

@ -20,6 +20,8 @@ package com.ibm.wala.sourcepos;
import java.io.DataInputStream;
import java.io.IOException;
import com.ibm.wala.sourcepos.InvalidRangeException.Cause;
/**
* This class represents the MethodPositions attribute.
*
@ -43,6 +45,8 @@ public final class MethodPositions extends PositionsAttribute {
private static final String ERR_END_BEFORE_START = "Error in MethodPositions attribute: %2$s (%4$s) is before %1$s (%3$s).";
private static final String ERR_UNKNOWN_REASON = "Error in MethodPositions attribute: unknown reason %1$s.";
private static final String WARN_INVALID_BLOCK_END = "Warning in MethodPositions attribute: Invalid method block end position.";
private static final String WARN_PARAMETER_NOT_IN_DECLARATION = "Warning in MethodPositions attribute: Parameter not in the declaration range.";
@ -117,13 +121,19 @@ public final class MethodPositions extends PositionsAttribute {
try {
range = new Range(start, end);
} catch (InvalidRangeException e) {
switch (e.getThisCause()) {
final Cause thisCause = e.getThisCause();
switch (thisCause) {
case END_BEFORE_START:
Debug.warn(ERR_END_BEFORE_START, startVarName, endVarName, start, end);
break;
case START_UNDEFINED:
Debug.warn(ERR_POSITION_UNDEFINED, startVarName);
break;
case END_UNDEFINED:
Debug.warn(ERR_POSITION_UNDEFINED, endVarName);
break;
default:
Debug.warn(ERR_UNKNOWN_REASON, thisCause);
}
}
}

View File

@ -20,7 +20,6 @@ import java.util.Iterator;
import com.ibm.wala.util.WalaException;
import com.ibm.wala.util.collections.Iterator2Collection;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.graph.Graph;
/**
@ -33,7 +32,16 @@ public class DotUtil {
*
*/
public static enum DotOutputType {
PS, SVG, PDF, EPS
PS("ps"),
SVG("svg"),
PDF("pdf"),
EPS("eps");
public final String suffix;
DotOutputType(final String suffix) {
this.suffix = suffix;
}
}
private static DotOutputType outputType = DotOutputType.PDF;
@ -51,19 +59,7 @@ public class DotUtil {
}
private static String outputTypeCmdLineParam() {
switch (outputType) {
case PS:
return "-Tps";
case EPS:
return "-Teps";
case SVG:
return "-Tsvg";
case PDF:
return "-Tpdf";
default:
Assertions.UNREACHABLE();
return null;
}
return "-T" + outputType.suffix;
}
/**