Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.LineNumberTable


            XClass x = getXClassOperand();

            checkPUTFIELD: if (putFieldPC + 10 > getPC() && f != null && obj != null && f.equals(putFieldXField)
                    && !f.isSynthetic() && obj.equals(putFieldObj) && x != null) {

                LineNumberTable table = getCode().getLineNumberTable();
                if (table != null) {
                    int first = table.getSourceLine(putFieldPC);
                    int second = table.getSourceLine(getPC());
                    if (first + 1 != second && first != second) {
                        break checkPUTFIELD;
                    }
                } else if (putFieldPC + 3 != getPC()) {
                    break checkPUTFIELD;
View Full Code Here


            }

            BitSet linesMentionedMultipleTimes = getClassContext().linesMentionedMultipleTimes(getMethod());
            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) {
                if (lineNumberTable != null) {
                    int line0 = lineNumberTable.getSourceLine(item0.getPC());
                    int line1 = lineNumberTable.getSourceLine(item1.getPC());
                    int firstPos = Math.min(item0.getPC(), item1.getPC());
                    if (firstPos < lastMethodCall && line0 != line1) {
                        return;
                    }
View Full Code Here

     *            the method being visited
     * @return the SourceLineAnnotation, or null if we do not have line number
     *         information for the method
     */
    public static SourceLineAnnotation fromVisitedMethod(MethodGen methodGen, String sourceFile) {
        LineNumberTable lineNumberTable = methodGen.getLineNumberTable(methodGen.getConstantPool());
        String className = methodGen.getClassName();
        int codeSize = methodGen.getInstructionList().getLength();
        if (lineNumberTable == null) {
            return createUnknown(className, sourceFile, 0, codeSize - 1);
        }
View Full Code Here

        String sourceFile = javaClass.getSourceFileName();
        if (method == null) {
            return createUnknown(javaClass.getClassName(), sourceFile);
        }
        Code code = method.getCode();
        LineNumberTable lineNumberTable = method.getLineNumberTable();
        if (code == null || lineNumberTable == null) {
            return createUnknown(javaClass.getClassName(), sourceFile);
        }

        return forEntireMethod(javaClass.getClassName(), sourceFile, lineNumberTable, code.getLength());
View Full Code Here

        SourceLineAnnotation result = null;

        try {
            Method m = Global.getAnalysisCache().getMethodAnalysis(Method.class, methodDescriptor);
            XClass xclass = Global.getAnalysisCache().getClassAnalysis(XClass.class, methodDescriptor.getClassDescriptor());
            LineNumberTable lnt = m.getLineNumberTable();
            String sourceFile = xclass.getSource();
            if (sourceFile != null && lnt != null) {
                int firstLine = Integer.MAX_VALUE;
                int bytecode = 0;
                LineNumber[] entries = lnt.getLineNumberTable();
                for (LineNumber entry : entries) {
                    if (entry.getLineNumber() < firstLine) {
                        firstLine = entry.getLineNumber();
                        bytecode = entry.getStartPC();
                    }
View Full Code Here

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

     *            the bytecode offset of the end instruction in the range
     * @return the SourceLineAnnotation, or null if we do not have line number
     *         information for the instruction
     */
    public static SourceLineAnnotation fromVisitedInstructionRange(BytecodeScanningDetector visitor, int startPC, int endPC) {
        LineNumberTable lineNumberTable = getLineNumberTable(visitor);
        String className = visitor.getDottedClassName();
        String sourceFile = visitor.getSourceFile();

        if (lineNumberTable == null) {
            return createUnknown(className, sourceFile, startPC, endPC);
        }

        int startLine = lineNumberTable.getSourceLine(startPC);
        int endLine = lineNumberTable.getSourceLine(endPC);
        return new SourceLineAnnotation(className, sourceFile, startLine, endLine, startPC, endPC);
    }
View Full Code Here

            int startPC, int endPC) {
        if (startPC > endPC) {
            throw new IllegalArgumentException("Start pc " + startPC + " greater than end pc " + endPC);
        }

        LineNumberTable lineNumberTable = getLineNumberTable(visitor);
        String className = visitor.getDottedClassName();
        String sourceFile = visitor.getSourceFile();

        if (lineNumberTable == null) {
            return createUnknown(className, sourceFile, startPC, endPC);
        }

        int startLine = lineNumberTable.getSourceLine(startPC);
        int endLine = lineNumberTable.getSourceLine(endPC);
        return new SourceLineAnnotation(className, sourceFile, startLine, endLine, startPC, endPC);
    }
View Full Code Here

     *         information for the instruction
     */
    @Nonnull
    public static SourceLineAnnotation fromVisitedInstruction(ClassContext classContext, MethodGen methodGen, String sourceFile,
            @Nonnull InstructionHandle handle) {
        LineNumberTable table = methodGen.getLineNumberTable(methodGen.getConstantPool());
        String className = methodGen.getClassName();

        int bytecodeOffset = handle.getPosition();

        if (table == null) {
            return createUnknown(className, sourceFile, bytecodeOffset, bytecodeOffset);
        }

        int lineNumber = table.getSourceLine(handle.getPosition());
        return new SourceLineAnnotation(className, sourceFile, lineNumber, lineNumber, bytecodeOffset, bytecodeOffset);
    }
View Full Code Here

     * @param end
     *            the end instruction (inclusive)
     */
    public static SourceLineAnnotation fromVisitedInstructionRange(ClassContext classContext, MethodGen methodGen,
            String sourceFile, InstructionHandle start, InstructionHandle end) {
        LineNumberTable lineNumberTable = methodGen.getLineNumberTable(methodGen.getConstantPool());
        String className = methodGen.getClassName();

        if (lineNumberTable == null) {
            return createUnknown(className, sourceFile, start.getPosition(), end.getPosition());
        }

        int startLine = lineNumberTable.getSourceLine(start.getPosition());
        int endLine = lineNumberTable.getSourceLine(end.getPosition());
        return new SourceLineAnnotation(className, sourceFile, startLine, endLine, start.getPosition(), end.getPosition());
    }
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.