@Override
    public void visitClassContext(ClassContext classContext) {
        JavaClass jclass = classContext.getJavaClass();

        // Check to see if the class references any other classes
        // which could be resources we want to track.
        // If we don't find any such classes, we skip analyzing
        // the class. (Note: could do this by method.)
        boolean sawResourceClass = false;
        for (int i = 0; i < jclass.getConstantPool().getLength(); ++i) {
            Constant constant = jclass.getConstantPool().getConstant(i);
            String className = null;
            if (constant instanceof ConstantMethodref) {
                ConstantMethodref cmr = (ConstantMethodref) constant;

                int classIndex = cmr.getClassIndex();
                className = jclass.getConstantPool().getConstantString(classIndex, Const.CONSTANT_Class);
            } else if (constant instanceof ConstantInterfaceMethodref) {
                ConstantInterfaceMethodref cmr = (ConstantInterfaceMethodref) constant;

                int classIndex = cmr.getClassIndex();
                className = jclass.getConstantPool().getConstantString(classIndex, Const.CONSTANT_Class);
            }

            if (className != null) {
                if (DEBUG) {
                    System.out.println("FindOpenStream: saw class " + className);
                }

                for (String aPRESCREEN_CLASS_LIST : PRESCREEN_CLASS_LIST) {
                    if (className.indexOf(aPRESCREEN_CLASS_LIST) >= 0) {
                        sawResourceClass = true;
                        break;
                    }
                }
            }

        }

        if (sawResourceClass) {
            super.visitClassContext(classContext);
        }
    }
@ Override public void visitClassContext ( ClassContext classContext ) { JavaClass jclass = classContext . getJavaClass ( ) ; boolean sawResourceClass = false ; for ( int i = 0 ; i < jclass . getConstantPool ( ) . getLength ( ) ; ++ i ) { Constant constant = jclass . getConstantPool ( ) . getConstant ( i ) ; String className = null ; if ( constant instanceof ConstantMethodref ) { ConstantMethodref cmr = ( ConstantMethodref ) constant ; int classIndex = cmr . getClassIndex ( ) ; className = jclass . getConstantPool ( ) . getConstantString ( classIndex , Const . CONSTANT_Class ) ; } else if ( constant instanceof ConstantInterfaceMethodref ) { ConstantInterfaceMethodref cmr = ( ConstantInterfaceMethodref ) constant ; int classIndex = cmr . getClassIndex ( ) ; className = jclass . getConstantPool ( ) . getConstantString ( classIndex , Const . CONSTANT_Class ) ; } if ( className != null ) { if ( DEBUG ) { System . out . println ( "FindOpenStream: saw class " + className ) ; } for ( String aPRESCREEN_CLASS_LIST : PRESCREEN_CLASS_LIST ) { if ( className . indexOf ( aPRESCREEN_CLASS_LIST ) >= 0 ) { sawResourceClass = true ; break ; } } } } if ( sawResourceClass ) { super . visitClassContext ( classContext ) ; } }
/*
(non-Javadoc)

@see
edu.umd.cs.findbugs.Detector#visitClassContext(edu.umd.cs.findbugs.ba
.ClassContext)