@Override public void visit(Code obj) { lastRegStore = -1; lineNumbers = obj.getLineNumberTable(); super.visit(obj); }
private static LineNumberTable getLineNumberTable(PreorderVisitor visitor) { Code code = visitor.getMethod().getCode(); if (code == null) { return null; } return code.getLineNumberTable(); }
private static int getLineNumber(Method method, InstructionHandle handle) { LineNumberTable table = method.getCode().getLineNumberTable(); if (table == null) { return -1; } return table.getSourceLine(handle.getPosition()); } }
static SourceLineAnnotation getSourceAnnotationForClass(String className, String sourceFileName) { int lastLine = -1; int firstLine = Integer.MAX_VALUE; try { JavaClass targetClass = AnalysisContext.currentAnalysisContext().lookupClass(className); for (Method m : targetClass.getMethods()) { Code c = m.getCode(); if (c != null) { LineNumberTable table = c.getLineNumberTable(); if (table != null) { for (LineNumber line : table.getLineNumberTable()) { lastLine = Math.max(lastLine, line.getLineNumber()); firstLine = Math.min(firstLine, line.getLineNumber()); } } } } } catch (ClassNotFoundException e) { AnalysisContext.reportMissingClass(e); } if (firstLine < Integer.MAX_VALUE) { return new SourceLineAnnotation(className, sourceFileName, firstLine, lastLine, -1, -1); } return SourceLineAnnotation.createUnknown(className, sourceFileName); }
/** * Create from Method and bytecode offset in a visited class. * * @param jclass * JavaClass of visited class * @param method * Method in visited class * @param pc * bytecode offset in visited method * @return SourceLineAnnotation describing visited instruction */ public static SourceLineAnnotation fromVisitedInstruction(JavaClass jclass, Method method, int pc) { LineNumberTable lineNumberTable = method.getCode().getLineNumberTable(); String className = jclass.getClassName(); String sourceFile = jclass.getSourceFileName(); if (lineNumberTable == null) { return createUnknown(className, sourceFile, pc, pc); } int startLine = lineNumberTable.getSourceLine(pc); return new SourceLineAnnotation(className, sourceFile, startLine, startLine, pc, pc); }
@Override public void sawOpcode(int seen) { if (ifInstructionSet.get(seen)) { if (getBranchTarget() == getBranchFallThrough()) { int priority = NORMAL_PRIORITY; LineNumberTable lineNumbers = getCode().getLineNumberTable(); if (lineNumbers != null) { int branchLineNumber = lineNumbers.getSourceLine(getPC()); int targetLineNumber = lineNumbers.getSourceLine(getBranchFallThrough()); int nextLine = getNextSourceLine(lineNumbers, branchLineNumber); if (branchLineNumber + 1 == targetLineNumber || branchLineNumber == targetLineNumber && nextLine == branchLineNumber + 1) { priority = HIGH_PRIORITY; } else if (branchLineNumber + 2 < Math.max(targetLineNumber, nextLine)) { priority = LOW_PRIORITY; } } else { priority = LOW_PRIORITY; } bugAccumulator.accumulateBug(new BugInstance(this, priority == HIGH_PRIORITY ? "UCF_USELESS_CONTROL_FLOW_NEXT_LINE" : "UCF_USELESS_CONTROL_FLOW", priority) .addClassAndMethod(this), this); } } }
LineNumberTable lineNumberTable = code.getLineNumberTable(); if (lineNumberTable == null) { return size;
LineNumberTable lineNumbers = obj.getLineNumberTable(); if (exp == null) { return;
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); } }
SourceLineAnnotation source = SourceLineAnnotation.fromVisitedInstruction(this); boolean possibleClone = source.getStartLine() > 0 && linesMentionedMultipleTimes.get(source.getStartLine()); LineNumberTable lineNumberTable = getCode().getLineNumberTable(); int linesDifference = 0; if (item0.getPC() != -1 && item1.getPC() != -1) {
DataInputStream byteStream = new DataInputStream(new ByteArrayInputStream(codeBytes)); lineNumberTable = obj.getLineNumberTable();
LineNumberTable table = getCode().getLineNumberTable(); if (table != null) { int first = table.getSourceLine(putFieldPC);
@Override public void visit(Code obj) { lastRegStore = -1; lineNumbers = obj.getLineNumberTable(); super.visit(obj); }
/** @return LineNumberTable of code attribute if any, i.e. the call is forwarded * to the Code atribute. */ public final LineNumberTable getLineNumberTable() { final Code code = getCode(); if (code == null) { return null; } return code.getLineNumberTable(); }
/** @return LineNumberTable of code attribute if any, i.e. the call is forwarded * to the Code atribute. */ public final LineNumberTable getLineNumberTable() { Code code = getCode(); if(code != null) return code.getLineNumberTable(); else return null; }
public LineNumberCursor(Code code) { if (code == null) return; LineNumberTable table= code.getLineNumberTable(); if (table == null) return; lineNumbers= table.getLineNumberTable(); length= lineNumbers.length; Arrays.sort(lineNumbers, new LineNumberComparator()); }
private static LineNumberTable getLineNumberTable(PreorderVisitor visitor) { Code code = visitor.getMethod().getCode(); if (code == null) { return null; } return code.getLineNumberTable(); }
/** * add the current line number to a set of line numbers * * @param lineNumbers * the current set of line numbers */ private void addLineNumber(BitSet lineNumbers) { LineNumberTable lnt = getCode().getLineNumberTable(); if (lnt == null) { lineNumbers.set(0); } else { int line = lnt.getSourceLine(getPC()); if (line < 0) { lineNumbers.set(lineNumbers.size()); } else { lineNumbers.set(line); } } }
private static int getLineNumber(Method method, InstructionHandle handle) { LineNumberTable table = method.getCode().getLineNumberTable(); if (table == null) { return -1; } return table.getSourceLine(handle.getPosition()); } }
/** * Create from Method and bytecode offset in a visited class. * * @param jclass * JavaClass of visited class * @param method * Method in visited class * @param pc * bytecode offset in visited method * @return SourceLineAnnotation describing visited instruction */ public static SourceLineAnnotation fromVisitedInstruction(JavaClass jclass, Method method, int pc) { LineNumberTable lineNumberTable = method.getCode().getLineNumberTable(); String className = jclass.getClassName(); String sourceFile = jclass.getSourceFileName(); if (lineNumberTable == null) { return createUnknown(className, sourceFile, pc, pc); } int startLine = lineNumberTable.getSourceLine(pc); return new SourceLineAnnotation(className, sourceFile, startLine, startLine, pc, pc); }