Bug 304023 - Unnecessary ArrayIndexOutOfBoundsException caught when index is illegal
Summary: Unnecessary ArrayIndexOutOfBoundsException caught when index is illegal
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Runtime (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-26 08:02 EST by Tudor Malene CLA
Modified: 2010-02-26 08:04 EST (History)
0 users

See Also:


Attachments
Test class which calls 2 versions of the peek method and compares results (1.48 KB, application/octet-stream)
2010-02-26 08:04 EST, Tudor Malene CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tudor Malene CLA 2010-02-26 08:02:08 EST
Build Identifier: 1.6.8

In BasicTokenSource, the methods next and peek catch an ArrayIndexOutOfBoundsException, when the index is not in range, and return IToken.EOF in the catch clause, thus everytime any of these methods are called with an illegal index, an unnecessary exception is created and handled. 
It would be much more efficient to manually check the range and return IToken.EOF if not legal, avoiding the unnecessary exception handling .

Reproducible: Always
Comment 1 Tudor Malene CLA 2010-02-26 08:04:01 EST
Created attachment 160293 [details]
Test class which calls 2 versions of the peek method and compares results