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


Java Location类代码示例

本文整理汇总了Java中edu.umd.cs.findbugs.ba.Location的典型用法代码示例。如果您正苦于以下问题:Java Location类的具体用法?Java Location怎么用?Java Location使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Location类属于edu.umd.cs.findbugs.ba包,在下文中一共展示了Location类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createStream

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
public Stream createStream(Location location, ObjectType type, ConstantPoolGen cpg,
                           RepositoryLookupFailureCallback lookupFailureCallback) {

	Instruction ins = location.getHandle().getInstruction();

	try {
		if (ins instanceof InvokeInstruction) {
			if (!Hierarchy.isSubtype(type, baseClassType))
				return null;

			Stream stream = new Stream(location, type.getClassName(), baseClassType.getClassName())
			        .setIsOpenOnCreation(true)
			        .setIgnoreImplicitExceptions(true);
			if (bugType != null)
				stream.setInteresting(bugType);

			return stream;
		}
	} catch (ClassNotFoundException e) {
		lookupFailureCallback.reportMissingClass(e);
	}

	return null;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:AnyMethodReturnValueStreamFactory.java

示例2: createStream

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
public Stream createStream(Location location, ObjectType type, ConstantPoolGen cpg,
                           RepositoryLookupFailureCallback lookupFailureCallback) {

	Instruction ins = location.getHandle().getInstruction();
	if (ins.getOpcode() != Constants.GETSTATIC)
		return null;

	GETSTATIC getstatic = (GETSTATIC) ins;
	if (!className.equals(getstatic.getClassName(cpg))
	        || !fieldName.equals(getstatic.getName(cpg))
	        || !fieldSig.equals(getstatic.getSignature(cpg)))
		return null;

	return new Stream(location, type.getClassName(), streamBaseClass)
	        .setIgnoreImplicitExceptions(true)
	        .setIsOpenOnCreation(true);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:StaticFieldLoadStreamFactory.java

示例3: hasCustomReadObject

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
/**
 * Check if the readObject is doing multiple external call beyond the basic readByte, readBoolean, etc..
 * @param m
 * @param classContext
 * @return
 * @throws CFGBuilderException
 * @throws DataflowAnalysisException
 */
private boolean hasCustomReadObject(Method m, ClassContext classContext,List<String> classesToIgnore)
        throws CFGBuilderException, DataflowAnalysisException {
    ConstantPoolGen cpg = classContext.getConstantPoolGen();
    CFG cfg = classContext.getCFG(m);
    int count = 0;
    for (Iterator<Location> i = cfg.locationIterator(); i.hasNext(); ) {
        Location location = i.next();
        Instruction inst = location.getHandle().getInstruction();
        //ByteCode.printOpCode(inst,cpg);
        if(inst instanceof InvokeInstruction) {
            InvokeInstruction invoke = (InvokeInstruction) inst;
            if (!READ_DESERIALIZATION_METHODS.contains(invoke.getMethodName(cpg))
                    && !classesToIgnore.contains(invoke.getClassName(cpg))) {
                count +=1;
            }
        }
    }
    return count > 3;
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:28,代码来源:DeserializationGadgetDetector.java

示例4: analyzeMethod

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
private void analyzeMethod(Method m, ClassContext classContext) throws CFGBuilderException, DataflowAnalysisException {
    MethodGen methodGen = classContext.getMethodGen(m);
    ConstantPoolGen cpg = classContext.getConstantPoolGen();
    CFG cfg = classContext.getCFG(m);

    if (methodGen == null || methodGen.getInstructionList() == null) {
        return; //No instruction .. nothing to do
    }
    for (Iterator<Location> i = cfg.locationIterator(); i.hasNext(); ) {
        Location location = i.next();
        Instruction inst = location.getHandle().getInstruction();
        if (inst instanceof InvokeInstruction) {
            InvokeInstruction invoke = (InvokeInstruction) inst;
            String methodName = invoke.getMethodName(cpg);
            if ("enableDefaultTyping".equals(methodName)) {
                JavaClass clz = classContext.getJavaClass();
                bugReporter.reportBug(new BugInstance(this, DESERIALIZATION_TYPE, HIGH_PRIORITY)
                        .addClass(clz)
                        .addMethod(clz, m)
                        .addCalledMethod(cpg, invoke)
                        .addSourceLine(classContext, m, location)
                );
            }
        }
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:27,代码来源:UnsafeJacksonDeserializationDetector.java

示例5: analyzeMethod

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
private void analyzeMethod(Method m, ClassContext classContext) throws CFGBuilderException, DataflowAnalysisException {

        ConstantPoolGen cpg = classContext.getConstantPoolGen();
        CFG cfg = classContext.getCFG(m);
        
        for (Iterator<Location> i = cfg.locationIterator(); i.hasNext(); ) {
            Location location = i.next();

            Instruction inst = location.getHandle().getInstruction();
            
            if (inst instanceof LDC) {
                LDC ldc = (LDC) inst;
                if (ldc != null) {
                    if("java.naming.security.authentication".equals(ldc.getValue(cpg)) &&
                       "none".equals(ByteCode.getConstantLDC(location.getHandle().getNext(), cpg, String.class))){
                        JavaClass clz = classContext.getJavaClass();
                        bugReporter.reportBug(new BugInstance(this, LDAP_ANONYMOUS, Priorities.LOW_PRIORITY) //
                        .addClass(clz)
                        .addMethod(clz, m)
                        .addSourceLine(classContext, m, location));
                        break;
                    }
                }
            }            
        }
    }
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:27,代码来源:AnonymousLdapDetector.java

示例6: safeCallToPrimateParseMethod

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
private boolean safeCallToPrimateParseMethod(XMethod calledMethod, Location location) {
    int position = location.getHandle().getPosition();

    if (calledMethod.getClassName().equals("java.lang.Integer")) {

        ConstantPool constantPool = classContext.getJavaClass().getConstantPool();
        Code code = method.getCode();

        int catchSize;

        catchSize = Util.getSizeOfSurroundingTryBlock(constantPool, code, "java/lang/NumberFormatException", position);
        if (catchSize < Integer.MAX_VALUE)
            return true;
        catchSize = Util.getSizeOfSurroundingTryBlock(constantPool, code, "java/lang/IllegalArgumentException", position);
        if (catchSize < Integer.MAX_VALUE)
            return true;

        catchSize = Util.getSizeOfSurroundingTryBlock(constantPool, code, "java/lang/RuntimeException", position);
        if (catchSize < Integer.MAX_VALUE)
            return true;
        catchSize = Util.getSizeOfSurroundingTryBlock(constantPool, code, "java/lang/Exception", position);
        if (catchSize < Integer.MAX_VALUE)
            return true;
    }
    return false;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:27,代码来源:FindNullDeref.java

示例7: createStream

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
public Stream createStream(Location location, ObjectType type, ConstantPoolGen cpg,
        RepositoryLookupFailureCallback lookupFailureCallback) {

    Instruction ins = location.getHandle().getInstruction();

    try {
        if (ins instanceof InvokeInstruction) {
            if (!Hierarchy.isSubtype(type, baseClassType))
                return null;

            Stream stream = new Stream(location, type.getClassName(), baseClassType.getClassName()).setIsOpenOnCreation(true)
                    .setIgnoreImplicitExceptions(true);
            if (bugType != null)
                stream.setInteresting(bugType);

            return stream;
        }
    } catch (ClassNotFoundException e) {
        lookupFailureCallback.reportMissingClass(e);
    }

    return null;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:24,代码来源:AnyMethodReturnValueStreamFactory.java

示例8: reportNullDeref

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
private void reportNullDeref(WarningPropertySet<WarningProperty> propertySet, Location location, String type, int priority,
        @CheckForNull
        BugAnnotation variable) {

    BugInstance bugInstance = new BugInstance(this, type, priority).addClassAndMethod(classContext.getJavaClass(), method);
    if (variable != null)
        bugInstance.add(variable);
    else
        bugInstance.add(new LocalVariableAnnotation("?", -1, -1));
    bugInstance.addSourceLine(classContext, method, location).describe("SOURCE_LINE_DEREF");

    if (FindBugsAnalysisFeatures.isRelaxedMode()) {
        WarningPropertyUtil.addPropertiesForDataMining(propertySet, classContext, method, location);
    }
    addPropertiesForDereferenceLocations(propertySet, Collections.singleton(location), false);

    propertySet.decorateBugInstance(bugInstance);

    bugReporter.reportBug(bugInstance);
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:21,代码来源:FindNullDeref.java

示例9: nullCheck

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
private Type nullCheck(short opcode, Edge edge, InstructionHandle last, BasicBlock sourceBlock)
        throws DataflowAnalysisException {
    if (DEBUG_NULL_CHECK) {
        System.out.println("checking for nullcheck on edge " + edge);
    }
    Type type = null;
    if ((opcode == Constants.IFNULL && edge.getType() == EdgeTypes.IFCMP_EDGE)
            || (opcode == Constants.IFNONNULL && edge.getType() == EdgeTypes.FALL_THROUGH_EDGE)) {
        Location location = new Location(last, sourceBlock);
        TypeFrame typeFrame = typeDataflow.getFactAtLocation(location);
        if (typeFrame.isValid()) {
            type = typeFrame.getTopValue();
            if (DEBUG_NULL_CHECK) {
                System.out.println("ifnull comparison of " + type + " to null at " + last);
            }
        }
    }
    return type;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:20,代码来源:ObligationAnalysis.java

示例10: isSafeValue

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
private boolean isSafeValue(Location location, ConstantPoolGen cpg) throws CFGBuilderException {
    Instruction prevIns = location.getHandle().getInstruction();
    if (prevIns instanceof LDC || prevIns instanceof GETSTATIC)
        return true;
    if (prevIns instanceof InvokeInstruction) {
        String methodName = ((InvokeInstruction) prevIns).getMethodName(cpg);
        if (methodName.startsWith("to") && methodName.endsWith("String") && methodName.length() > 8)
            return true;
    }
    if (prevIns instanceof AALOAD) {
        CFG cfg = classContext.getCFG(method);

        Location prev = getPreviousLocation(cfg, location, true);
        if (prev != null) {
            Location prev2 = getPreviousLocation(cfg, prev, true);
            if (prev2 != null && prev2.getHandle().getInstruction() instanceof GETSTATIC) {
                GETSTATIC getStatic = (GETSTATIC) prev2.getHandle().getInstruction();
                if (getStatic.getSignature(cpg).equals("[Ljava/lang/String;"))
                    return true;
            }
        }
    }
    return false;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:25,代码来源:FindSqlInjection.java

示例11: uniqueLocations

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
/**
 * @param derefLocationSet
 * @return
 */
private boolean uniqueLocations(Collection<Location> derefLocationSet) {
    boolean uniqueDereferenceLocations = false;
    LineNumberTable table = method.getLineNumberTable();
    if (table == null)
        uniqueDereferenceLocations = true;
    else {
        BitSet linesMentionedMultipleTimes = classContext.linesMentionedMultipleTimes(method);
        for (Location loc : derefLocationSet) {
            int lineNumber = table.getSourceLine(loc.getHandle().getPosition());
            if (!linesMentionedMultipleTimes.get(lineNumber))
                uniqueDereferenceLocations = true;
        }
    }
    return uniqueDereferenceLocations;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:20,代码来源:NoiseNullDeref.java

示例12: countLocalStoresLoadsAndIncrements

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
/**
 * Count stores, loads, and increments of local variables in method whose
 * CFG is given.
 *
 * @param localStoreCount
 *            counts of local stores (indexed by local)
 * @param localLoadCount
 *            counts of local loads (indexed by local)
 * @param localIncrementCount
 *            counts of local increments (indexed by local)
 * @param cfg
 *            control flow graph (CFG) of method
 */
private void countLocalStoresLoadsAndIncrements(int[] localStoreCount, int[] localLoadCount, int[] localIncrementCount,
        CFG cfg) {
    for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
        Location location = i.next();

        if (location.getBasicBlock().isExceptionHandler())
            continue;

        boolean isStore = isStore(location);
        boolean isLoad = isLoad(location);
        if (!isStore && !isLoad)
            continue;

        IndexedInstruction ins = (IndexedInstruction) location.getHandle().getInstruction();
        int local = ins.getIndex();
        if (ins instanceof IINC) {
            localStoreCount[local]++;
            localLoadCount[local]++;
            localIncrementCount[local]++;
        } else if (isStore)
            localStoreCount[local]++;
        else
            localLoadCount[local]++;
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:39,代码来源:FindDeadLocalStores.java

示例13: unionWith

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
public void unionWith(UnconditionalValueDerefSet fact, ValueNumberFactory valueNumberFactory) {
    if (UnconditionalValueDerefAnalysis.DEBUG) {
        System.out.println("union update of # " + System.identityHashCode(this) + " from " + System.identityHashCode(fact));
    }
    // Compute the union of the unconditionally dereferenced value sets
    valueNumbersUnconditionallyDereferenced.or(fact.valueNumbersUnconditionallyDereferenced);

    // For each unconditionally dereferenced value...
    for (int i = 0; i < numValueNumbersInMethod; i++) {
        ValueNumber vn = valueNumberFactory.forNumber(i);

        if (fact.valueNumbersUnconditionallyDereferenced.get(i)) {
            // Compute the union of the dereference locations for
            // this value number.
            Set<Location> derefLocationSet = derefLocationSetMap.get(vn);
            if (derefLocationSet == null) {
                derefLocationSet = new HashSet<Location>();
                derefLocationSetMap.put(vn, derefLocationSet);
            }
            derefLocationSet.addAll(fact.derefLocationSetMap.get(vn));
        } else {
            derefLocationSetMap.put(vn, new HashSet<Location>(fact.getDerefLocationSet(vn)));
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:26,代码来源:UnconditionalValueDerefSet.java

示例14: reportNullDeref

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
private void reportNullDeref(WarningPropertySet<WarningProperty> propertySet, Location location, String type, int priority,
        BugAnnotation cause, @CheckForNull BugAnnotation variable) {

    BugInstance bugInstance = new BugInstance(this, type, priority).addClassAndMethod(classContext.getJavaClass(), method);
    bugInstance.add(cause);
    if (variable != null)
        bugInstance.add(variable);
    else
        bugInstance.add(new LocalVariableAnnotation("?", -1, -1));
    bugInstance.addSourceLine(classContext, method, location).describe("SOURCE_LINE_DEREF");

    if (FindBugsAnalysisFeatures.isRelaxedMode()) {
        WarningPropertyUtil.addPropertiesForDataMining(propertySet, classContext, method, location);
    }
    addPropertiesForDereferenceLocations(propertySet, Collections.singleton(location));

    propertySet.decorateBugInstance(bugInstance);

    bugReporter.reportBug(bugInstance);
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:21,代码来源:NoiseNullDeref.java

示例15: checkNonNullPutField

import edu.umd.cs.findbugs.ba.Location; //导入依赖的package包/类
/**
 * If this is a putfield or putstatic instruction, check to see if the field
 * is @NonNull, and treat it as dereferences.
 *
 * @param location
 *            the Location of the instruction
 * @param vnaFrame
 *            the ValueNumberFrame at the Location of the instruction
 * @param fact
 *            the dataflow value to modify
 * @throws DataflowAnalysisException
 */
private void checkNonNullPutField(Location location, ValueNumberFrame vnaFrame, UnconditionalValueDerefSet fact)
        throws DataflowAnalysisException {
    INullnessAnnotationDatabase database = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase();
    if (database == null) {
        return;
    }

    FieldInstruction fieldIns = (FieldInstruction) location.getHandle().getInstruction();

    XField field = XFactory.createXField(fieldIns, methodGen.getConstantPool());
    char firstChar = field.getSignature().charAt(0);
    if (firstChar != 'L' && firstChar != '[')
        return;
    NullnessAnnotation resolvedAnnotation = database.getResolvedAnnotation(field, true);
    if (resolvedAnnotation == NullnessAnnotation.NONNULL) {
        IsNullValueFrame invFrame = invDataflow.getFactAtLocation(location);
        if (!invFrame.isValid())
            return;
        IsNullValue value = invFrame.getTopValue();
        if (reportDereference(value)) {
            ValueNumber vn = vnaFrame.getTopValue();
            fact.addDeref(vn, location);
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:38,代码来源:UnconditionalValueDerefAnalysis.java


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