本文整理汇总了Java中edu.umd.cs.findbugs.ba.ClassContext.getBytecodeSet方法的典型用法代码示例。如果您正苦于以下问题:Java ClassContext.getBytecodeSet方法的具体用法?Java ClassContext.getBytecodeSet怎么用?Java ClassContext.getBytecodeSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.findbugs.ba.ClassContext
的用法示例。
在下文中一共展示了ClassContext.getBytecodeSet方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitClassContext
import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
public void visitClassContext(ClassContext classContext) {
JavaClass jclass = classContext.getJavaClass();
if (jclass.getClassName().startsWith("java.util.concurrent."))
return;
Method[] methodList = jclass.getMethods();
for (Method method : methodList) {
if (method.getCode() == null)
continue;
// We can ignore methods that don't contain a monitorenter
BitSet bytecodeSet = classContext.getBytecodeSet(method);
if (bytecodeSet == null)
continue;
if (false && !bytecodeSet.get(Constants.MONITORENTER))
continue;
analyzeMethod(classContext, method);
}
}
示例2: prescreen
import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
public boolean prescreen(Method method, ClassContext classContext) {
BitSet bytecodeSet = classContext.getBytecodeSet(method);
// Method must contain a MONITORENTER
if (!bytecodeSet.get(Constants.MONITORENTER))
return false;
// Method must contain either GETFIELD/PUTFIELD or GETSTATIC/PUTSTATIC
if (!(bytecodeSet.get(Constants.GETFIELD) && bytecodeSet.get(Constants.PUTFIELD)) &&
!(bytecodeSet.get(Constants.GETSTATIC) && bytecodeSet.get(Constants.PUTSTATIC)))
return false;
return true;
}
示例3: prescreen
import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
@Override
public boolean prescreen(Method method, ClassContext classContext) {
if (method.getName().equals("<clinit>"))
return false;
Code code = method.getCode();
if (code.getCode().length > 5000)
return false;
BitSet bytecodeSet = classContext.getBytecodeSet(method);
if (bytecodeSet == null)
return false;
// The pattern requires a get/put pair accessing the same field.
boolean hasGetStatic = bytecodeSet.get(Constants.GETSTATIC);
boolean hasPutStatic = bytecodeSet.get(Constants.PUTSTATIC);
if (!hasGetStatic || !hasPutStatic)
return false;
// If the method is synchronized, then we'll assume that
// things are properly synchronized
if (method.isSynchronized())
return false;
reported.clear();
return true;
}
示例4: prescreen
import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
/**
* Use this to screen out methods that do not contain invocations.
*/
public boolean prescreen(ClassContext classContext, Method method) {
BitSet bytecodeSet = classContext.getBytecodeSet(method);
return bytecodeSet != null
&& (bytecodeSet.get(Constants.INVOKEINTERFACE) || bytecodeSet.get(Constants.INVOKEVIRTUAL)
|| bytecodeSet.get(Constants.INVOKESPECIAL) || bytecodeSet.get(Constants.INVOKESTATIC) || bytecodeSet
.get(Constants.INVOKENONVIRTUAL));
}
示例5: prescreen
import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
@Override
public boolean prescreen(ClassContext classContext, Method method, boolean mightClose) {
if (!mightClose)
return false;
BitSet bytecodeSet = classContext.getBytecodeSet(method);
if (bytecodeSet == null)
return false;
MethodGen methodGen = classContext.getMethodGen(method);
return methodGen != null && methodGen.getName().toLowerCase().indexOf("lock") == -1
&& (bytecodeSet.get(Constants.INVOKEVIRTUAL) || bytecodeSet.get(Constants.INVOKEINTERFACE));
}
示例6: prescreen
import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
private boolean prescreen(ClassContext classContext, Method method) {
BitSet bytecodeSet = classContext.getBytecodeSet(method);
if (bytecodeSet == null)
return false;
// method must acquire a lock
if (!bytecodeSet.get(Constants.MONITORENTER) && !method.isSynchronized())
return false;
// and contain a static method invocation
if (!bytecodeSet.get(Constants.INVOKESTATIC))
return false;
return true;
}
示例7: prescreen
import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
@Override
public boolean prescreen(ClassContext classContext, Method method, boolean mightClose) {
BitSet bytecodeSet = classContext.getBytecodeSet(method);
if (bytecodeSet == null)
return false;
return bytecodeSet.get(Constants.NEW) || bytecodeSet.get(Constants.INVOKEINTERFACE)
|| bytecodeSet.get(Constants.INVOKESPECIAL) || bytecodeSet.get(Constants.INVOKESTATIC)
|| bytecodeSet.get(Constants.INVOKEVIRTUAL);
}
示例8: prescreen
import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
public boolean prescreen(Method method, ClassContext classContext) {
// Pre-screen for methods with POP or POP2 bytecodes.
// This gives us a speedup close to 5X.
BitSet bytecodeSet = classContext.getBytecodeSet(method);
return bytecodeSet.get(Constants.POP) || bytecodeSet.get(Constants.POP2);
}
示例9: analyzeMethod
import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, DataflowAnalysisException {
MethodGen methodGen = classContext.getMethodGen(method);
if (methodGen == null)
return;
BitSet bytecodeSet = classContext.getBytecodeSet(method);
if (bytecodeSet == null)
return;
// We don't adequately model instanceof interfaces yet
if (bytecodeSet.get(Constants.INSTANCEOF) || bytecodeSet.get(Constants.CHECKCAST))
return;
CFG cfg = classContext.getCFG(method);
TypeDataflow typeDataflow = classContext.getTypeDataflow(method);
ConstantPoolGen cpg = classContext.getConstantPoolGen();
String sourceFile = classContext.getJavaClass().getSourceFileName();
if (DEBUG) {
String methodName = methodGen.getClassName() + "." + methodGen.getName();
System.out.println("Checking " + methodName);
}
for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
Location location = i.next();
InstructionHandle handle = location.getHandle();
Instruction ins = handle.getInstruction();
if (!(ins instanceof INVOKEINTERFACE))
continue;
INVOKEINTERFACE invoke = (INVOKEINTERFACE) ins;
String mName = invoke.getMethodName(cpg);
if (!mName.equals("setAttribute"))
continue;
String cName = invoke.getClassName(cpg);
if (!cName.equals("javax.servlet.http.HttpSession"))
continue;
TypeFrame frame = typeDataflow.getFactAtLocation(location);
if (!frame.isValid()) {
// This basic block is probably dead
continue;
}
Type operandType = frame.getTopValue();
if (operandType.equals(TopType.instance())) {
// unreachable
continue;
}
if (!(operandType instanceof ReferenceType)) {
// Shouldn't happen - illegal bytecode
continue;
}
ReferenceType refType = (ReferenceType) operandType;
if (refType.equals(NullType.instance())) {
continue;
}
try {
double isSerializable = DeepSubtypeAnalysis.isDeepSerializable(refType);
if (isSerializable < 0.9) {
SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstruction(classContext,
methodGen, sourceFile, handle);
ReferenceType problem = DeepSubtypeAnalysis.getLeastSerializableTypeComponent(refType);
bugAccumulator.accumulateBug(new BugInstance(this, "J2EE_STORE_OF_NON_SERIALIZABLE_OBJECT_INTO_SESSION",
isSerializable < 0.15 ? HIGH_PRIORITY : isSerializable > 0.5 ? LOW_PRIORITY : NORMAL_PRIORITY)
.addClassAndMethod(methodGen, sourceFile).addType(problem).describe(TypeAnnotation.FOUND_ROLE),
sourceLineAnnotation);
}
} catch (ClassNotFoundException e) {
// ignore
}
}
}
示例10: prescreen
import edu.umd.cs.findbugs.ba.ClassContext; //导入方法依赖的package包/类
public boolean prescreen(ClassContext classContext, Method method) {
BitSet bytecodeSet = classContext.getBytecodeSet(method);
return bytecodeSet != null && (bytecodeSet.get(Constants.CHECKCAST) || bytecodeSet.get(Constants.INSTANCEOF));
}