[11] RFR: [JDK-5064835] TextMeasurer/deleteChar function fails when deleting more than one characters

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[11] RFR: [JDK-5064835] TextMeasurer/deleteChar function fails when deleting more than one characters

Prahalad kumar Narayanan
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.
Reply | Threaded
Open this post in threaded view
|

Re: [11] RFR: [JDK-5064835] TextMeasurer/deleteChar function fails when deleting more than one characters

Jayathirth D v
Hi Prahalad,

Please find my inputs:

Since we are making changes to deleteChar() code and specification I think we should make similar changes to insertChar() to make them behave in same way. I observed Jane Wang comment in JBS and tested inserting multiple character using TextMeasurer.insertChar() and it doesn't through ArrayIndexOutOfBoundsException or any other exception, it just initializes the text parameters using the newParagraph.

We can make changes corresponding to insertChar() in the same bug or we can raise separate bug, but its better if we make changes to insertChar() also in the same JBS as they are similar change corresponding to identical behavior in same Class.

Regarding JCK test fail, since we are targeting it to JDK 11 I think we have time to update the same without any risk. But we should get input from Phil/Others regarding the same.

In the test case may be we can remove the System.out.println("Test passed."), since we know that if we don't get any exception/errors the jtreg test is passed. I see that some test cases have this "Test Passed" output but I feel it is redundant.

Thanks,
Jay

-----Original Message-----
From: Prahalad Kumar Narayanan
Sent: Friday, December 29, 2017 4:30 PM
To: 2d-dev
Subject: [OpenJDK 2D-Dev] [11] RFR: [JDK-5064835] TextMeasurer/deleteChar function fails when deleting more than one characters

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.
Reply | Threaded
Open this post in threaded view
|

Re: [11] RFR: [JDK-5064835] TextMeasurer/deleteChar function fails when deleting more than one characters

Sergey Bylokhov
Just small comment(for a discussion), about a performance of these
methods. How much faster these methods from the case when the
TextMeasure is created from scratch? I mean that if they are much faster
and the insertChar() method works already, then probably we can support
this in deleteChar as well?

On 01/01/2018 22:53, Jayathirth D V wrote:

> Hi Prahalad,
>
> Please find my inputs:
>
> Since we are making changes to deleteChar() code and specification I think we should make similar changes to insertChar() to make them behave in same way. I observed Jane Wang comment in JBS and tested inserting multiple character using TextMeasurer.insertChar() and it doesn't through ArrayIndexOutOfBoundsException or any other exception, it just initializes the text parameters using the newParagraph.
>
> We can make changes corresponding to insertChar() in the same bug or we can raise separate bug, but its better if we make changes to insertChar() also in the same JBS as they are similar change corresponding to identical behavior in same Class.
>
> Regarding JCK test fail, since we are targeting it to JDK 11 I think we have time to update the same without any risk. But we should get input from Phil/Others regarding the same.
>
> In the test case may be we can remove the System.out.println("Test passed."), since we know that if we don't get any exception/errors the jtreg test is passed. I see that some test cases have this "Test Passed" output but I feel it is redundant.
>
> Thanks,
> Jay
>
> -----Original Message-----
> From: Prahalad Kumar Narayanan
> Sent: Friday, December 29, 2017 4:30 PM
> To: 2d-dev
> Subject: [OpenJDK 2D-Dev] [11] RFR: [JDK-5064835] TextMeasurer/deleteChar function fails when deleting more than one characters
>
> 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.
>


--
Best regards, Sergey.
Reply | Threaded
Open this post in threaded view
|

Re: [11] RFR: [JDK-5064835] TextMeasurer/deleteChar function fails when deleting more than one characters

Prahalad kumar Narayanan
Hello Sergey & Jay

Thank you for your time in review & inputs.
Please find my views herewith:

. On Performance:
      . TextMeasurer's Constructor invokes : initAll(AttributedCharacterIterator text) method
      . initAll(AttributedCharacterIterator ) method further instantiates
            . fChars : new char[length]
            . fBidi : new Bidi
            . fParagraph : new StyledParagraph and so on.
      . The concerned method- deleteChar (and insertChar), invoke the same "initAll" method when number of characters deleted or inserted is more than one.
      . So from performance perspective, there shouldn't be a major difference between creating a new TextMeasurer and using deleteChar to delete more than few characters.

      . When methods invoke initAll, the text and its attributes are re-initialized and we would lose the text attributes originally set on TextMeasurer.
      . This is the reason why the proposed fix doesn't allow re-initialization and throws IllegalArgumentException when attempted to delete multiple chars.

