Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.Instruction


    /**
     * Set the instruction for loading the value of this variable onto the
     * JVM stack and returns the old instruction.
     */
    public Instruction setLoadInstruction(Instruction instruction) {
        Instruction tmp = _loadInstruction;
        _loadInstruction = instruction;
        return tmp;
    }
View Full Code Here


    /**
     * Set the instruction for storing a value from the stack into this
     * variable and returns the old instruction.
     */
    public Instruction setStoreInstruction(Instruction instruction) {
        Instruction tmp = _storeInstruction;
        _storeInstruction = instruction;
        return tmp;
    }
View Full Code Here

            try {
                if (!match[0].hasTargeters() &&
                    !match[1].hasTargeters() &&
                    !match[2].hasTargeters())
                {
                    Instruction load_m = match[1].getInstruction();
                    il.insert(match[0], load_m);
                    il.delete(match[1], match[2]);
                }
            }
            catch (TargetLostException e) {
View Full Code Here

    private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, ClassNotFoundException,
    DataflowAnalysisException {
        CFG cfg = classContext.getCFG(method);
        for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
            Location location = i.next();
            Instruction ins = location.getHandle().getInstruction();

            if (ins instanceof InvokeInstruction) {
                if (TARGET_METHOD != null
                        && !((InvokeInstruction) ins).getMethodName(classContext.getConstantPoolGen()).equals(TARGET_METHOD)) {
                    continue;
View Full Code Here

                Instruction.readInstruction(sequence);
            }

            int pos;
            while (sequence.available() > 0 && ((pos = sequence.getIndex()) < end)) {
                Instruction ins = Instruction.readInstruction(sequence);
                if ((ins instanceof BranchInstruction) && !(ins instanceof TABLESWITCH) && !(ins instanceof LOOKUPSWITCH)) {
                    BranchInstruction bi = (BranchInstruction) ins;
                    int offset = bi.getIndex();
                    int target = offset + pos;
                    if (target >= end) { // or target < start ??
View Full Code Here

        int lockCount = mg.isSynchronized() ? 1 : 0;
        boolean sawWaitOrNotify = false;

        InstructionHandle handle = mg.getInstructionList().getStart();
        while (handle != null && !(lockCount >= 2 && sawWaitOrNotify)) {
            Instruction ins = handle.getInstruction();
            if (ins instanceof MONITORENTER) {
                ++lockCount;
            } else if (ins instanceof INVOKEVIRTUAL) {
                INVOKEVIRTUAL inv = (INVOKEVIRTUAL) ins;
                String methodName = inv.getMethodName(cpg);
View Full Code Here

    @Override
    public Stream createStream(Location location, ObjectType type, ConstantPoolGen cpg,
            RepositoryLookupFailureCallback lookupFailureCallback) {

        try {
            Instruction ins = location.getHandle().getInstruction();

            // For now, just support instance methods
            short opcode = ins.getOpcode();
            if (!invokeOpcodeSet.get(opcode)) {
                return null;
            }

            // Is invoked class a subtype of the base class we want
View Full Code Here

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

        for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
            Location location = i.next();
            Instruction ins = location.getHandle().getInstruction();
            short opcode = ins.getOpcode();

            // Field store instruction?
            if (opcode != Constants.PUTFIELD && opcode != Constants.PUTSTATIC) {
                continue;
            }
View Full Code Here

                }
                Location location = new Location(handle, block);

                // Keep track of whether we saw any instructions
                // that might actually have created a new object.
                Instruction ins = handle.getInstruction();
                if (DEBUG) {
                    System.out.println(location);
                }
                if (ins instanceof AllocationInstruction) {
                    sawNEW = true;
                } else if (ins instanceof InvokeInstruction) {
                    if (ins instanceof INVOKESTATIC
                            && ((INVOKESTATIC) ins).getMethodName(classContext.getConstantPoolGen()).startsWith("new")) {
                        sawNEW = true;
                    }
                    sawINVOKE = true;
                }

                // Compute lock set intersection for all matched
                // instructions.
                LockSet insLockSet = lockDataflow.getFactAtLocation(location);
                if (lockSet == null) {
                    lockSet = new LockSet();
                    lockSet.copyFrom(insLockSet);
                } else {
                    lockSet.intersectWith(insLockSet);
                }
            }
        }

        if (!(sawNEW || sawINVOKE)) {
            return;
        }
        if (lockSet == null) {
            throw new IllegalStateException("lock set is null");
        }
        if (!lockSet.isEmpty()) {
            return;
        }

        boolean sawGetStaticAfterPutStatic = false;
        check: if (signature.startsWith("[") || signature.startsWith("L")) {

            BitSet postStore = domAnalysis.getAllDominatedBy(store.getBasicBlock());
            for (BasicBlock block : cfg.getBlocks(postStore)) {
                for (Iterator<InstructionHandle> j = block.instructionIterator(); j.hasNext();) {
                    InstructionHandle handle = j.next();

                    InstructionHandle nextHandle = handle.getNext();
                    Instruction ins = handle.getInstruction();

                    if (ins instanceof GETSTATIC && potentialInitialization(nextHandle)) {
                        XField field2 = XFactory.createXField((FieldInstruction) ins, methodGen.getConstantPool());
                        if (xfield.equals(field2)) {
                            sawGetStaticAfterPutStatic = true;
View Full Code Here

    private boolean potentialInitialization(InstructionHandle nextHandle) {
        if (nextHandle == null) {
            return true;
        }
        Instruction instruction = nextHandle.getInstruction();
        if (instruction instanceof ReturnInstruction) {
            return false;
        }
        if (instruction instanceof IfInstruction) {
            return false;
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.