Package org.apache.bcel.generic

Examples of org.apache.bcel.generic.InvokeInstruction


            }
            if (ins instanceof INVOKEINTERFACE) {
                continue;
            }

            InvokeInstruction inv = (InvokeInstruction) ins;
            TypeFrame frame = typeDataflow.getFactAtLocation(location);

            String methodName = inv.getMethodName(constantPoolGen);
            if (methodName.toLowerCase().indexOf("unsupported") >= 0) {
                continue;
            }
            String methodSig = inv.getSignature(constantPoolGen);
            if (methodSig.equals("()Ljava/lang/UnsupportedOperationException;")) {
                continue;
            }

            Set<XMethod> targets;
View Full Code Here


            Instruction ins = location.getHandle().getInstruction();
            switch (ins.getOpcode()) {
            case INVOKEVIRTUAL:
            case INVOKEINTERFACE:
                InvokeInstruction iins = (InvokeInstruction) ins;
                String invoking = iins.getName(cpg);
                if ( comparatorMethod(invoking) || booleanComparisonMethod(invoking) ) {
                    if (methodGen.getName().toLowerCase().indexOf("test") >= 0) {
                        break;
                    }
                    if (methodGen.getClassName().toLowerCase().indexOf("test") >= 0) {
                        break;
                    }
                    if (classContext.getJavaClass().getSuperclassName().toLowerCase().indexOf("test") >= 0) {
                        break;
                    }
                    if (location.getHandle().getNext().getInstruction().getOpcode() == POP) {
                        break;
                    }
                    String sig = iins.getSignature(cpg);

                    SignatureParser parser = new SignatureParser(sig);
                    if (parser.getNumParameters() == 1
                            && ( booleanComparisonMethod(invoking&& sig.endsWith(";)Z") || comparatorMethod(invoking) && sig.endsWith(";)I"))) {
                        checkForSelfOperation(classContext, location, valueNumberDataflow, "COMPARISON", method, methodGen,
View Full Code Here

            InstructionHandle handle = location.getHandle();
            Instruction ins = handle.getInstruction();

            if (ins instanceof InvokeInstruction) {
                InvokeInstruction invoke = (InvokeInstruction) ins;
                String className = invoke.getClassName(cpg);

                if (invoke.getMethodName(cpg).equals("putIfAbsent")) {
                    String signature = invoke.getSignature(cpg);
                    if (signature.equals("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;")
                            && !(invoke instanceof INVOKESTATIC) && extendsConcurrentMap(className)) {
                        InstructionHandle next = handle.getNext();
                        boolean isIgnored = next != null && next.getInstruction() instanceof POP;
                        //                        boolean isImmediateNullTest = next != null
View Full Code Here

                if (prevLocation != null && !isSafeValue(prevLocation, cpg)) {
                    stringAppendState.setSawUnsafeAppend(handle);
                }

            } else if (ins instanceof InvokeInstruction) {
                InvokeInstruction inv = (InvokeInstruction) ins;
                String sig1 = inv.getSignature(cpg);
                String sig2 = sig1.substring(sig1.indexOf(')'));

                if (sig2.indexOf("java/lang/String") >= 0) {
                    String methodName = inv.getMethodName(cpg);
                    String className = inv.getClassName(cpg);
                    if (methodName.equals("valueOf") && className.equals("java.lang.String")
                            && sig1.equals("(Ljava/lang/Object;)Ljava/lang/String;")) {
                        try {
                            TypeDataflow typeDataflow = classContext.getTypeDataflow(method);
                            TypeFrame frame = typeDataflow.getFactAtLocation(location);
View Full Code Here

            Location location = i.next();
            Instruction ins = location.getHandle().getInstruction();
            if (!(ins instanceof InvokeInstruction)) {
                continue;
            }
            InvokeInstruction invoke = (InvokeInstruction) ins;
            if (isDatabaseSink(invoke, cpg)) {
                ConstantFrame frame = dataflow.getFactAtLocation(location);
                int numArguments = frame.getNumArguments(invoke, cpg);
                Constant value = frame.getStackValue(numArguments - 1);
View Full Code Here

            Instruction ins = thrower.getInstruction();
            if (!(ins instanceof InvokeInstruction)) {
                continue;
            }

            InvokeInstruction inv = (InvokeInstruction) ins;
            boolean foundThrower = false;
            boolean foundNonThrower = false;

            if (inv instanceof INVOKEINTERFACE) {
                continue;
            }

            String className = inv.getClassName(cpg);

            Location loc = new Location(thrower, basicBlock);
            TypeFrame typeFrame = typeDataflow.getFactAtLocation(loc);
            XMethod primaryXMethod = XFactory.createXMethod(inv, cpg);
            // if (primaryXMethod.isAbstract()) continue;
            Set<XMethod> targetSet = null;
            try {

                if (className.startsWith("[")) {
                    continue;
                }
                String methodSig = inv.getSignature(cpg);
                if (!methodSig.endsWith("V")) {
                    continue;
                }

                targetSet = Hierarchy2.resolveMethodCallTargets(inv, typeFrame, cpg);
View Full Code Here

    enum Use { STORE_INTO_HTTP_SESSION, PASSED_TO_WRITE_OBJECT, STORED_IN_SERIALZIED_FIELD }

    @CheckForNull Use getUse(ConstantPoolGen cpg, Instruction ins) {
        if (ins instanceof InvokeInstruction) {
            InvokeInstruction invoke = (InvokeInstruction) ins;

            String mName = invoke.getMethodName(cpg);
            String cName = invoke.getClassName(cpg);

            if (mName.equals("setAttribute") && cName.equals("javax.servlet.http.HttpSession")) {
                return Use.STORE_INTO_HTTP_SESSION;
            }
            if (mName.equals("writeObject")
View Full Code Here

        ConstantPoolGen cpg = cfg.getMethodGen().getConstantPool();
        if (ins instanceof IfInstruction && ins.consumeStack(cpg) == 2) {
            isTest = true;
        else if (ins instanceof InvokeInstruction && ins.consumeStack(cpg) == 2) {
            InvokeInstruction invoke = (InvokeInstruction) ins;
            isTest = invoke.getMethodName(cpg).equals("equals") &&invoke.getSignature(cpg).equals("(Ljava/lang/Object;)Z") ;
        }
        if (isTest) {
            ValueNumber top = factAtLocation.getStackValue(0);
            if (top.hasFlag(ValueNumber.CONSTANT_VALUE)) {
                return;
View Full Code Here

            Instruction exceptionThrower = instructionHandle.getInstruction();
            if (!(exceptionThrower instanceof InvokeInstruction)) {
                continue;
            }

            InvokeInstruction inv = (InvokeInstruction) exceptionThrower;
            boolean foundThrower = false;
            boolean foundNonThrower = false;
            boolean isExact = true;
            XMethod primaryXMethod = XFactory.createXMethod(inv, cpg);
            final String methodName = primaryXMethod.getName();
            final boolean matches = unconditionalThrowerPattern.matcher(methodName).matches();
            if (DEBUG) {
                System.out.println("Checking '" + methodName + "' is " + matches);
            }

            if (matches) {
                if (DEBUG) {
                    System.out.println("\tmatched for " + instructionHandle + " : " + primaryXMethod);
                }

                foundThrower = true;
            } else if (inv instanceof INVOKEINTERFACE) {
                continue;
            } else if (inv instanceof INVOKESTATIC) {
                foundThrower = isUnconditionalThrower(primaryXMethod);
            } else {
                String className = inv.getClassName(cpg);
                if (DEBUG) {
                    System.out.println("\tlooking up method for " + instructionHandle + " : " + primaryXMethod);
                }

                Location loc = new Location(instructionHandle, basicBlock);
                TypeFrame typeFrame = typeDataflow.getFactAtLocation(loc);
                // if (primaryXMethod.isAbstract()) continue;
                Set<XMethod> targetSet = null;
                try {

                    if (className.startsWith("[")) {
                        continue;
                    }
                    String methodSig = inv.getSignature(cpg);
                    if (!methodSig.endsWith("V") && !methodSig.endsWith("Exception;")
                            && !methodSig.endsWith("Error;") && !methodSig.endsWith(")Ljava/lang/Object;")) {
                        continue;
                    }
View Full Code Here

            while (j.hasNext()) {
                InstructionHandle handle = j.next();

                Instruction ins = handle.getInstruction();
                if (ins instanceof InvokeInstruction) {
                    InvokeInstruction inv = (InvokeInstruction) ins;
                    Method called = isSelfCall(inv);
                    if (called != null) {
                        // Add edge to call graph
                        CallSite callSite = new CallSite(method, block, handle);
                        callGraph.createEdge(node, callGraph.getNodeForMethod(called), callSite);
View Full Code Here

TOP

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

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.