final method java_Java XMethod.isFinal方法代碼示例

import edu.umd.cs.findbugs.ba.XMethod; //導入方法依賴的package包/類

@Override

public void sawOpcode(int seen) {

if (getMethodName().equals("") && seen == INVOKEVIRTUAL) {

XMethod m = getXMethodOperand();

if (m != null && !m.isPrivate() && !m.isFinal()) {

int args = PreorderVisitor.getNumberArguments(m.getSignature());

OpcodeStack.Item item = stack.getStackItem(args);

if (item.getRegisterNumber() == 0) {

try {

Set targets = Hierarchy2.resolveVirtualMethodCallTargets(m, false, false);

Subtypes2 subtypes2 = AnalysisContext.currentAnalysisContext().getSubtypes2();

for (XMethod called : targets) {

if (!called.isAbstract() && !called.equals(m)

&& subtypes2.isSubtype(called.getClassDescriptor(), getClassDescriptor()))

fieldSummary.setCalledFromSuperConstructor(new ProgramPoint(this), called);

}

} catch (ClassNotFoundException e) {

AnalysisContext.reportMissingClass(e);

}

}

}

}

if (seen == INVOKESPECIAL && getMethodName().equals("") && getNameConstantOperand().equals("")) {

String classOperand = getClassConstantOperand();

OpcodeStack.Item invokedOn = stack.getItemMethodInvokedOn(this);

if (invokedOn.getRegisterNumber() == 0 && !classOperand.equals(getClassName())) {

sawInitializeSuper = true;

XMethod invoked = getXMethodOperand();

if (invoked != null)

fieldSummary.sawSuperCall(getXMethod(), invoked);

}

}

if (seen == PUTFIELD || seen == PUTSTATIC) {

XField fieldOperand = getXFieldOperand();

if (fieldOperand == null)

return;

touched.add(fieldOperand);

if (!fieldOperand.getClassDescriptor().getClassName().equals(getClassName()))

fieldSummary.addWrittenOutsideOfConstructor(fieldOperand);

else if (seen == PUTFIELD) {

OpcodeStack.Item addr = stack.getStackItem(1);

{

if (addr.getRegisterNumber() != 0 || !getMethodName().equals(""))

fieldSummary.addWrittenOutsideOfConstructor(fieldOperand);

}

} else if (seen == PUTSTATIC && !getMethodName().equals(""))

fieldSummary.addWrittenOutsideOfConstructor(fieldOperand);

OpcodeStack.Item top = stack.getStackItem(0);

fieldSummary.mergeSummary(fieldOperand, top);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值