Package org.apache.bcel.classfile

Examples of org.apache.bcel.classfile.JavaClass


    public void visitClassContext(ClassContext classContext) {
        if (!enabled()) {
            return;
        }

        JavaClass jClass = classContext.getJavaClass();
        XClass xClass = classContext.getXClass();

        try {

            if (!isJunit3TestCase(xClass)) {
                return;
            }
            if ((jClass.getAccessFlags() & ACC_ABSTRACT) == 0) {
                if (!hasTestMethods(jClass)) {
                    bugReporter.reportBug(new BugInstance(this, "IJU_NO_TESTS", LOW_PRIORITY).addClass(jClass));
                }
            }
            directChildOfTestCase = "junit.framework.TestCase".equals(jClass.getSuperclassName());
            jClass.accept(this);
        } catch (ClassNotFoundException cnfe) {
            bugReporter.reportMissingClass(cnfe);
        }

    }
View Full Code Here


        if (hasSuite(methods)) {
            return true;
        }

        try {
            JavaClass sClass = jClass.getSuperClass();
            if (sClass != null) {
                return hasTestMethods(sClass);
            }
        } catch (ClassNotFoundException e) {
            AnalysisContext.reportMissingClass(e);
View Full Code Here

            sawSuperCall = false;
            super.visit(obj);
            if (sawSuperCall) {
                return;
            }
            JavaClass we = Lookup.findSuperImplementor(getThisClass(), getMethodName(), "()V", bugReporter);
            if (we != null && !we.getClassName().equals("junit.framework.TestCase")) {
                // OK, got a bug
                int offset = 0;
                if (getMethodName().equals("tearDown")) {
                    offset = obj.getCode().length - 1;
                }
View Full Code Here

            throws ClassNotFoundException {
        String className = inv.getClassName(cpg);
        String methodName = inv.getName(cpg);
        String methodSig = inv.getSignature(cpg);

        JavaClass jclass = Repository.lookupClass(className);
        return findMethod(jclass, methodName, methodSig, chooser);
    }
View Full Code Here

            if (className.startsWith("[")) {
                // Java 1.5 allows array classes to appear as the class name
                className = "java.lang.Object";
            }

            JavaClass jClass = Repository.lookupClass(className);
            return findInvocationLeastUpperBound(jClass, methodName, methodSig, methodChooser,
                    opcode == Constants.INVOKEINTERFACE);

        }
    }
View Full Code Here

                if (result != null) {
                    return null;
                }
            }
        } else {
            JavaClass sClass = jClass.getSuperClass();
            if (sClass != null) {
                return findInvocationLeastUpperBound(sClass, methodName, methodSig, methodChooser, invokeInterface);
            }
        }
        return null;
View Full Code Here

        String methodSig = invokeInstruction.getSignature(cpg);

        // Array method calls aren't virtual.
        // They should just resolve to Object methods.
        if (receiverType instanceof ArrayType) {
            JavaClass javaLangObject = AnalysisContext.currentAnalysisContext().lookupClass("java.lang.Object");
            JavaClassAndMethod classAndMethod = findMethod(javaLangObject, methodName, methodSig, INSTANCE_METHOD);
            if (classAndMethod != null) {
                result.add(classAndMethod);
            }
            return result;
        }

        if (receiverType instanceof NullType) {
            return Collections.<JavaClassAndMethod> emptySet();
        }
        AnalysisContext analysisContext = AnalysisContext.currentAnalysisContext();

        // Get the receiver class.
        String receiverClassName = ((ObjectType) receiverType).getClassName();
        JavaClass receiverClass = analysisContext.lookupClass(receiverClassName);
        ClassDescriptor receiverDesc = DescriptorFactory.createClassDescriptorFromDottedClassName(receiverClassName);

        // Figure out the upper bound for the method.
        // This is what will be called if this is not a virtual call site.
        JavaClassAndMethod upperBound = findMethod(receiverClass, methodName, methodSig, CONCRETE_METHOD);
View Full Code Here

     * @param fieldName
     *            the name of the field
     * @return the Field, or null if no such field could be found
     */
    public static Field findField(String className, String fieldName) throws ClassNotFoundException {
        JavaClass jclass = Repository.lookupClass(className);

        while (jclass != null) {
            Field[] fieldList = jclass.getFields();
            for (Field field : fieldList) {
                if (field.getName().equals(fieldName)) {
                    return field;
                }
            }

            jclass = jclass.getSuperClass();
        }

        return null;
    }
View Full Code Here


    private boolean embeddedNameMismatch(ZipFile zipInputFile, ZipEntry ze) throws IOException {
        InputStream zipIn = zipInputFile.getInputStream(ze);
        String name = ze.getName();
        JavaClass j = new ClassParser(zipIn, name).parse();
        zipIn.close();
        String className = j.getClassName();
        String computedFileName = ClassName.toSlashedClassName(className)+".class";
        if (name.charAt(0) == '1') {
            System.out.println(name);
            System.out.println("  " + className);
        }
View Full Code Here

        String refName = getComponentClass(refSig);
        if (refName.equals("java.lang.Object")) {
            return 0.99;
        }

        JavaClass refJavaClass = Repository.lookupClass(refName);
        return isDeepSerializable(refJavaClass);
    }
View Full Code Here

TOP

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

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.