本文整理汇总了Java中org.apache.bcel.Constants.IFNONNULL属性的典型用法代码示例。如果您正苦于以下问题:Java Constants.IFNONNULL属性的具体用法?Java Constants.IFNONNULL怎么用?Java Constants.IFNONNULL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.bcel.Constants
的用法示例。
在下文中一共展示了Constants.IFNONNULL属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: analyzeMethod
private void analyzeMethod(ClassContext classContext, Method method)
throws CFGBuilderException, DataflowAnalysisException {
if (DEBUG) System.out.println("Clearing redundant branch information");
redundantBranchList.clear();
definitelySameBranchSet.clear();
definitelyDifferentBranchSet.clear();
undeterminedBranchSet.clear();
if (DEBUG)
System.out.println(SignatureConverter.convertMethodSignature(classContext.getMethodGen(method)));
// Get the IsNullValueAnalysis for the method from the ClassContext
IsNullValueDataflow invDataflow = classContext.getIsNullValueDataflow(method);
// Look for null check blocks where the reference being checked
// is definitely null, or null on some path
Iterator<BasicBlock> bbIter = invDataflow.getCFG().blockIterator();
while (bbIter.hasNext()) {
BasicBlock basicBlock = bbIter.next();
if (basicBlock.isNullCheck()) {
analyzeNullCheck(classContext, method, invDataflow, basicBlock);
} else if (!basicBlock.isEmpty()) {
// Look for all reference comparisons where
// - both values compared are definitely null, or
// - one value is definitely null and one is definitely not null
// These cases are not null dereferences,
// but they are quite likely to indicate an error, so while we've got
// information about null values, we may as well report them.
InstructionHandle lastHandle = basicBlock.getLastInstruction();
Instruction last = lastHandle.getInstruction();
switch (last.getOpcode()) {
case Constants.IF_ACMPEQ:
case Constants.IF_ACMPNE:
analyzeRefComparisonBranch(method, invDataflow, basicBlock, lastHandle);
break;
case Constants.IFNULL:
case Constants.IFNONNULL:
analyzeIfNullBranch(method, invDataflow, basicBlock, lastHandle);
break;
}
}
}
Iterator<RedundantBranch> i = redundantBranchList.iterator();
while (i.hasNext()) {
RedundantBranch redundantBranch = i.next();
if (DEBUG) System.out.println("Redundant branch: " + redundantBranch);
InstructionHandle handle = redundantBranch.handle;
int lineNumber = redundantBranch.lineNumber;
// The source to bytecode compiler may sometimes duplicate blocks of
// code along different control paths. So, to report the bug,
// we check to ensure that the branch is REALLY determined each
// place it is duplicated, and that it is determined in the same way.
if (!undeterminedBranchSet.get(lineNumber) &&
!(definitelySameBranchSet.get(lineNumber) && definitelyDifferentBranchSet.get(lineNumber))) {
reportRedundantNullCheck(classContext, method, handle, redundantBranch);
}
}
}