当前位置: 首页>>代码示例>>Java>>正文


Java ClassContext.getBytecodeSet方法代码示例

本文整理汇总了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);

    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:22,代码来源:FindJSR166LockMonitorenter.java

示例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;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:15,代码来源:BCPDoubleCheck.java

示例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;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:28,代码来源:LazyInit.java

示例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));
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:11,代码来源:FindUnrelatedTypesInGenericContainer.java

示例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));
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:14,代码来源:FindUnreleasedLock.java

示例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;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:15,代码来源:FindSleepWithLockHeld.java

示例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);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:10,代码来源:FindOpenStream.java

示例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);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:7,代码来源:BCPMethodReturnCheck.java

示例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
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:78,代码来源:FindNonSerializableStoreIntoSession.java

示例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));
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:5,代码来源:FindBadCast2.java


注:本文中的edu.umd.cs.findbugs.ba.ClassContext.getBytecodeSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。