Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.LineNumberTable


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


        MethodGen methodGen = classContext.getMethodGen(method);
        String sourceFile = classContext.getJavaClass().getSourceFileName();

        if (lineMentionedMultipleTimes.cardinality() > 0) {
            linesWithLoadsOfNotDefinitelyNullValues = new BitSet();
            LineNumberTable lineNumbers = method.getLineNumberTable();
            for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
                Location location = i.next();

                InstructionHandle handle = location.getHandle();
                Instruction ins = handle.getInstruction();
                if (!(ins instanceof ALOAD)) {
                    continue;
                }

                IsNullValueFrame frame = nullValueDataflow.getFactAtLocation(location);
                if (!frame.isValid()) {
                    // This basic block is probably dead
                    continue;
                }
                // System.out.println(handle.getPosition() + "\t" +
                // ins.getName() + "\t" + frame);

                ALOAD load = (ALOAD) ins;

                int index = load.getIndex();
                IsNullValue v = frame.getValue(index);
                if (!v.isDefinitelyNull()) {
                    int sourceLine = lineNumbers.getSourceLine(handle.getPosition());
                    if (sourceLine > 0) {
                        linesWithLoadsOfNotDefinitelyNullValues.set(sourceLine);
                    }
                }
            }
View Full Code Here

    boolean callToAssertionMethod(Location loc) {

        InstructionHandle h = loc.getHandle();
        int firstPos = h.getPosition();

        LineNumberTable ln = method.getLineNumberTable();
        int firstLine = ln == null ? -1 : ln.getSourceLine(firstPos);

        while (h != null) {
            int pos = h.getPosition();

            if (ln == null) {
                if (pos > firstPos + 15) {
                    break;
                }
            } else {
                int line = ln.getSourceLine(pos);
                if (line != firstLine) {
                    break;
                }
            }
            Instruction i = h.getInstruction();
View Full Code Here

                }
            }
            return true;
        }

        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 (lineNumber > 0 && !linesMentionedMultipleTimes.get(lineNumber)) {
                    uniqueDereferenceLocations = true;
                }
            }
        }
View Full Code Here

        bugAccumulator.reportAccumulatedBugs();
    }

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

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

         */
        byte[] byte_code = null;
        if (il != null) {
            byte_code = il.getByteCode();
        }
        LineNumberTable lnt = null;
        LocalVariableTable lvt = null;
        /* Create LocalVariableTable and LineNumberTable attributes (for debuggers, e.g.)
         */
        if ((variable_vec.size() > 0) && !strip_attributes) {
            addCodeAttribute(lvt = getLocalVariableTable(cp));
View Full Code Here

            System.out.println("Warning: VN " + valueNumber + " invf: " + frame + " @ " + location);
        }

        boolean isConsistent = true;
        Iterator<BasicBlock> bbIter = invDataflow.getCFG().blockIterator();
        LineNumberTable table = method.getLineNumberTable();
        int position = exceptionThrowerHandle.getPosition();
        int line = table == null ? 0 : table.getSourceLine(position);
        while (bbIter.hasNext()) {
            BasicBlock bb = bbIter.next();

            if (!bb.isNullCheck()) {
                continue;
            }

            InstructionHandle eth = bb.getExceptionThrower();
            if (eth == exceptionThrowerHandle) {
                continue;
            }
            if (eth.getInstruction().getOpcode() != exceptionThrower.getOpcode()) {
                continue;
            }

            int ePosition = eth.getPosition();
            if (ePosition == position || table != null && line == table.getSourceLine(ePosition)) {

                IsNullValueFrame frame2 = invDataflow.getStartFact(bb);
                if (!frame2.isValid()) {
                    continue;
                }
View Full Code Here

            ValueNumberFrame vnaFrame) {
        return ValueNumberSourceInfo.findRequiredAnnotationFromValueNumber(method, location, valueNumber, vnaFrame, null);
    }

    private static int getLineNumber(Method method, InstructionHandle handle) {
        LineNumberTable table = method.getCode().getLineNumberTable();
        if (table == null) {
            return -1;
        }
        return table.getSourceLine(handle.getPosition());
    }
View Full Code Here

            System.out.println("Method: " + methodGen.getName() + " - " + methodGen.getSignature() + "in class "
                    + methodGen.getClassName());
        }

        // Associate line number information with each InstructionHandle
        LineNumberTable table = methodGen.getLineNumberTable(methodGen.getConstantPool());

        if (table != null && table.getTableLength() > 0) {
            checkTable(table);
            InstructionHandle handle = methodGen.getInstructionList().getStart();
            while (handle != null) {
                int bytecodeOffset = handle.getPosition();
                if (bytecodeOffset < 0) {
                    throw new IllegalStateException("Bad bytecode offset: " + bytecodeOffset);
                }
                if (DEBUG) {
                    System.out.println("Looking for source line for bytecode offset " + bytecodeOffset);
                }
                int sourceLine;
                try {
                    sourceLine = table.getSourceLine(bytecodeOffset);
                } catch (ArrayIndexOutOfBoundsException e) {
                    if (LINE_NUMBER_BUG) {
                        throw e;
                    } else {
                        sourceLine = -1;
View Full Code Here

TOP

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

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.