@ Override public void sawOpcode ( int seen ) { switch ( state ) { case COLLECT : if ( ( seen == Const . INVOKESTATIC ) || ( seen == Const . INVOKEVIRTUAL ) || ( seen == Const . INVOKEINTERFACE ) || ( seen == Const . INVOKESPECIAL ) ) { refClasses . add ( getClassConstantOperand ( ) ) ; String signature = getSigConstantOperand ( ) ; Type [ ] argTypes = Type . getArgumentTypes ( signature ) ; for ( Type t : argTypes ) { addType ( t ) ; } Type resultType = Type . getReturnType ( signature ) ; addType ( resultType ) ; } break ; case SEEN_NOTHING : if ( ( seen == Const . LDC ) || ( seen == Const . LDC_W ) ) { Constant c = getConstantRefOperand ( ) ; if ( c instanceof ConstantString ) { clsName = ( ( ConstantString ) c ) . getBytes ( getConstantPool ( ) ) ; state = State . SEEN_LDC ; } } break ; case SEEN_LDC : if ( ( seen == Const . INVOKESTATIC ) && "forName" . equals ( getNameConstantOperand ( ) ) && "java/lang/Class" . equals ( getClassConstantOperand ( ) ) && refClasses . contains ( clsName ) ) { bugReporter . reportBug ( new BugInstance ( this , BugType . SCR_SLOPPY_CLASS_REFLECTION . name ( ) , NORMAL_PRIORITY ) . addClass ( this ) . addMethod ( this ) . addSourceLine ( this ) ) ; } state = State . SEEN_NOTHING ; break ; } }
overrides the visitor to find class loading that is non obfuscation proof