Package edu.umd.cs.findbugs.classfile

Examples of edu.umd.cs.findbugs.classfile.ClassDescriptor


    public ClassContext getClassContext(JavaClass javaClass) {
        // This is a bit silly since we're doing an unnecessary
        // ClassDescriptor->JavaClass lookup.
        // However, we can be assured that it will succeed.

        ClassDescriptor classDescriptor = DescriptorFactory.instance().getClassDescriptor(
                ClassName.toSlashedClassName(javaClass.getClassName()));

        try {
            return Global.getAnalysisCache().getClassAnalysis(ClassContext.class, classDescriptor);
        } catch (CheckedAnalysisException e) {
View Full Code Here


            OpcodeStack.Item top = stack.getStackItem(0);
            String signature = top.getSignature();
            while (signature.charAt(0) == '[') {
                signature = signature.substring(1);
            }
            ClassDescriptor c = DescriptorFactory.createClassDescriptorFromFieldSignature(signature);
            if (c == null || !Subtypes2.instanceOf(c, Serializable.class)) {
                return;
            }

            try {
                XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, c);
                if (xClass.isInterface()) {
                    return;
                }
                if (xClass.isSynthetic()) {
                    return;
                }
                if (xClass.isAbstract()) {
                    return;
                }
                unreadFields.strongEvidenceForIntendedSerialization(c);
            } catch (CheckedAnalysisException e) {
                bugReporter.logError("Error looking up xClass of " + c, e);
            }

        }
        if (seen == CHECKCAST) {
            OpcodeStack.Item top = stack.getStackItem(0);
            if (readObject.equals(top.getReturnValueOf())) {
                ClassDescriptor c = getClassDescriptorOperand();
                if (!Subtypes2.instanceOf(c, Serializable.class)) {
                    return;
                }

                try {
View Full Code Here

                }
                XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, desc.getClassDescriptor());
                if (xClass == null) {
                    break;
                }
                ClassDescriptor superClass = xClass.getSuperclassDescriptor();
                if (superClass == null) {
                    break;
                }
                desc = DescriptorFactory.instance().getMethodDescriptor(superClass.getClassName(), desc.getName(),
                        desc.getSignature(), desc.isStatic());
            }
        } catch (CheckedAnalysisException e) {
            assert true;
        } catch (RuntimeException e) {
View Full Code Here

    }

    private XField resolveXField(FieldDescriptor originalDescriptor) {
        FieldDescriptor desc = originalDescriptor;
        LinkedList<ClassDescriptor> worklist = new LinkedList<ClassDescriptor>();
        ClassDescriptor originalClassDescriptor = desc.getClassDescriptor();
        worklist.add(originalClassDescriptor);
        try {
            while (!worklist.isEmpty()) {
                ClassDescriptor d = worklist.removeFirst();
                if (!d.equals(originalClassDescriptor)) {
                    desc = DescriptorFactory.instance().getFieldDescriptor(d.getClassName(), desc.getName(), desc.getSignature(),
                            desc.isStatic());
                }

                XField f = fields.get(desc);
                if (f != null) {
                    return f;
                }
                XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, d);
                if (xClass == null) {
                    break;
                }
                ClassDescriptor superClass = xClass.getSuperclassDescriptor();
                if (superClass != null) {
                    worklist.add(superClass);
                }
                if (originalDescriptor.isStatic()) {
                    for (ClassDescriptor i : xClass.getInterfaceDescriptorList()) {
View Full Code Here

                if (className.equals("java/util/Calendar") || className.equals("java/text/DateFormat")) {
                    sawDateClass = true;
                    break;
                }
                try {
                    ClassDescriptor cDesc = DescriptorFactory.createClassDescriptor(className);

                    if (subtypes2.isSubtype(cDesc, calendarType) || subtypes2.isSubtype(cDesc, dateFormatType)) {
                        sawDateClass = true;
                        break;
                    }
View Full Code Here

            return;
        }
        if (!aField.isPublic() && !aField.isProtected()) {
            return;
        }
        ClassDescriptor classOfField = DescriptorFactory.createClassDescriptorFromFieldSignature(aField.getSignature());
        String tBugType = null;
        int priority = aField.isPublic() && aField.isFinal() && aField.getName().equals(aField.getName().toUpperCase())
                && getThisClass().isPublic() ? HIGH_PRIORITY : NORMAL_PRIORITY;
        if (classOfField != null) {
            try {
View Full Code Here

            if (className.startsWith("[")) {
                // Ignore array classes
                return;
            }
            ClassDescriptor cDesc = DescriptorFactory.createClassDescriptor(className);

            // if it is not compatible with Calendar or DateFormat, we are not
            // interested anymore
            boolean isCalendar = subtypes2.isSubtype(cDesc, calendarType);
            boolean isDateFormat = subtypes2.isSubtype(cDesc, dateFormatType);
View Full Code Here

                if (value instanceof String) {
                    String annotationClassName = (String) value;
                    boolean lacksClassfileRetention = AnalysisContext.currentAnalysisContext().getAnnotationRetentionDatabase()
                            .lacksRuntimeRetention(annotationClassName.replace('/', '.'));
                    if (lacksClassfileRetention) {
                        ClassDescriptor annotationClass = DescriptorFactory.createClassDescriptor(annotationClassName);
                        accumulator.accumulateBug(
                                new BugInstance(this, "DMI_ANNOTATION_IS_NOT_VISIBLE_TO_REFLECTION", HIGH_PRIORITY)
                                .addClassAndMethod(this).addCalledMethod(this).addClass(annotationClass)
                                .describe(ClassAnnotation.ANNOTATION_ROLE), this);
                    }
View Full Code Here

    @Override
    public void parse(final ClassNameAndSuperclassInfo.Builder builder) throws InvalidClassFileFormatException {

        builder.setCodeBaseEntry(codeBaseEntry);
        builder.setAccessFlags(javaClass.getAccessFlags());
        ClassDescriptor classDescriptor = DescriptorFactory.createClassDescriptorFromDottedClassName(javaClass.getClassName());
        if (expectedClassDescriptor != null && expectedClassDescriptor.equals(classDescriptor)) {
            throw new InvalidClassFileFormatException("Expected " + expectedClassDescriptor, classDescriptor, codeBaseEntry);
        }
        builder.setClassDescriptor(classDescriptor);
View Full Code Here

            }

            int access_flags = in.readUnsignedShort();

            int this_class = in.readUnsignedShort();
            ClassDescriptor thisClassDescriptor = getClassDescriptor(this_class);

            int super_class = in.readUnsignedShort();
            ClassDescriptor superClassDescriptor = getClassDescriptor(super_class);

            int interfaces_count = in.readUnsignedShort();
            if (interfaces_count < 0) {
                throw new InvalidClassFileFormatException(expectedClassDescriptor, codeBaseEntry);
            }
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.classfile.ClassDescriptor

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.