Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.LineNumber


     */
    public static SourceLineAnnotation forEntireMethod(@DottedClassName String className, String sourceFile, LineNumberTable lineNumberTable,
            int codeSize) {
        LineNumber[] table = lineNumberTable.getLineNumberTable();
        if (table != null && table.length > 0) {
            LineNumber first = table[0];
            LineNumber last = table[table.length - 1];
            return new SourceLineAnnotation(className, sourceFile, first.getLineNumber(), last.getLineNumber(), 0, codeSize - 1);
        } else {
            return createUnknown(className, sourceFile, 0, codeSize - 1);
        }
    }
View Full Code Here


                for (int j = 0; j < c_attributes.length; j++) {
                    a = c_attributes[j];
                    if (a instanceof LineNumberTable) {
                        LineNumber[] ln = ((LineNumberTable) a).getLineNumberTable();
                        for (int k = 0; k < ln.length; k++) {
                            LineNumber l = ln[k];
                            InstructionHandle ih = il.findHandle(l.getStartPC());
                            if (ih != null) {
                                addLineNumber(ih, l.getLineNumber());
                            }
                        }
                    } else if (a instanceof LocalVariableTable) {
                        LocalVariable[] lv = ((LocalVariableTable) a).getLocalVariableTable();
                        removeLocalVariables();
                        for (int k = 0; k < lv.length; k++) {
                            LocalVariable l = lv[k];
                            InstructionHandle start = il.findHandle(l.getStartPC());
                            InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength());
                            // Repair malformed handles
                            if (null == start) {
                                start = il.getStart();
                            }
                            if (null == end) {
                                end = il.getEnd();
                            }
                            addLocalVariable(l.getName(), Type.getType(l.getSignature()), l
                                    .getIndex(), start, end);
                        }
                    } else {
                        addCodeAttribute(a);
                    }
View Full Code Here

                    }
                }
                if (sourceLine >= 0) {
                    ++numGood;
                }
                lineNumberMap.put(handle, new LineNumber(bytecodeOffset, sourceLine));
                handle = handle.getNext();
                ++numBytecodes;
            }
            hasLineNumbers = true;
View Full Code Here

            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");
            }
        }
    }
View Full Code Here

     *
     * This relies on that the instruction list has already been dumped to byte code or
     * or that the `setPositions' methods has been called for the instruction list.
     */
    public LineNumber getLineNumber() {
        return new LineNumber(ih.getPosition(), src_line);
    }
View Full Code Here

   *
   * This relies on that the instruction list has already been dumped to byte code or
   * or that the `setPositions' methods has been called for the instruction list.
   */
  public LineNumber getLineNumber() {
    return new LineNumber(ih.getPosition(), src_line);
  }
View Full Code Here

            // Append a table of the line numbers.
            if (printLineNumbers) {
                LineNumberTable lt = m.getLineNumberTable();
                if (lt != null) {
                    LineNumber nums[] = lt.getLineNumberTable();
                    if (nums.length > 0) {
                        String indentStr3 = indentString(indent * 3);
                        result.append(indentString(
                                indent * 2, "LineNumberTable:"));
                        result.append(n);
                        for (int j = 0; j < nums.length; j++) {
                            LineNumber ln = nums[j];
                            result.append(indentStr3);
                            result.append("line ");
                            result.append(ln.getLineNumber());
                            result.append(": ");
                            result.append(ln.getStartPC());
                            result.append(n);
                        }
                    }
                }
            }
View Full Code Here

            // Append a table of the line numbers.
            if (printLineNumbers) {
                LineNumberTable lt = m.getLineNumberTable();
                if (lt != null) {
                    LineNumber nums[] = lt.getLineNumberTable();
                    if (nums.length > 0) {
                        String indentStr3 = indentString(indent * 3);
                        result.append(indentString(
                                indent * 2, "LineNumberTable:"));
                        result.append(n);
                        for (int j = 0; j < nums.length; j++) {
                            LineNumber ln = nums[j];
                            result.append(indentStr3);
                            result.append("line ");
                            result.append(ln.getLineNumber());
                            result.append(": ");
                            result.append(ln.getStartPC());
                            result.append(n);
                        }
                    }
                }
            }
View Full Code Here

                for (int j = 0; j < c_attributes.length; j++) {
                    a = c_attributes[j];
                    if (a instanceof LineNumberTable) {
                        LineNumber[] ln = ((LineNumberTable) a).getLineNumberTable();
                        for (int k = 0; k < ln.length; k++) {
                            LineNumber l = ln[k];
                            InstructionHandle ih = il.findHandle(l.getStartPC());
                            if (ih != null) {
                                addLineNumber(ih, l.getLineNumber());
                            }
                        }
                    } else if (a instanceof LocalVariableTable) {
                        LocalVariable[] lv = ((LocalVariableTable) a).getLocalVariableTable();
                        removeLocalVariables();
                        for (int k = 0; k < lv.length; k++) {
                            LocalVariable l = lv[k];
                            InstructionHandle start = il.findHandle(l.getStartPC());
                            InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength());
                            // Repair malformed handles
                            if (null == start) {
                                start = il.getStart();
                            }
                            if (null == end) {
                                end = il.getEnd();
                            }
                            addLocalVariable(l.getName(), Type.getType(l.getSignature()), l
                                    .getIndex(), start, end);
                        }
                    } else if (a instanceof LocalVariableTypeTable) {
                        LocalVariable[] lv = ((LocalVariableTypeTable) a).getLocalVariableTypeTable();
                        removeLocalVariables();
                        for (int k = 0; k < lv.length; k++) {
                            LocalVariable l = lv[k];
                            InstructionHandle start = il.findHandle(l.getStartPC());
                            InstructionHandle end = il.findHandle(l.getStartPC() + l.getLength());
                            // Repair malformed handles
                            if (null == start) {
                                start = il.getStart();
                            }
                            if (null == end) {
                                end = il.getEnd();
                            }
                            addLocalVariable(l.getName(), Type.getType(l.getSignature()), l
                                    .getIndex(), start, end);
                        }
                    } else {
                        addCodeAttribute(a);
                    }
View Full Code Here

     *
     * This relies on that the instruction list has already been dumped to byte code or
     * or that the `setPositions' methods has been called for the instruction list.
     */
    public LineNumber getLineNumber() {
        return new LineNumber(ih.getPosition(), src_line);
    }
View Full Code Here

TOP

Related Classes of org.apache.bcel.classfile.LineNumber

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.