Hello Everyone Good day to you.
Request your time in reviewing the fix for the bug: JDK-5064835 TextMeasurer/deleteChar function fails when deleting more than one characters. Root Cause: . The spec clearly mentions that the concerned method is to be used to delete a single character. . However, the spec does not mention the outcome when the method is used to delete multiple characters (as reported in the bug) Solution Approaches: . Since the spec does not mention the outcome when multiple characters are deleted, the result is left to the implementation. . The solution can be approached in two perspectives- 1. Update the spec to explicitly mention the exception that would be thrown in such cases or 2. Re-initialize the TextMeasurer with the new text as present in the argument of the method. Solution: . I inspected feasibility/ risk of both the approaches and I 'm of the opinion that approach 1. is better. . Reason is that, with the second approach- . The re-initialization would reset all text attributes, and state variabes that were set on TextMeasurer (and internal StyledParagraph) object. . If re-initialization is required, one could create a new TextMeasurer using the modified text rather than invoking deleteChar method. . Thus in the proposed solution- I 've added a throws clause that explicitly mentions that IllegalArgumentException will be thrown when attempted to delete multiple characters. Other Info: . The fix was tested with existing jtreg test cases- No regressions were seen. . 2 JCK tests have been found to fail. They are- . java_awt/Font/TextMeasurer/CharTest (TestCase5) . java_awt/Font/LineBreakMeasurer/CharTest (TestCase4) . In both the failures, incorrect arguments are passed to deleteChar method- newParagraph (with multiple chars deleted) & beginIndex (-1) . While the test case expects index out of bounds exception for -ve index, the code now throws IllegalArgumentsException. . A minor correction to JCK test will fix the issue. I shall raise a JCK bug once the fix is approved & submitted. Kindly review the changes at your convenience & share your feedback: http://cr.openjdk.java.net/~pnarayanan/5064835/webrev.00/ Note: I 've not raised a CSR for this bug yet. Based on review, I will create the CSR for change to the specification. Thank you for your time in review & Happy New Year Prahalad N.