. On Modifying insertChar method's behavior
      . As Jay suggested, we should fix insertChar method's behavior to align with deleteChar method.
      . I was not sure whether we should make changes to insertChar as a separate bug /or alongside the current fix.

      . Nevertheless, I 've created a new webrev with the changes included for insertChar as well.
      . Impact from changes to insertChar are as follows-
            . No new regressions seen with JTreg test cases.
            . The change in insertChar introduces 4 JCK test failures making total count of JCK test failures to 6
            . JCK tests that failed are:
                     api/java_awt/Font/TextMeasurer/CharTest (Test cases: 1, 2, 5)
                     api/java_awt/Font/LineBreakTextMeasurer/CharTest (Test cases: 1, 2, 4)
      . All the above test cases can be easily fixed with specification updated for the methods.
 
Kindly review the updated changes at your convenience.
Link: http://cr.openjdk.java.net/~pnarayanan/5064835/webrev.01/

Thank you once again
Have a good day

Prahalad N.


-----Original Message-----
From: Sergey Bylokhov
Sent: Saturday, January 06, 2018 3:04 PM
To: Jayathirth D V; Prahalad Kumar Narayanan; 2d-dev
Subject: Re: [OpenJDK 2D-Dev] [11] RFR: [JDK-5064835] TextMeasurer/deleteChar function fails when deleting more than one characters

Just small comment(for a discussion), about a performance of these methods. How much faster these methods from the case when the TextMeasure is created from scratch? I mean that if they are much faster and the insertChar() method works already, then probably we can support this in deleteChar as well?

On 01/01/2018 22:53, Jayathirth D V wrote:

> Hi Prahalad,
>
> Please find my inputs:
>
> Since we are making changes to deleteChar() code and specification I think we should make similar changes to insertChar() to make them behave in same way. I observed Jane Wang comment in JBS and tested inserting multiple character using TextMeasurer.insertChar() and it doesn't through ArrayIndexOutOfBoundsException or any other exception, it just initializes the text parameters using the newParagraph.
>
> We can make changes corresponding to insertChar() in the same bug or we can raise separate bug, but its better if we make changes to insertChar() also in the same JBS as they are similar change corresponding to identical behavior in same Class.
>
> Regarding JCK test fail, since we are targeting it to JDK 11 I think we have time to update the same without any risk. But we should get input from Phil/Others regarding the same.
>
> In the test case may be we can remove the System.out.println("Test passed."), since we know that if we don't get any exception/errors the jtreg test is passed. I see that some test cases have this "Test Passed" output but I feel it is redundant.
>
> Thanks,
> Jay
>
> -----Original Message-----
> From: Prahalad Kumar Narayanan
> Sent: Friday, December 29, 2017 4:30 PM
> To: 2d-dev
> Subject: [OpenJDK 2D-Dev] [11] RFR: [JDK-5064835]
> TextMeasurer/deleteChar function fails when deleting more than one
> characters
>
> 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.
>


--
Best regards, Sergey.
Reply | Threaded
Open this post in threaded view
|

Re: [11] RFR: [JDK-5064835] TextMeasurer/deleteChar function fails when deleting more than one characters

Jayathirth D v
Hi Prahalad,

Changes in insertChar() are also fine.

