-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.3.0
-
sparc
-
solaris_2.5
Name: dfC67450 Date: 07/02/99
CollationElementIterator.setOffset(int offset) is broken in Kestrel "I".
It no longer throws IllegalArgumentException if offset == -1 and throws
if offset equals to the length of source.
Javadoc says nothing about this case but old behavior looks more correct.
Here is a minimized test:
-----------------Test.java------------------------
import java.text.*;
public class Test {
public static void main (String args[]){
String rule = "< c, C < d; D";
RuleBasedCollator rbc = null;
try {
rbc = new RuleBasedCollator(rule); // create an object
CollationElementIterator iterator =
rbc.getCollationElementIterator(""); // get iterator
String source = "Hello";
iterator.setText(source);
int offset = -1;
System.out.println("setOffset(" + offset + ")");
try {
iterator.setOffset(offset);
System.out.println("getOffset(): " + iterator.getOffset());
} catch (IllegalArgumentException e) {
System.out.println("IllegalArgumentException: " + e);
}
System.out.println("--------------------------------");
offset = source.length();
System.out.println("setOffset(" + offset + ")");
try {
iterator.setOffset(offset);
System.out.println("getOffset(): " + iterator.getOffset());
} catch (IllegalArgumentException e) {
System.out.println("IllegalArgumentException: " + e);
}
} catch (ParseException e) {
System.out.println("Unexpected ParseException: " + e);
}
}
}
--------- sample run (JDK1.2.2, correct: both list are the same) -----------
setOffset(-1)
IllegalArgumentException: java.lang.IllegalArgumentException: Invalid index
--------------------------------
setOffset(5)
getOffset(): 5
--------- sample run (JDK1.3 I, WRONG: the second list is bogus) -----------
setOffset(-1)
getOffset: 0
--------------------------------
setOffset(5)
IllegalArgumentException: java.lang.IllegalArgumentException: Invalid index
-----------------------------------------------------------------------------
======================================================================
- duplicates
-
JDK-4250680 kestrel I fails: api/java_text/CollationElementIterator/index.html#ColltnElmtIte
- Closed