Buggy code:
public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscoverer { private static final String ANNOTATION_CLASS_NAME = "java.lang.annotation.Annotation" ; private static final String THIS_JOIN_POINT = "thisJoinPoint" ; private static final String THIS_JOIN_POINT_STATIC_PART = "thisJoinPointStaticPart" ; private static final int STEP_JOIN_POINT_BINDING = 1 ; private static final int STEP_THROWING_BINDING = 2 ; private static final int STEP_ANNOTATION_BINDING = 3 ; private static final int STEP_RETURNING_BINDING = 4 ; private static final int STEP_PRIMITIVE_ARGS_BINDING = 5 ; private static final int STEP_THIS_TARGET_ARGS_BINDING = 6 ; private static final int STEP_REFERENCE_PCUT_BINDING = 7 ; private static final int STEP_FINISHED = 8 ; private static final Set singleValuedAnnotationPcds = new HashSet ( ) ; private static final Set nonReferencePointcutTokens = new HashSet ( ) ; private static Class annotationClass ; private boolean raiseExceptions ; private String returningName ; private String throwingName ; private String pointcutExpression ; private Class [ ] argumentTypes ; private String [ ] parameterNameBindings ; private int numberOfRemainingUnboundArguments ; private int algorithmicStep = AspectJAdviceParameterNameDiscoverer . STEP_JOIN_POINT_BINDING ; public AspectJAdviceParameterNameDiscoverer ( String pointcutExpression ) { } public void setRaiseExceptions ( boolean raiseExceptions ) { } public void setReturningName ( String returningName ) { } public void setThrowingName ( String throwingName ) { } public String [ ] getParameterNames ( Method method ) { } public String [ ] getParameterNames ( Constructor ctor ) { } private void bindParameterName ( int index , String name ) { } private boolean maybeBindThisJoinPoint ( ) { } private void maybeBindThisJoinPointStaticPart ( ) { } private void maybeBindThrowingVariable ( ) { } private void maybeBindReturningVariable ( ) { } private void maybeBindAnnotationsFromPointcutExpression ( ) { } private void bindAnnotationsFromVarNames ( List varNames ) { } private String maybeExtractVariableName ( String candidateToken ) { } private void maybeExtractVariableNamesFromArgs ( String argsSpec , List varNames ) { } private void maybeBindThisOrTargetOrArgsFromPointcutExpression ( ) { } private void maybeBindReferencePointcutParameter ( ) { } private AspectJAdviceParameterNameDiscoverer . PointcutBody getPointcutBody ( String [ ] tokens , int startIndex ) { int numTokensConsumed = 0 ; String currentToken = tokens [ startIndex ] ; int bodyStart = currentToken . indexOf ( '(' ) ; if ( ( currentToken . charAt ( ( ( currentToken . length ( ) ) - 1 ) ) ) == ')' ) { return new AspectJAdviceParameterNameDiscoverer . PointcutBody ( 0 , currentToken . substring ( ( bodyStart + 1 ) , ( ( currentToken . length ( ) ) - 1 ) ) ) ; } else { <START_BUG> StringBuffer sb = new StringBuffer ( ) ; <END_BUG> if ( ( bodyStart >= 0 ) && ( bodyStart != ( ( currentToken . length ( ) ) - 1 ) ) ) { sb . append ( currentToken . substring ( ( bodyStart + 1 ) ) ) ; sb . append ( "<seq2seq4repair_space>" ) ; } numTokensConsumed ++ ; int currentIndex = startIndex + numTokensConsumed ; while ( currentIndex < ( tokens . length ) ) { if ( tokens [ currentIndex ] . equals ( "(" ) ) { currentIndex ++ ; continue ; } if ( tokens [ currentIndex ] . endsWith ( ")" ) ) { sb . append ( tokens [ currentIndex ] . substring ( 0 , ( ( tokens [ currentIndex ] . length ( ) ) - 1 ) ) ) ; return new AspectJAdviceParameterNameDiscoverer . PointcutBody ( numTokensConsumed , sb . toString ( ) . trim ( ) ) ; } String toAppend = tokens [ currentIndex ] ; if ( toAppend . startsWith ( "(" ) ) { toAppend = toAppend . substring ( 1 ) ; } sb . append ( toAppend ) ; sb . append ( "<seq2seq4repair_space>" ) ; currentIndex ++ ; numTokensConsumed ++ ; } } return new AspectJAdviceParameterNameDiscoverer . PointcutBody ( numTokensConsumed , null ) ; } private void maybeBindPrimitiveArgsFromPointcutExpression ( ) { } private boolean isUnbound ( int i ) { } private boolean alreadyBound ( String varName ) { } private boolean isSubtypeOf ( Class supertype , int argumentNumber ) { } private int countNumberOfUnboundAnnotationArguments ( ) { } private int countNumberOfUnboundPrimitiveArguments ( ) { } private void findAndBind ( Class argumentType , String varName ) { } private static class PointcutBody { private int numTokensConsumed ; private String text ; public PointcutBody ( int tokens , String text ) { } } public static class AmbiguousBindingException extends RuntimeException { public AmbiguousBindingException ( String msg ) { } } }

Fix:
StringBuilder sb = new StringBuilder ( ) ;