I noticed a small correction in indentation for which there is no need for another webrev.
At line number 674 & 738. We should maintain space between operands and operator.
if (end - start != fChars.length+1) {       ->        if (end - start != fChars.length + 1) {
&
if (end - start != fChars.length-1) {        ->         if (end - start != fChars.length - 1) {

Thanks,
Jay

-----Original Message-----
From: Prahalad Kumar Narayanan
Sent: Monday, January 08, 2018 12:12 PM
To: Sergey Bylokhov; Jayathirth D V; 2d-dev
Subject: RE: [OpenJDK 2D-Dev] [11] RFR: [JDK-5064835] TextMeasurer/deleteChar function fails when deleting more than one characters

Hello Sergey & Jay

Thank you for your time in review & inputs.
Please find my views herewith:

. On Performance:
      . TextMeasurer's Constructor invokes : initAll(AttributedCharacterIterator text) method
      . initAll(AttributedCharacterIterator ) method further instantiates
            . fChars : new char[length]
            . fBidi : new Bidi
            . fParagraph : new StyledParagraph and so on.
      . The concerned method- deleteChar (and insertChar), invoke the same "initAll" method when number of characters deleted or inserted is more than one.
      . So from performance perspective, there shouldn't be a major difference between creating a new TextMeasurer and using deleteChar to delete more than few characters.

      . When methods invoke initAll, the text and its attributes are re-initialized and we would lose the text attributes originally set on TextMeasurer.
      . This is the reason why the proposed fix doesn't allow re-initialization and throws IllegalArgumentException when attempted to delete multiple chars.

. On Modifying insertChar method's behavior
      . As Jay suggested, we should fix insertChar method's behavior to align with deleteChar method.
      . I was not sure whether we should make changes to insertChar as a separate bug /or alongside the current fix.

      . Nevertheless, I 've created a new webrev with the changes included for insertChar as well.
      . Impact from changes to insertChar are as follows-
            . No new regressions seen with JTreg test cases.
            . The change in insertChar introduces 4 JCK test failures making total count of JCK test failures to 6
            . JCK tests that failed are:
                     api/java_awt/Font/TextMeasurer/CharTest (Test cases: 1, 2, 5)
                     api/java_awt/Font/LineBreakTextMeasurer/CharTest (Test cases: 1, 2, 4)
      . All the above test cases can be easily fixed with specification updated for the methods.
 
Kindly review the updated changes at your convenience.
Link: http://cr.openjdk.java.net/~pnarayanan/5064835/webrev.01/

Thank you once again
Have a good day

Prahalad N.


-----Original Message-----
From: Sergey Bylokhov
Sent: Saturday, January 06, 2018 3:04 PM
To: Jayathirth D V; Prahalad Kumar Narayanan; 2d-dev
Subject: Re: [OpenJDK 2D-Dev] [11] RFR: [JDK-5064835] TextMeasurer/deleteChar function fails when deleting more than one characters

Just small comment(for a discussion), about a performance of these methods. How much faster these methods from the case when the TextMeasure is created from scratch? I mean that if they are much faster and the insertChar() method works already, then probably we can support this in deleteChar as well?

On 01/01/2018 22:53, Jayathirth D V wrote:

> Hi Prahalad,
>
> Please find my inputs:
>
> Since we are making changes to deleteChar() code and specification I think we should make similar changes to insertChar() to make them behave in same way. I observed Jane Wang comment in JBS and tested inserting multiple character using TextMeasurer.insertChar() and it doesn't through ArrayIndexOutOfBoundsException or any other exception, it just initializes the text parameters using the newParagraph.
>
> We can make changes corresponding to insertChar() in the same bug or we can raise separate bug, but its better if we make changes to insertChar() also in the same JBS as they are similar change corresponding to identical behavior in same Class.
>
> Regarding JCK test fail, since we are targeting it to JDK 11 I think we have time to update the same without any risk. But we should get input from Phil/Others regarding the same.
>
> In the test case may be we can remove the System.out.println("Test passed."), since we know that if we don't get any exception/errors the jtreg test is passed. I see that some test cases have this "Test Passed" output but I feel it is redundant.
>
> Thanks,
> Jay
>
> -----Original Message-----
> From: Prahalad Kumar Narayanan
> Sent: Friday, December 29, 2017 4:30 PM
> To: 2d-dev
> Subject: [OpenJDK 2D-Dev] [11] RFR: [JDK-5064835]
> TextMeasurer/deleteChar function fails when deleting more than one
> characters
>
> 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.
>


--
Best regards, Sergey.
Reply | Threaded
Open this post in threaded view
|

Re: [11] RFR: [JDK-5064835] TextMeasurer/deleteChar function fails when deleting more than one characters

Philip Race
In reply to this post by Prahalad kumar Narayanan
I think we need to divine what the authors of the method intended since they
seem a bit conflicted about whether only 1 or > 1 chars can be deleted.

- The method is called deleteChar and says it updates the measurer in
such a case.
- It then says that this call is equivalent to creating a new measurer
from the text ..
    presumably meaning the text represented by the iterator.

- I am sure that "newParagraph" is expected to be a sub-set of the old
text but
   what stops you from having original text "abcdef" and new text "12345" ?
   That seems like it neds some doc treatment .. at the least .. have some
fun testing that when you replace LTR with RTL text for example.

- The code does check to see if the new text is other than one char
different .. although
    it checks only the length .. not the content and if the length is
!=1 char different
    it it is then re-creates from scratch. This seems to suggest that it
is expected to
    support > 1 char deleted and allows for the 1 char case as an
optimisation.

- A consequence of these previous two points is that

- I don't see any "state" at the API level, so the discussions about
resetting or losing
   state are confusing. The internal "state" won't be lost, it'll be
re-created.

- I am at a loss to understand why after "initAll()" the method needs to
go through
the pointless exercise of recreating the arrays and calling
StyledParagraph.deleteChar(..)
Seems to me it can just proceed straight to invalidateComponents()
In fact isn't this the bug ? That's why we get AIOB .. because the code
assumes "fChars"
is the original longer array.

On balance I think the method is mis-named and mis-documented in suggesting
only a single char is supported. We can't fix the name but we can fix
the docs
and the exception. This may be the most compatible and most useful fix.


- LineBreakMeasurer looks very similar and needs the same treatment as
this class

- Minor thing to fix : StyledParagraph.deleteChar javadoc seems to have
a copy paste
error from StyledParagraph.insertChar

      * Return a StyledParagraph reflecting the insertion of a single
character
      * into the text

Should be
      * Return a StyledParagraph reflecting the deletion of a single
character
      * from the text

-phil.

On 12/29/2017 03:00 AM, Prahalad Kumar Narayanan wrote:

> 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.