Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8255242: Bidi.requiresBidi has misleading exception message
Reviewed-by: bchristi
  • Loading branch information
naotoj committed Oct 25, 2020
1 parent 60d0142 commit 57d903b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Expand Up @@ -4541,7 +4541,8 @@ public static boolean requiresBidi(char[] text,

if (0 > start || start > limit || limit > text.length) {
throw new IllegalArgumentException("Value start " + start +
" is out of range 0 to " + limit);
" is out of range 0 to " + limit + ", or limit " + limit +
" is beyond the text length " + text.length);
}

for (int i = start; i < limit; ++i) {
Expand Down
10 changes: 8 additions & 2 deletions test/jdk/java/text/Bidi/BidiConformance.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,7 +23,7 @@

/*
* @test
* @bug 6850113 8032446
* @bug 6850113 8032446 8255242
* @summary confirm the behavior of new Bidi implementation. (Backward compatibility)
* @modules java.desktop
*/
Expand Down Expand Up @@ -1397,6 +1397,12 @@ private void testMethod_requiresBidi() {
" when limit is textLength+1(too large).");
}
catch (IllegalArgumentException e) {
if (!e.getMessage().equals(
"Value start 0 is out of range 0 to " + (textLength + 1) +
", or limit " + (textLength + 1) + " is beyond the text length " + textLength)) {
errorHandling("requiresBidi() should throw an IAE" +
" mentioning limit is beyond the text length. Message: " + e.getMessage());
}
}
catch (ArrayIndexOutOfBoundsException e) {
errorHandling("requiresBidi() should not throw an AIOoBE " +
Expand Down

1 comment on commit 57d903b

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 57d903b Oct 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.