Buggy code:
class DefaultCommentMapper { Comment [ ] comments ; HashMap leadingComments ; HashMap trailingComments ; Scanner scanner ; DefaultCommentMapper ( Comment [ ] table ) { } boolean hasSameTable ( Comment [ ] table ) { } Comment getComment ( int position ) { } private int getCommentIndex ( int start , int position , int exact ) { } Comment [ ] getLeadingComments ( ASTNode node ) { } Comment [ ] getTrailingComments ( ASTNode node ) { } public int getExtendedStartPosition ( ASTNode node ) { } public int getExtendedEnd ( ASTNode node ) { } public int getExtendedLength ( ASTNode node ) { } void initialize ( CompilationUnit unit , Scanner sc ) { } int storeLeadingComments ( ASTNode node , int previousEnd ) { int nodeStart = node . getStartPosition ( ) ; int extended = nodeStart ; int previousEndLine = this . scanner . getLineNumber ( previousEnd ) ; int nodeStartLine = this . scanner . getLineNumber ( nodeStart ) ; int idx = getCommentIndex ( 0 , nodeStart , ( - 1 ) ) ; if ( idx == ( - 1 ) ) { return nodeStart ; } int startIdx = - 1 ; int endIdx = idx ; int previousStart = nodeStart ; while ( ( idx >= 0 ) && ( previousStart >= previousEnd ) ) { Comment comment = this . comments [ idx ] ; int commentStart = comment . getStartPosition ( ) ; int end = ( commentStart + ( comment . getLength ( ) ) ) - 1 ; int commentLine = this . scanner . getLineNumber ( commentStart ) ; if ( ( end <= previousEnd ) || ( ( commentLine == previousEndLine ) && ( commentLine != nodeStartLine ) ) ) { break ; } else if ( ( end + 1 ) < previousStart ) { this . scanner . resetTo ( ( end + 1 ) , previousStart ) ; try { int token = this . scanner . getNextToken ( ) ; if ( ( token != ( TerminalTokens . TokenNameWHITESPACE ) ) || ( ( this . scanner . currentPosition ) != previousStart ) ) { if ( idx == endIdx ) { return nodeStart ; } break ; } } catch ( InvalidInputException e ) { return nodeStart ; } char [ ] gap = this . scanner . getCurrentIdentifierSource ( ) ; int nbrLine = 0 ; int pos = - 1 ; while ( ( pos = CharOperation . indexOf ( '\n' , gap , ( pos + 1 ) ) ) >= 0 ) { nbrLine ++ ; } if ( nbrLine > 1 ) { break ; } } previousStart = commentStart ; startIdx = idx -- ; } if ( startIdx != ( - 1 ) ) { int commentStart = this . comments [ startIdx ] . getStartPosition ( ) ; if ( ( previousEnd < commentStart ) && ( previousEndLine != nodeStartLine ) ) { int lastTokenEnd = previousEnd ; this . scanner . resetTo ( previousEnd , commentStart ) ; try { <START_BUG> while ( ( this . scanner . currentPosition ) != commentStart ) { <END_BUG> if ( ( this . scanner . getNextToken ( ) ) != ( TerminalTokens . TokenNameWHITESPACE ) ) { lastTokenEnd = this . scanner . getCurrentTokenEndPosition ( ) ; } } } catch ( InvalidInputException e ) { } int lastTokenLine = this . scanner . getLineNumber ( lastTokenEnd ) ; int length = this . comments . length ; while ( ( ( startIdx < length ) && ( lastTokenLine == ( this . scanner . getLineNumber ( this . comments [ startIdx ] . getStartPosition ( ) ) ) ) ) && ( nodeStartLine != lastTokenLine ) ) { startIdx ++ ; } } if ( startIdx <= endIdx ) { this . leadingComments . put ( node , new int [ ] { startIdx , endIdx } ) ; extended = this . comments [ endIdx ] . getStartPosition ( ) ; } } return extended ; } int storeTrailingComments ( ASTNode node , int nextStart , boolean lastChild ) { } class CommentMapperVisitor extends DefaultASTVisitor { HashMap waitingSiblings = new HashMap ( 10 ) ; protected boolean visitNode ( ASTNode node ) { } protected void endVisitNode ( ASTNode node ) { } public boolean visit ( CompilationUnit node ) { } } }

Fix:
while ( ( this . scanner . currentPosition ) < commentStart ) {