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


Java SourceLineAnnotation类代码示例

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


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

示例1: visit

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
@Override
public void visit(Code obj) {
    found.clear();
    // Solution to sourceforge bug 1765925; returning null is the
    // convention used by java.io.File.listFiles()
    if (getMethodName().equals("listFiles")) {
        return;
    }
    String returnType = getMethodSig().substring(getMethodSig().indexOf(")") + 1);
    if (returnType.startsWith("[")) {
        nullOnTOS = false;
        super.visit(obj);
        if (!found.isEmpty()) {
            BugInstance bug = new BugInstance(this, "PZLA_PREFER_ZERO_LENGTH_ARRAYS", LOW_PRIORITY).addClassAndMethod(this);
            for (SourceLineAnnotation s : found)
                bug.add(s);
            bugReporter.reportBug(bug);
            found.clear();
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:22,代码来源:PreferZeroLengthArrays.java

示例2: sawOpcode

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
@Override
public void sawOpcode(int seen) {

    switch (seen) {
    case ACONST_NULL:
        nullOnTOS = true;
        return;
    case ARETURN:
        if (nullOnTOS) {
            SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstruction(getClassContext(), this,
                    getPC());
            if (sourceLineAnnotation != null)
                found.add(sourceLineAnnotation);
        }

        break;
    }
    nullOnTOS = false;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:20,代码来源:PreferZeroLengthArrays.java

示例3: suppressWarningsIfOneLiveStoreOnLine

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
/**
 * If feature is enabled, suppress warnings where there is at least one live
 * store on the line where the warning would be reported.
 * 
 * @param accumulator
 *            BugAccumulator containing warnings for method
 * @param liveStoreSourceLineSet
 *            bitset of lines where at least one live store was seen
 */
private void suppressWarningsIfOneLiveStoreOnLine(BugAccumulator accumulator, BitSet liveStoreSourceLineSet) {
    if (!SUPPRESS_IF_AT_LEAST_ONE_LIVE_STORE_ON_LINE) {
        return;
    }

    // Eliminate any accumulated warnings for instructions
    // that (due to inlining) *can* be live stores.
    entryLoop: for (Iterator<? extends BugInstance> i = accumulator.uniqueBugs().iterator(); i.hasNext();) {

        for (SourceLineAnnotation annotation : accumulator.locations(i.next())) {
            if (liveStoreSourceLineSet.get(annotation.getStartLine())) {
                // This instruction can be a live store; don't report
                // it as a warning.
                i.remove();
                continue entryLoop;
            }
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:29,代码来源:FindDeadLocalStores.java

示例4: visit

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
@Override
public void visit(Code obj) {
    found.clear();
    priority = LOW_PRIORITY;

    state = SAW_NOTHING;

    super.visit(obj);
    bugAccumulator.reportAccumulatedBugs();
    if (!found.isEmpty()) {
        BugInstance bug = new BugInstance(this, "FE_FLOATING_POINT_EQUALITY", priority).addClassAndMethod(this);

        boolean first = true;
        for (SourceLineAnnotation s : found) {
            bug.add(s);
            if (first)
                first = false;
            else
                bug.describe(SourceLineAnnotation.ROLE_ANOTHER_INSTANCE);
        }

        bugReporter.reportBug(bug);

        found.clear();
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:27,代码来源:FindFloatEquality.java

示例5: visit

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
@Override
public void visit(Code obj) {
    if (DEBUG)
        System.out.printf("%nVisiting %s%n", getMethodDescriptor());
    reachable = false;
    lastPC = 0;
    biggestJumpTarget = -1;
    found.clear();
    switchHdlr = new SwitchHandler();
    clearAllDeadStores();
    deadStore = null;
    priority = NORMAL_PRIORITY;
    fallthroughDistance = 1000;
    enumType = null;
    super.visit(obj);
    enumType = null;
    if (!found.isEmpty()) {
        if (found.size() >= 4 && priority == NORMAL_PRIORITY)
            priority = LOW_PRIORITY;
        for (SourceLineAnnotation s : found)
            bugAccumulator.accumulateBug(new BugInstance(this, "SF_SWITCH_FALLTHROUGH", priority).addClassAndMethod(this), s);
    }

    bugAccumulator.reportAccumulatedBugs();
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:26,代码来源:SwitchFallthrough.java

示例6: foundSwitchNoDefault

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
private void foundSwitchNoDefault(SourceLineAnnotation s) {
    LineNumberTable table = getCode().getLineNumberTable();

    if (table != null) {
        int startLine = s.getStartLine();
        int prev = Integer.MIN_VALUE;
        for (LineNumber ln : table.getLineNumberTable()) {
            int thisLineNumber = ln.getLineNumber();
            if (thisLineNumber < startLine && thisLineNumber > prev && ln.getStartPC() < s.getStartBytecode())
                prev = thisLineNumber;
        }
        int diff = startLine - prev;
        if (diff > 5)
            return;

        bugAccumulator.accumulateBug(new BugInstance(this, "SF_SWITCH_NO_DEFAULT", NORMAL_PRIORITY).addClassAndMethod(this),
                s);
    }

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

示例7: findSource0

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
public boolean findSource0(SourceLineAnnotation srcLine) {
    if (srcLine == null)
        return false;
    String cName = srcLine.getClassName();
    if (sourceFound.contains(cName))
        return true;
    if (sourceNotFound.contains(cName))
        return false;

    try {
        InputStream in = sourceFinder.openSource(srcLine);
        in.close();
        sourceFound.add(cName);
        return true;
    } catch (IOException e1) {
        sourceNotFound.add(cName);
        return false;
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:20,代码来源:SourceSearcher.java

示例8: lookupSourceFile

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
/**
 * Lookup a class's source file
 *
 * @param dottedClassName
 *            the name of the class
 * @return the source file for the class, or
 *         {@link SourceLineAnnotation#UNKNOWN_SOURCE_FILE} if unable to
 *         determine
 */
public final String lookupSourceFile(@Nonnull @DottedClassName String dottedClassName) {
    if (dottedClassName == null)
        throw new IllegalArgumentException("className is null");
    try {
        XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class,
                DescriptorFactory.createClassDescriptorFromDottedClassName(dottedClassName));
        String name = xClass.getSource();
        if (name == null) {
            return SourceLineAnnotation.UNKNOWN_SOURCE_FILE;
        }
        return name;
    } catch (CheckedAnalysisException e) {
        return SourceLineAnnotation.UNKNOWN_SOURCE_FILE;
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:25,代码来源:AnalysisContext.java

示例9: suppressWarningsIfOneLiveStoreOnLine

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
/**
 * If feature is enabled, suppress warnings where there is at least one live
 * store on the line where the warning would be reported.
 *
 * @param accumulator
 *            BugAccumulator containing warnings for method
 * @param liveStoreSourceLineSet
 *            bitset of lines where at least one live store was seen
 */
private void suppressWarningsIfOneLiveStoreOnLine(BugAccumulator accumulator, BitSet liveStoreSourceLineSet) {
    if (!SUPPRESS_IF_AT_LEAST_ONE_LIVE_STORE_ON_LINE) {
        return;
    }

    // Eliminate any accumulated warnings for instructions
    // that (due to inlining) *can* be live stores.
    entryLoop: for (Iterator<? extends BugInstance> i = accumulator.uniqueBugs().iterator(); i.hasNext();) {

        for (SourceLineAnnotation annotation : accumulator.locations(i.next())) {
            if (liveStoreSourceLineSet.get(annotation.getStartLine())) {
                // This instruction can be a live store; don't report
                // it as a warning.
                i.remove();
                continue entryLoop;
            }
        }
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:29,代码来源:FindDeadLocalStores.java

示例10: WarningWithProperties

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
WarningWithProperties(BugInstance warning, WarningPropertySet<WarningProperty> propertySet,
        SourceLineAnnotation sourceLine, Location location) {
    this.instance = warning;
    this.propertySet = propertySet;
    this.sourceLine = sourceLine;
    this.location = location;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:8,代码来源:FindRefComparison.java

示例11: addLines

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
/**
 * Adds lines with tainted source or path for reporting
 * 
 * @param locations collection of locations used to extract lines
 */
public void addLines(Collection<TaintLocation> locations) {
    Objects.requireNonNull(detector, "locations");
    for (TaintLocation location : locations) {
        lines.add(SourceLineAnnotation.fromVisitedInstruction(
            location.getMethodDescriptor(), location.getPosition()));
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:13,代码来源:InjectionSink.java

示例12: accumulateBug

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
/**
 *
 */
private void accumulateBug() {
    if (pendingBug == null)
        return;
    bugAccumulator.accumulateBug(pendingBug, SourceLineAnnotation.fromVisitedInstruction(this, monitorEnterPC));
    pendingBug = null;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:10,代码来源:SynchronizationOnSharedBuiltinConstant.java

示例13: inspectResult

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
@Override
public void inspectResult(ClassContext classContext, MethodGen methodGen, CFG cfg,
        Dataflow<ResourceValueFrame, ResourceValueAnalysis<Lock>> dataflow, Lock resource) {

    JavaClass javaClass = classContext.getJavaClass();

    ResourceValueFrame exitFrame = dataflow.getResultFact(cfg.getExit());
    if (DEBUG) {
        System.out.println("Resource value at exit: " + exitFrame);
    }
    int exitStatus = exitFrame.getStatus();

    if (exitStatus == ResourceValueFrame.OPEN || exitStatus == ResourceValueFrame.OPEN_ON_EXCEPTION_PATH) {
        String bugType;
        int priority;
        if (exitStatus == ResourceValueFrame.OPEN) {
            bugType = "UL_UNRELEASED_LOCK";
            priority = HIGH_PRIORITY;
        } else {
            bugType = "UL_UNRELEASED_LOCK_EXCEPTION_PATH";
            priority = NORMAL_PRIORITY;
        }

        String sourceFile = javaClass.getSourceFileName();
        Location location = resource.getLocation();
        InstructionHandle handle = location.getHandle();
        InstructionHandle nextInstruction = handle.getNext();
        if (nextInstruction.getInstruction() instanceof RETURN)
            return; // don't report as error; intentional
        bugAccumulator.accumulateBug(new BugInstance(this, bugType, priority).addClassAndMethod(methodGen, sourceFile),
                SourceLineAnnotation.fromVisitedInstruction(classContext, methodGen, sourceFile, handle));
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:34,代码来源:FindUnreleasedLock.java

示例14: visit

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
@Override
public void visit(LocalVariable obj) {
    if (isReservedName(obj.getName())) {
        LocalVariableAnnotation var = new LocalVariableAnnotation(obj.getName(), obj.getIndex(), obj.getStartPC());
        SourceLineAnnotation source = SourceLineAnnotation.fromVisitedInstruction(getClassContext(), this, obj.getStartPC());
        BugInstance bug = new BugInstance(this, "NM_FUTURE_KEYWORD_USED_AS_IDENTIFIER", NORMAL_PRIORITY)
                .addClassAndMethod(this).add(var).add(source);
        bugReporter.reportBug(bug);
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:11,代码来源:DontUseEnum.java

示例15: sawOpcode

import edu.umd.cs.findbugs.SourceLineAnnotation; //导入依赖的package包/类
@Override
public void sawOpcode(int seen) {

    if (DEBUG)
        System.out.println("Saw opcode " + OPCODE_NAMES[seen] + " " + pendingIdivCastToDivBugLocation);

    if ((prevOpCode == I2D || prevOpCode == L2D) && seen == INVOKESTATIC && ClassName.isMathClass(getClassConstantOperand())
            && getNameConstantOperand().equals("ceil")) {
        bugAccumulator
                .accumulateBug(new BugInstance(this, "ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL", HIGH_PRIORITY)
                        .addClassAndMethod(this), this);
        pendingIdivCastToDivBugLocation = null;
    } else if ((prevOpCode == I2F || prevOpCode == L2F) && seen == INVOKESTATIC
            && ClassName.isMathClass(getClassConstantOperand()) && getNameConstantOperand().equals("round")) {
        bugAccumulator.accumulateBug(
                new BugInstance(this, "ICAST_INT_CAST_TO_FLOAT_PASSED_TO_ROUND", NORMAL_PRIORITY).addClassAndMethod(this),
                this);
        pendingIdivCastToDivBugLocation = null;
    } else if (pendingIdivCastToDivBugLocation != null) {
        bugAccumulator.accumulateBug(
                new BugInstance(this, "ICAST_IDIV_CAST_TO_DOUBLE", NORMAL_PRIORITY).addClassAndMethod(this),
                pendingIdivCastToDivBugLocation);
        pendingIdivCastToDivBugLocation = null;
    }

    if (prevOpCode == IDIV && (seen == I2D || seen == I2F) || prevOpCode == LDIV && (seen == L2D || seen == L2F))
        pendingIdivCastToDivBugLocation = SourceLineAnnotation.fromVisitedInstruction(this);
    prevOpCode = seen;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:30,代码来源:IDivResultCastToDouble.java


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