Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.Code


     * .classfile.IAnalysisCache, java.lang.Object)
     */
    @Override
    public UnpackedCode analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException {
        Method method = getMethod(analysisCache, descriptor);
        Code code = method.getCode();
        if (code == null) {
            return null;
        }

        byte[] instructionList = code.getCode();

        // Create callback
        UnpackedBytecodeCallback callback = new UnpackedBytecodeCallback(instructionList.length);

        // Scan the method.
View Full Code Here


                    equalsMethod = MethodAnnotation.fromVisitedMethod(this);
                    hasEqualsObject = true;
                    if (obj.isAbstract()) {
                        equalsObjectIsAbstract = true;
                    } else if (!obj.isNative()) {
                        Code code = obj.getCode();
                        byte[] codeBytes = code.getCode();
                        if (codeBytes.length == 9) {
                            int op0 = opcode(codeBytes, 0);
                            int op1 = opcode(codeBytes, 1);
                            int op2 = opcode(codeBytes, 2);
                            int op5 = opcode(codeBytes, 5);
View Full Code Here

    public boolean prescreen(Method method, ClassContext classContext) {
        if (method.getName().equals("<clinit>")) {
            return false;
        }

        Code code = method.getCode();
        if (code.getCode().length > 5000) {
            return false;
        }

        BitSet bytecodeSet = classContext.getBytecodeSet(method);
        if (bytecodeSet == null) {
View Full Code Here

        for (Attribute a : obj.getAttributes()) {
            if (a instanceof Deprecated) {
                return true;
            }
        }
        Code code = obj.getCode();
        if (code == null) {
            return false;
        }
        byte[] codeBytes = code.getCode();
        if (codeBytes.length > 1 && codeBytes.length < 10) {
            int lastOpcode = codeBytes[codeBytes.length - 1] & 0xff;
            if (lastOpcode != ATHROW) {
                return false;
            }
View Full Code Here

        if (mName.equals("isRequestedSessionIdFromURL") || mName.equals("isRequestedSessionIdFromUrl")) {
            return;
        }
        String sig = getMethodSig();
        if (mName.equals(baseClassName) && sig.equals("()V")) {
            Code code = obj.getCode();
            Method realVoidConstructor = findVoidConstructor(getThisClass());
            if (code != null && !markedAsNotUsable(obj)) {
                int priority = NORMAL_PRIORITY;
                if (codeDoesSomething(code)) {
                    priority--;
View Full Code Here

                        : null, cp);
        Attribute[] attributes = m.getAttributes();
        for (int i = 0; i < attributes.length; i++) {
            Attribute a = attributes[i];
            if (a instanceof Code) {
                Code c = (Code) a;
                setMaxStack(c.getMaxStack());
                setMaxLocals(c.getMaxLocals());
                CodeException[] ces = c.getExceptionTable();
                if (ces != null) {
                    for (int j = 0; j < ces.length; j++) {
                        CodeException ce = ces[j];
                        int type = ce.getCatchType();
                        ObjectType c_type = null;
                        if (type > 0) {
                            String cen = m.getConstantPool().getConstantString(type,
                                    Constants.CONSTANT_Class);
                            c_type = new ObjectType(cen);
                        }
                        int end_pc = ce.getEndPC();
                        int length = m.getCode().getCode().length;
                        InstructionHandle end;
                        if (length == end_pc) { // May happen, because end_pc is exclusive
                            end = il.getEnd();
                        } else {
                            end = il.findHandle(end_pc);
                            end = end.getPrev(); // Make it inclusive
                        }
                        addExceptionHandler(il.findHandle(ce.getStartPC()), end, il.findHandle(ce
                                .getHandlerPC()), c_type);
                    }
                }
                Attribute[] c_attributes = c.getAttributes();
                for (int j = 0; j < c_attributes.length; j++) {
                    a = c_attributes[j];
                    if (a instanceof LineNumberTable) {
                        LineNumber[] ln = ((LineNumberTable) a).getLineNumberTable();
                        for (int k = 0; k < ln.length; k++) {
View Full Code Here

        for (int i = 0; i < code_attrs.length; i++) {
            attrs_len += (code_attrs[i].getLength() + 6);
        }
        CodeException[] c_exc = getCodeExceptions();
        int exc_len = c_exc.length * 8; // Every entry takes 8 bytes
        Code code = null;
        if ((il != null) && !isAbstract() && !isNative()) {
            // Remove any stale code attribute
            Attribute[] attributes = getAttributes();
            for (int i = 0; i < attributes.length; i++) {
                Attribute a = attributes[i];
                if (a instanceof Code) {
                    removeAttribute(a);
                }
            }
            code = new Code(cp.addUtf8("Code"), 8 + byte_code.length + // prologue byte code
                    2 + exc_len + // exceptions
                    2 + attrs_len, // attributes
                    max_stack, max_locals, byte_code, c_exc, code_attrs, cp.getConstantPool());
            addAttribute(code);
        }
View Full Code Here

                int offset = 0;
                if (getMethodName().equals("tearDown")) {
                    offset = obj.getCode().length - 1;
                }
                Method superMethod = Lookup.findImplementation(we, getMethodName(), "()V");
                Code superCode = superMethod.getCode();
                if (superCode != null && superCode.getCode().length > 3) {
                    bugReporter.reportBug(new BugInstance(this, getMethodName().equals("setUp") ? "IJU_SETUP_NO_SUPER"
                            : "IJU_TEARDOWN_NO_SUPER", NORMAL_PRIORITY).addClassAndMethod(this).addMethod(we, superMethod)
                            .describe(MethodAnnotation.METHOD_OVERRIDDEN).addSourceLine(this, offset));
                }
            }
View Full Code Here

                if (method.isStatic() || !overridesSuperclassMethod(javaClass, method)) {
                    addFeature(METHOD_NAME_KEY + method.getName() + ":" + transformedMethodSignature);
                }

                Code code = method.getCode();
                if (code != null && code.getCode() != null && code.getCode().length >= MIN_CODE_LENGTH) {
                    addFeature(CODE_LENGTH_KEY + method.getName() + ":" + transformedMethodSignature + ":"
                            + code.getCode().length);
                }
            }
        }

        for (Field field : javaClass.getFields()) {
View Full Code Here

            if (i < args.length - 1) {
                file.print(",&nbsp;");
            }
        }
        file.println(")</B></P>");
        Code c = null;
        byte[] code = null;
        if (attributes.length > 0) {
            file.print("<H4>Attributes</H4><UL>\n");
            for (int i = 0; i < attributes.length; i++) {
                byte tag = attributes[i].getTag();
                if (tag != ATTR_UNKNOWN) {
                    file.print("<LI><A HREF=\"" + class_name + "_attributes.html#method"
                            + method_number + "@" + i + "\" TARGET=Attributes>"
                            + ATTRIBUTE_NAMES[tag] + "</A></LI>\n");
                } else {
                    file.print("<LI>" + attributes[i] + "</LI>");
                }
                if (tag == ATTR_CODE) {
                    c = (Code) attributes[i];
                    Attribute[] attributes2 = c.getAttributes();
                    code = c.getCode();
                    file.print("<UL>");
                    for (int j = 0; j < attributes2.length; j++) {
                        tag = attributes2[j].getTag();
                        file.print("<LI><A HREF=\"" + class_name + "_attributes.html#" + "method"
                                + method_number + "@" + i + "@" + j + "\" TARGET=Attributes>"
View Full Code Here

TOP

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

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.