Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.Instruction


            instanceOfFrame.copyFrom(fact);
        }

        // Model the instruction
        visitor.setFrameAndLocation(fact, new Location(handle, basicBlock));
        Instruction ins = handle.getInstruction();
        visitor.analyzeInstruction(ins);

        if (!fact.isValid()) {
            return;
        }

        // Special case:
        // The instruction may have produced previously seen values
        // about which new is-null information is known.
        // If any other instances of the produced values exist,
        // update their is-null information.
        // Also, make a note of any newly-produced null values.

        int numProduced = ins.produceStack(methodGen.getConstantPool());
        if (numProduced == Constants.UNPREDICTABLE) {
            throw new DataflowAnalysisException("Unpredictable stack production", methodGen, handle);
        }

        int start = fact.getNumSlots() - numProduced;
View Full Code Here


                    ValueNumberFrame vnaFrame = vnaDataflow.getStartFact(destBlock);
                    if (vnaFrame == null) {
                        throw new IllegalStateException("no vna frame at block entry?");
                    }

                    Instruction firstInDest = edge.getTarget().getFirstInstruction().getInstruction();

                    IsNullValue instance = fact.getInstance(firstInDest, methodGen.getConstantPool());

                    if (instance.isDefinitelyNull()) {
                        // If we know the variable is null, this edge is
View Full Code Here

    @Override
    public MatchResult match(InstructionHandle handle, ConstantPoolGen cpg, ValueNumberFrame before, ValueNumberFrame after,
            BindingSet bindingSet) throws DataflowAnalysisException {

        Instruction ins = handle.getInstruction();
        if (!(ins instanceof NEW)) {
            return null;
        }

        LocalVariable result = new LocalVariable(after.getTopValue());
View Full Code Here

            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);
                    }
                }
            }
        }

        IdentityHashMap<InstructionHandle, Object> sometimesGood = new IdentityHashMap<InstructionHandle, Object>();

        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()) {
                sometimesGood.put(handle, null);
            }
        }

        // System.out.println(nullValueDataflow);
        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;
            }

            if (sometimesGood.containsKey(handle)) {
                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()) {
                InstructionHandle nextHandle = handle.getNext();
                Instruction next = nextHandle.getInstruction();
                int position = location
                        .getHandle().getPosition();
                int catchSizeANY = Util.getSizeOfSurroundingTryBlock(method, "", position);
                if (catchSizeANY < Integer.MAX_VALUE && isNullTestedClose( classContext, load, nextHandle, next)) {
                    continue;
View Full Code Here

        IFNULL ifNull = (IFNULL) next;
        InstructionHandle nextNextHandle = nextHandle.getNext(); // aload
        if (nextNextHandle == null) {
            return false;
        }
        Instruction nextInstruction = nextNextHandle.getInstruction();

        if (!(nextInstruction instanceof ALOAD)) {
            return false;
        }
        ALOAD nextLoad = (ALOAD) nextInstruction;
        if (load.getIndex() != nextLoad.getIndex()) {
            return false;
        }
        InstructionHandle nextNextNextHandle = nextNextHandle.getNext(); // invoke
        if (nextNextNextHandle == null) {
            return false;
        }
        Instruction nextNextNextInstruction = nextNextNextHandle.getInstruction();
        if (!(nextNextNextInstruction instanceof INVOKEVIRTUAL)) {
            return false;
        }
        INVOKEVIRTUAL invokeVirtual = (INVOKEVIRTUAL) nextNextNextInstruction;
        String methodName = invokeVirtual.getMethodName(classContext.getConstantPoolGen());
View Full Code Here

    @Override
    public MatchResult match(InstructionHandle handle, ConstantPoolGen cpg, ValueNumberFrame before, ValueNumberFrame after,
            BindingSet bindingSet) throws DataflowAnalysisException {

        // See if the instruction is an InvokeInstruction
        Instruction ins = handle.getInstruction();
        if (!(ins instanceof InvokeInstruction)) {
            return null;
        }
        InvokeInstruction inv = (InvokeInstruction) ins;
View Full Code Here

    @Override
    public MatchResult match(InstructionHandle handle, ConstantPoolGen cpg, ValueNumberFrame before, ValueNumberFrame after,
            BindingSet bindingSet) throws DataflowAnalysisException {

        Instruction ins = handle.getInstruction();
        FieldInstruction fieldIns;
        Variable field;

        // The instruction must be PUTFIELD or PUTSTATIC
        if (ins instanceof PUTFIELD) {
View Full Code Here

            ConstantPoolGen cpg = classContext.getConstantPoolGen();
            TypeDataflow typeDataflow = classContext.getTypeDataflow(method);

            for (Iterator<Location> i = classContext.getCFG(method).locationIterator(); i.hasNext();) {
                Location location = i.next();
                Instruction ins = location.getHandle().getInstruction();
                try {
                    ValueNumberFrame vnaFrame = classContext.getValueNumberDataflow(method).getFactAtLocation(location);
                    if (!vnaFrame.isValid()) {
                        continue;
                    }

                    if (ins instanceof InvokeInstruction) {
                        examineCallSite(location, cpg, typeDataflow);
                    } else if (methodAnnotation == NullnessAnnotation.NONNULL && ins.getOpcode() == Constants.ARETURN) {
                        examineReturnInstruction(location);
                    } else if (ins instanceof PUTFIELD) {
                        examinePutfieldInstruction(location, (PUTFIELD) ins, cpg);
                    }
                } catch (ClassNotFoundException e) {
View Full Code Here

                Location loc = i.next();
                int pc2 = loc.getHandle().getPosition();
                if (pc2 >= pc || pc2 < pc - 30) {
                    continue;
                }
                Instruction ins = loc.getHandle().getInstruction();
                if ((ins instanceof IFNONNULL || ins instanceof IFNULL || ins instanceof NullnessConversationInstruction)
                        && !seen.get(pc2)) {
                    ifNullTests++;
                    seen.set(pc2);
                }
View Full Code Here

        }
        int pc = location.getHandle().getPosition();
        BugAnnotation variable = ValueNumberSourceInfo.findAnnotationFromValueNumber(method, location, valueNumber, vnaFrame,
                "VALUE_OF");
        addPropertiesForDereferenceLocations(propertySet, Collections.singleton(location), isConsistent);
        Instruction ins = location.getHandle().getInstruction();
        if (ins instanceof InvokeInstruction && refValue.isDefinitelyNull()) {
            InvokeInstruction iins = (InvokeInstruction) ins;
            if (iins.getMethodName(classContext.getConstantPoolGen()).equals("close")
                    && iins.getSignature(classContext.getConstantPoolGen()).equals("()V")) {
                propertySet.addProperty(NullDerefProperty.CLOSING_NULL);
View Full Code Here

TOP

Related Classes of org.apache.bcel.generic.Instruction

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.