Buggy code:
@ CustomUserValue public class PossiblyRedundantMethodCalls extends BytecodeScanningDetector { public static final String PRMC_RISKY_FIELD_USER_KEY = "fbcontrib.PRMC.riskynames" ; public static final String PRMC_RISKY_CLASS_USER_KEY = "fbcontrib.PRMC.riskyclasses" ; public static final String PRMC_HIGH_BYTECOUNT = "fbcontrib.PRMC.highbytecount" ; public static final String PRMC_HIGH_METHODCALLS = "fbcontrib.PRMC.highmethodcalls" ; public static final String PRMC_NORMAL_BYTECOUNT = "fbcontrib.PRMC.normalbytecount" ; public static final String PRMC_NORMAL_METHODCALLS = "fbcontrib.PRMC.normalmethodcalls" ; private static Set < String > riskyMethodNameContents = new HashSet < String > ( ) ; private static int highByteCountLimit = 200 ; private static int highMethodCallLimit = 10 ; private static int normalByteCountLimit = 50 ; private static int normalMethodCallLimit = 4 ; private static Set < String > riskyClassNames = new HashSet < String > ( ) ; private final BugReporter bugReporter ; private OpcodeStack stack = null ; private Map < Integer , PossiblyRedundantMethodCalls . MethodCall > localMethodCalls = null ; private Map < String , PossiblyRedundantMethodCalls . MethodCall > fieldMethodCalls = null ; private Map < String , PossiblyRedundantMethodCalls . MethodCall > staticMethodCalls = null ; private BitSet branchTargets = null ; public PossiblyRedundantMethodCalls ( BugReporter bugReporter ) { } @ Override public void visitClassContext ( ClassContext classContext ) { } @ Override public void visitCode ( Code obj ) { } @ Override public void sawOpcode ( int seen ) { String userValue = null ; try { stack . precomputation ( this ) ; int pc = getPC ( ) ; if ( branchTargets . get ( pc ) ) { localMethodCalls . clear ( ) ; fieldMethodCalls . clear ( ) ; branchTargets . clear ( pc ) ; } if ( ( ( seen >= ( IFEQ ) ) && ( seen <= ( GOTO ) ) ) || ( ( seen >= ( IFNULL ) ) && ( seen <= ( GOTO_W ) ) ) ) { branchTargets . set ( getBranchTarget ( ) ) ; } else if ( ( seen == ( TABLESWITCH ) ) || ( seen == ( LOOKUPSWITCH ) ) ) { int [ ] offsets = getSwitchOffsets ( ) ; for ( int offset : offsets ) { branchTargets . set ( ( offset + pc ) ) ; } } else if ( ( seen == ( ASTORE ) ) || ( ( seen >= ( ASTORE_0 ) ) && ( seen <= ( ASTORE_3 ) ) ) ) { localMethodCalls . remove ( Integer . valueOf ( RegisterUtils . getAStoreReg ( this , seen ) ) ) ; } else if ( seen == ( PUTFIELD ) ) { String fieldSource = "" ; if ( ( stack . getStackDepth ( ) ) > 0 ) { OpcodeStack . Item item = stack . getStackItem ( 0 ) ; fieldSource = ( ( String ) ( item . getUserValue ( ) ) ) ; if ( fieldSource == null ) fieldSource = "" ; } fieldMethodCalls . remove ( ( ( fieldSource + ":" ) + ( getNameConstantOperand ( ) ) ) ) ; } else if ( seen == ( GETFIELD ) ) { if ( ( stack . getStackDepth ( ) ) > 0 ) { OpcodeStack . Item item = stack . getStackItem ( 0 ) ; userValue = ( ( String ) ( item . getUserValue ( ) ) ) ; if ( userValue == null ) { int reg = item . getRegisterNumber ( ) ; if ( reg >= 0 ) { userValue = String . valueOf ( reg ) ; } else { XField xf = item . getXField ( ) ; if ( xf != null ) { userValue = xf . getName ( ) ; } } } } } else if ( ( ( seen == ( INVOKEVIRTUAL ) ) || ( seen == ( INVOKEINTERFACE ) ) ) || ( seen == ( INVOKESTATIC ) ) ) { String signature = getSigConstantOperand ( ) ; int parmCount = Type . getArgumentTypes ( signature ) . length ; <START_BUG> int neededStackSize = parmCount - ( seen == ( INVOKESTATIC ) ? 1 : 0 ) ; <END_BUG> if ( ( stack . getStackDepth ( ) ) > neededStackSize ) { Object [ ] parmConstants = new Object [ parmCount ] ; for ( int i = 0 ; i < parmCount ; i ++ ) { OpcodeStack . Item parm = stack . getStackItem ( i ) ; parmConstants [ i ] = parm . getConstant ( ) ; if ( ( parmConstants [ i ] ) == null ) { return ; } } String className = getClassConstantOperand ( ) ; PossiblyRedundantMethodCalls . MethodCall mc ; int reg = - 1 ; XField field = null ; if ( seen == ( INVOKESTATIC ) ) { mc = staticMethodCalls . get ( className ) ; } else { OpcodeStack . Item obj = stack . getStackItem ( parmCount ) ; reg = obj . getRegisterNumber ( ) ; field = obj . getXField ( ) ; if ( reg >= 0 ) { mc = localMethodCalls . get ( Integer . valueOf ( reg ) ) ; } else if ( field != null ) { String fieldSource = ( ( String ) ( obj . getUserValue ( ) ) ) ; if ( fieldSource == null ) fieldSource = "" ; mc = fieldMethodCalls . get ( ( ( fieldSource + ":" ) + ( field . getName ( ) ) ) ) ; } else { return ; } } String methodName = getNameConstantOperand ( ) ; if ( mc != null ) { if ( ( ( ( ! ( signature . endsWith ( "V" ) ) ) && ( methodName . equals ( mc . getName ( ) ) ) ) && ( signature . equals ( mc . getSignature ( ) ) ) ) && ( ! ( PossiblyRedundantMethodCalls . isRiskyName ( className , methodName ) ) ) ) { Object [ ] parms = mc . getParms ( ) ;

Fix:
int neededStackSize = parmCount - ( seen == ( INVOKESTATIC ) ? 0 : 1 ) ;