@ Override public void visitCode ( final Code obj ) { if ( sourceLines == null ) { return ; } if ( isAbstract ) { return ; } if ( Values . STATIC_INITIALIZER . equals ( methodName ) || Values . CONSTRUCTOR . equals ( methodName ) ) { return ; } int methodStart = srcLineAnnotation . getStartLine ( ) - 2 ; int methodLine = methodStart ; String line ; while ( ( methodLine >= 0 ) && ( methodLine < sourceLines . length ) ) { line = sourceLines [ methodLine ] ; if ( line . indexOf ( methodName ) >= 0 ) { break ; } methodLine -- ; } if ( methodLine < 0 ) { return ; } for ( int i = methodLine ; i <= methodStart ; i ++ ) { if ( ( i < 0 ) || ( i >= sourceLines . length ) ) { return ; } line = sourceLines [ i ] ; if ( line . indexOf ( "final" ) >= 0 ) { return ; } } changedParms = new BitSet ( ) ; super . visitCode ( obj ) ; BugInstance bi = null ; for ( int i = 0 ; i < firstLocalReg ; i ++ ) { if ( changedParms . get ( i ) ) { changedParms . clear ( i ) ; continue ; } String parmName = getRegisterName ( obj , i ) ; if ( bi == null ) { bi = new BugInstance ( this , BugType . FP_FINAL_PARAMETERS . name ( ) , LOW_PRIORITY ) . addClass ( this ) . addMethod ( this ) . addSourceLine ( this , 0 ) ; bugReporter . reportBug ( bi ) ; } bi . addString ( parmName ) ; } changedParms = null ; }
overrides the visitor to find the source lines for the method header to find non final parameters