if null java,Java Constants.IFNULL属性代码示例

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

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
帮我审查一下下带private Map<String, ItemsCustomTargetResult> getItemsCustomTargetResult(BidNodeViewDto bidNodeViewDto, Map<String, String> targetCodeMap) { Map<String, ItemsCustomTargetResult> itemsCustomTargetResultMap = new HashMap<>(); List<String> colName = new ArrayList<>(); colName.add(Constants.ProjectView.COL_NAME_EXPRESSION); colName.add(Constants.ProjectView.COL_NAME_EXPERSSION_VALUE); colName.add(Constants.ProjectView.COL_NAME_TOTAL); colName.add(Constants.ProjectView.COL_NAME_PERCENT); colName.add(Constants.ProjectView.COL_NAME_UNIT); for(String name : colName) { String value = null; if (Constants.ProjectView.COL_NAME_EXPRESSION.equals(name)) { value = bidNodeViewDto.getExpressionName() + ""; }else if(Constants.ProjectView.COL_NAME_EXPERSSION_VALUE.equals(name)) { value = bidNodeViewDto.getExpressionVal() + ""; }else if(Constants.ProjectView.COL_NAME_PERCENT.equals(name)) { value = bidNodeViewDto.getPercentTotal() + ""; }else if(Constants.ProjectView.COL_NAME_TOTAL.equals(name)) { value = bidNodeViewDto.getAmount() + ""; }else if(Constants.ProjectView.COL_NAME_UNIT.equals(name)) { value = bidNodeViewDto.getUnitIndex() + ""; } String targetCode = targetCodeMap.get(name); if(Strings.isBlank(targetCode)) { continue; } ItemsCustomTargetResult itemsCustomTargetResult = new ItemsCustomTargetResult(); itemsCustomTargetResultMap.put(targetCode,itemsCustomTargetResult.obtainItemsCustomTargetResult(targetCode, null, value, null)); } return itemsCustomTargetResultMap; }
06-10

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值