boolean changed = false;
boolean ASSUME_ASSERTIONS_ENABLED = true;
if (ASSUME_ASSERTIONS_ENABLED) {
LinkedList<Edge> edgesToRemove = new LinkedList<Edge>();
for (Iterator<Edge> i = cfg.edgeIterator(); i.hasNext();) {
Edge e = i.next();
if (e.getType() == EdgeTypes.IFCMP_EDGE) {
try {
BasicBlock source = e.getSource();
InstructionHandle last = source.getLastInstruction();
Instruction lastInstruction = last.getInstruction();
InstructionHandle prev = last.getPrev();
Instruction prevInstruction = prev.getInstruction();
if (prevInstruction instanceof GETSTATIC && lastInstruction instanceof IFNE) {
GETSTATIC getStatic = (GETSTATIC) prevInstruction;
if (getStatic.getFieldName(methodGen.getConstantPool()).equals("$assertionsDisabled")
&& getStatic.getSignature(methodGen.getConstantPool()).equals("Z")) {
edgesToRemove.add(e);
}
}
} catch (RuntimeException exception) {
assert true; // ignore it
}
}
}
if (edgesToRemove.size() > 0) {
changed = true;
for (Edge e : edgesToRemove) {
cfg.removeEdge(e);
}
}
}
cfg.setFlag(CFG.PRUNED_FAILED_ASSERTION_EDGES);
final boolean PRUNE_INFEASIBLE_EXCEPTION_EDGES = AnalysisContext.currentAnalysisContext().getBoolProperty(
AnalysisFeatures.ACCURATE_EXCEPTIONS);
if (PRUNE_INFEASIBLE_EXCEPTION_EDGES && !cfg.isFlagSet(CFG.PRUNED_INFEASIBLE_EXCEPTIONS)) {
try {
TypeDataflow typeDataflow = analysisCache.getMethodAnalysis(TypeDataflow.class, descriptor);
// Exception edge pruning based on ExceptionSets.
// Note: this is quite slow.
PruneInfeasibleExceptionEdges pruner = new PruneInfeasibleExceptionEdges(cfg, methodGen, typeDataflow);
pruner.execute();
changed = changed || pruner.wasCFGModified();
} catch (MissingClassException e) {
AnalysisContext.currentAnalysisContext().getLookupFailureCallback()
.reportMissingClass(e.getClassNotFoundException());
} catch (DataflowAnalysisException e) {
AnalysisContext.currentAnalysisContext().getLookupFailureCallback()
.logError("unable to extract type analysis", e);
} catch (ClassNotFoundException e) {
AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e);