FULL PRODUCT VERSION : java -version java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing) java version "1.5.0_11" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03) Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Linux edwin-t-new 2.6.22.1-cfs-v19 #1 SMP PREEMPT Tue Jul 17 12:46:51 EEST 2007 i686 GNU/Linux A DESCRIPTION OF THE PROBLEM : When trying to create a string containing all codePoints (in range Character.MIN_CODE_POINT, Character.MAX_CODE_POINT) an ArrayIndexOutOfBounds exception is thrown from the String constructor. Occurs with both java 1.5, and java 1.6. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Compile the sample code below: javac Test.java Run the sample code: java Test EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - No exceptions are thrown ACTUAL - Exception is thrown in the String constructor. ERROR MESSAGES/STACK TRACES THAT OCCUR : When running with JDK 1.6.0: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1114113 at java.lang.Character.toSurrogates(Character.java:2596) at java.lang.String.<init>(String.java:286) at Test.main(Test.java:7) When running with JDK 1.5.0.11: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1114113 at java.lang.Character.toSurrogates(Character.java:2596) at java.lang.String.<init>(String.java:275) at Test.main(Test.java:7) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- class Test { public static void main(String[] args) { int [] codePoints=new int[Character.MAX_CODE_POINT]; for(int i=0;i<codePoints.length;i++) { codePoints[i] = i; } final String original = new String(codePoints, 0, codePoints.length); } } ---------- END SOURCE ----------
|