Hi All,
Please review a fix for jdk9
Bug: https://bugs.openjdk.java.net/browse/JDK-7160052
webrev: http://cr.openjdk.java.net/~psadhukhan/7160052/webrev.00/
Issue:
GlyphVector.setGlyphPosition(int glyphIndex, Point2D
<cid:part1.01090803.05010309@oracle.com> newPos) can have glyphIndex
"equal" to the number of glyphs in this GlyphVector
so if user tries to call GlyphVector.setGlyphPosition(gv.getNumGlyphs(),
gv.getGlyphPosition(gv.getNumGlyphs()) it throws IndexOutOfBoundsException
Cause:
StandardGlyphVector maintains a glyph cache for the glyphs stored in the
GlyphVector via lbcache = new Shape[glyphs.length];
When GlyphVector.setGlyphPosition() is called, it positions the glyph at
the specified glyphIndex|||||||||| and tries to clear the mentioned
glyphIndex position of cache by calling clearCache(glyphIndex)
But, if we pass the glyphIndex == number of glyphs, then it tries to
access beyond the cache array resulting in IOB.
Fix:
Checked if glyphIndex passed as argument is equal to number of glyphs
then do not try to clear the cache as setGlyphPosition() will anyway
sets the position after the last glyph.
Also, added this check as per spec|IndexOutOfBoundsException
<cid:part2.03060502.08060102@oracle.com>| - if |glyphIndex| is less than
0 or greater than the number of glyphs in this |GlyphVector
|
Regards
Prasanta
||||