Buggy code:
public class HandleFactory { private String lastPkgFragmentRootPath ; private IPackageFragmentRoot lastPkgFragmentRoot ; private HashtableOfArrayToObject packageHandles ; private JavaModel javaModel ; public HandleFactory ( ) { } public Openable createOpenable ( String resourcePath , IJavaSearchScope scope ) { } public IJavaElement createElement ( final ASTNode toBeFound , CompilationUnitDeclaration parsedUnit , Openable openable ) { class EndVisit extends RuntimeException { private static final long serialVersionUID = 7264372508108115988L ; } class Visitor extends ASTVisitor { ASTNode [ ] nodeStack = new ASTNode [ 10 ] ; int nodeIndex = - 1 ; public void push ( ASTNode node ) { if ( ( ++ ( this . nodeIndex ) ) >= ( this . nodeStack . length ) ) <START_BUG> System . arraycopy ( this . nodeStack , 0 , ( this . nodeStack = new ASTNode [ ( this . nodeStack . length ) * 2 ] ) , 0 , ( ( this . nodeIndex ) - 1 ) ) ; <END_BUG> this . nodeStack [ this . nodeIndex ] = node ; } public void pop ( ASTNode node ) { while ( ( ( this . nodeIndex ) >= 0 ) && ( ( this . nodeStack [ ( ( this . nodeIndex ) -- ) ] ) != node ) ) { } } public boolean visit ( Argument node , BlockScope scope ) { push ( node ) ; if ( node == toBeFound ) throw new EndVisit ( ) ; return true ; } public void endVisit ( Argument node , BlockScope scope ) { pop ( node ) ; } public boolean visit ( ConstructorDeclaration node , ClassScope scope ) { push ( node ) ; if ( node == toBeFound ) throw new EndVisit ( ) ; return true ; } public void endVisit ( ConstructorDeclaration node , ClassScope scope ) { pop ( node ) ; } public boolean visit ( FieldDeclaration node , MethodScope scope ) { push ( node ) ; if ( node == toBeFound ) throw new EndVisit ( ) ; return true ; } public void endVisit ( FieldDeclaration node , MethodScope scope ) { pop ( node ) ; } public boolean visit ( Initializer node , MethodScope scope ) { push ( node ) ; if ( node == toBeFound ) throw new EndVisit ( ) ; return true ; } public boolean visit ( LocalDeclaration node , BlockScope scope ) { push ( node ) ; if ( node == toBeFound ) throw new EndVisit ( ) ; return true ; } public void endVisit ( LocalDeclaration node , BlockScope scope ) { pop ( node ) ; } public boolean visit ( TypeDeclaration node , BlockScope scope ) { push ( node ) ; if ( node == toBeFound ) throw new EndVisit ( ) ; return true ; } public void endVisit ( TypeDeclaration node , BlockScope scope ) { if ( ( ( node . bits ) & ( IsMemberTypeMASK ) ) != 0 ) { pop ( node ) ; } } public boolean visit ( TypeDeclaration node , ClassScope scope ) { push ( node ) ; if ( node == toBeFound ) throw new EndVisit ( ) ; return true ; } public void endVisit ( TypeDeclaration node , ClassScope scope ) { if ( ( ( node . bits ) & ( IsMemberTypeMASK ) ) != 0 ) { pop ( node ) ; } } public boolean visit ( MethodDeclaration node , ClassScope scope ) { push ( node ) ; if ( node == toBeFound ) throw new EndVisit ( ) ; return true ; } public void endVisit ( MethodDeclaration node , ClassScope scope ) { pop ( node ) ; } public boolean visit ( TypeDeclaration node , CompilationUnitScope scope ) { push ( node ) ; if ( node == toBeFound ) throw new EndVisit ( ) ; return true ; } public void endVisit ( TypeDeclaration node , CompilationUnitScope scope ) { pop ( node ) ; } } Visitor visitor = new Visitor ( ) ; try { parsedUnit . traverse ( visitor , parsedUnit . scope ) ; } catch ( EndVisit e ) { ASTNode [ ] nodeStack = visitor . nodeStack ; int end = visitor . nodeIndex ; int start = 0 ; ASTNode typeDecl = null ; if ( openable instanceof ClassFile ) { for ( int i = end ; i >= 0 ; i -- ) { if ( ( nodeStack [ i ] ) instanceof TypeDeclaration ) { typeDecl = nodeStack [ i ] ; start = i ; break ; } } } if ( typeDecl != null ) { openable = getOpenable ( typeDecl , openable ) ; } return createElement ( nodeStack , start , end , openable ) ; } return null ; } private IJavaElement createElement ( ASTNode [ ] nodeStack , int start , int end , IJavaElement parent ) { } public IJavaElement createElement ( ClassScope scope , ICompilationUnit unit , HashSet existingElements , HashMap knownScopes ) { } private IJavaElement createElement ( Scope scope , int elementPosition , ICompilationUnit unit , HashSet existingElements , HashMap knownScopes ) { } private IPackageFragmentRoot getJarPkgFragmentRoot ( String jarPathString , IJavaSearchScope scope ) { } private IPackageFragmentRoot getJarPkgFragmentRoot ( IPath jarPath , Object target , IJavaProject [ ] projects ) { } private Openable getOpenable ( ASTNode toBeFound , Openable openable ) { } private IPackageFragmentRoot getPkgFragmentRoot ( String pathString ) { } }

Fix:
System . arraycopy ( this . nodeStack , 0 , ( this . nodeStack = new ASTNode [ ( this . nodeStack . length ) * 2 ] ) , 0 , this . nodeIndex ) ;