FULL PRODUCT VERSION :
java version " 1.6.0_33 "
Java(TM) SE Runtime Environment (build 1.6.0_33-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux XXXXXXXX 2.6.32.26-175.fc12.x86_64 #1 SMP Wed Dec 1 21:39:34 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux
Darwin YYYYYYYY 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
Attempting to construct a String given a larger integer array of Unicode code points such that the code points require surrogate pairs for Java's internal representation, fails with an ArrayIndexOutOfBoundsException for larger (>2048) odd-numbered input array lengths.
Exception in thread " main " java.lang.ArrayIndexOutOfBoundsException: 2051
at java.lang.Character.toSurrogates(Character.java:2596)
at java.lang.String.<init>(String.java:285)
at BugReport.main(BugReport.java:7)
This problem has been reported by someone else as bug id#6588260 but was apparently closed unfixed.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create an odd-numbered integer array larger than 2048 elements.
2) Fill the array with *valid* Unicode code points larger than 0xFFFF.
3) Pass the array to a String contructor that also takes offset and size.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A String representing the input Unicode code points.
ACTUAL -
java.lang.ArrayIndexOutOfBoundsException
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread " main " java.lang.ArrayIndexOutOfBoundsException: 2051
at java.lang.Character.toSurrogates(Character.java:2596)
at java.lang.String.<init>(String.java:285)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class BugReport {
public static void main(String[] args) {
for ( int i=2048; i<2100; ++i ) {
int[] codePoints = new int[i];
for ( int j=0; j<i; ++j ) codePoints[j] = 0x24B24; // CJK
try {
final String kaboom = new String( codePoints, 0, i );
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println(String.format( " %d does not work " ,i));
}
}
}
}
---------- END SOURCE ----------
java version " 1.6.0_33 "
Java(TM) SE Runtime Environment (build 1.6.0_33-b04)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux XXXXXXXX 2.6.32.26-175.fc12.x86_64 #1 SMP Wed Dec 1 21:39:34 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux
Darwin YYYYYYYY 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
Attempting to construct a String given a larger integer array of Unicode code points such that the code points require surrogate pairs for Java's internal representation, fails with an ArrayIndexOutOfBoundsException for larger (>2048) odd-numbered input array lengths.
Exception in thread " main " java.lang.ArrayIndexOutOfBoundsException: 2051
at java.lang.Character.toSurrogates(Character.java:2596)
at java.lang.String.<init>(String.java:285)
at BugReport.main(BugReport.java:7)
This problem has been reported by someone else as bug id#6588260 but was apparently closed unfixed.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create an odd-numbered integer array larger than 2048 elements.
2) Fill the array with *valid* Unicode code points larger than 0xFFFF.
3) Pass the array to a String contructor that also takes offset and size.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A String representing the input Unicode code points.
ACTUAL -
java.lang.ArrayIndexOutOfBoundsException
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread " main " java.lang.ArrayIndexOutOfBoundsException: 2051
at java.lang.Character.toSurrogates(Character.java:2596)
at java.lang.String.<init>(String.java:285)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class BugReport {
public static void main(String[] args) {
for ( int i=2048; i<2100; ++i ) {
int[] codePoints = new int[i];
for ( int j=0; j<i; ++j ) codePoints[j] = 0x24B24; // CJK
try {
final String kaboom = new String( codePoints, 0, i );
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println(String.format( " %d does not work " ,i));
}
}
}
}
---------- END SOURCE ----------