public static int getNextSourceLine(LineNumberTable lineNumbers, int sourceLine) { int result = Integer.MAX_VALUE; for (LineNumber ln : lineNumbers.getLineNumberTable()) { int thisLine = ln.getLineNumber(); if (sourceLine < thisLine && thisLine < result) { result = thisLine; } } return result; } }
private static int getLineNumber(Method method, InstructionHandle handle) { LineNumberTable table = method.getCode().getLineNumberTable(); if (table == null) { return -1; } return table.getSourceLine(handle.getPosition()); } }
private void checkTable(LineNumberTable table) { if (DEBUG) { System.out.println("line number table has length " + table.getTableLength()); } LineNumber[] entries = table.getLineNumberTable(); int lastBytecode = -1; for (int i = 0; i < entries.length; ++i) { LineNumber ln = entries[i]; if (DEBUG) { System.out.println("Entry " + i + ": pc=" + ln.getStartPC() + ", line=" + ln.getLineNumber()); } int pc = ln.getStartPC(); if (pc <= lastBytecode) { throw new IllegalStateException("LineNumberTable is not sorted"); } } }
if (table != null && table.getTableLength() > 0) { checkTable(table); InstructionHandle handle = methodGen.getInstructionList().getStart(); sourceLine = table.getSourceLine(bytecodeOffset); } catch (ArrayIndexOutOfBoundsException e) { if (LINE_NUMBER_BUG) {
public LineNumberTable(final LineNumberTable c) { this(c.getNameIndex(), c.getLength(), c.getLineNumberTable(), c.getConstantPool()); }
@Override public void visitLineNumberTable(final LineNumberTable table) { stack.push(table); table.accept(visitor); final LineNumber[] numbers = table.getLineNumberTable(); for (final LineNumber number : numbers) { number.accept(this); } stack.pop(); }
/** * @return deep copy of this attribute */ @Override public Attribute copy( final ConstantPool _constant_pool ) { // TODO could use the lower level constructor and thereby allow // line_number_table to be made final final LineNumberTable c = (LineNumberTable) clone(); c.line_number_table = new LineNumber[line_number_table.length]; for (int i = 0; i < line_number_table.length; i++) { c.line_number_table[i] = line_number_table[i].copy(); } c.setConstantPool(_constant_pool); return c; }
/** * @return `LineNumberTable' attribute of all the local variables of this method. */ public LineNumberTable getLineNumberTable( final ConstantPoolGen cp ) { final int size = line_number_vec.size(); final LineNumber[] ln = new LineNumber[size]; for (int i = 0; i < size; i++) { ln[i] = line_number_vec.get(i).getLineNumber(); } return new LineNumberTable(cp.addUtf8("LineNumberTable"), 2 + ln.length * 4, ln, cp .getConstantPool()); }
private boolean hasDebugSymbols( JavaClass javaClass ) { boolean ret = false; Method[] methods = javaClass.getMethods(); for ( int i = 0; i < methods.length; i++ ) { LineNumberTable linenumbers = methods[i].getLineNumberTable(); if ( linenumbers != null && linenumbers.getLength() > 0 ) { ret = true; break; } } return ret; } }
/** * @return deep copy of this attribute */ public Attribute copy(ConstantPool constant_pool) { LineNumberTable c = (LineNumberTable)clone(); c.line_number_table = new LineNumber[line_number_table_length]; for(int i=0; i < line_number_table_length; i++) c.line_number_table[i] = line_number_table[i].copy(); c.constant_pool = constant_pool; return c; }
public LineNumberTable(LineNumberTable c) { this(c.getNameIndex(), c.getLength(), c.getLineNumberTable(), c.getConstantPool()); }
private void checkTable(LineNumberTable table) { if (DEBUG) { System.out.println("line number table has length " + table.getTableLength()); } LineNumber[] entries = table.getLineNumberTable(); int lastBytecode = -1; for (int i = 0; i < entries.length; ++i) { LineNumber ln = entries[i]; if (DEBUG) { System.out.println("Entry " + i + ": pc=" + ln.getStartPC() + ", line=" + ln.getLineNumber()); } int pc = ln.getStartPC(); if (pc <= lastBytecode) { throw new IllegalStateException("LineNumberTable is not sorted"); } } }
public void visitLineNumberTable(LineNumberTable table) { stack.push(table); table.accept(visitor); LineNumber[] numbers = table.getLineNumberTable(); for(int i=0; i < numbers.length; i++) numbers[i].accept(this); stack.pop(); }
if (table != null && table.getTableLength() > 0) { checkTable(table); InstructionHandle handle = methodGen.getInstructionList().getStart(); sourceLine = table.getSourceLine(bytecodeOffset); } catch (ArrayIndexOutOfBoundsException e) { if (LINE_NUMBER_BUG) {
/** * @return `LineNumberTable' attribute of all the local variables of this method. */ public LineNumberTable getLineNumberTable(ConstantPoolGen cp) { int size = line_number_vec.size(); LineNumber[] ln = new LineNumber[size]; try { for(int i=0; i < size; i++) ln[i] = ((LineNumberGen)line_number_vec.get(i)).getLineNumber(); } catch(ArrayIndexOutOfBoundsException e) {} // Never occurs return new LineNumberTable(cp.addUtf8("LineNumberTable"), 2 + ln.length * 4, ln, cp.getConstantPool()); }
@Override public void visitLineNumberTable(LineNumberTable obj) { super.visitLineNumberTable(obj); LineNumber[] line_number_table = obj.getLineNumberTable(); for (LineNumber aLine_number_table : line_number_table) { aLine_number_table.accept(this); } }
int startLine = lineNumberTable.getSourceLine(startPC); int endLine = lineNumberTable.getSourceLine(endPC); return new SourceLineAnnotation(className, sourceFile, startLine, endLine, startPC, endPC);
return new LineNumberTable(name_index, length, file, constant_pool);
int prevStartPc = -1; if (lineNumberTable != null) { for (LineNumber line : lineNumberTable.getLineNumberTable()) { int newLine = line.getLineNumber(); if (newLine == lineNum || newLine == -1) {
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; }