[cp-patches] FYI: Fix bug in static Byte constructor

Andrew Hughes A.Hughes at dcs.shef.ac.uk
Mon Apr 21 10:37:27 UTC 2008


This fixes a bug introduced by Ian's patch which
causes the Byte static initializer to get stuck
in an infinite loop.

ChangeLog:

2008-04-21  Andrew John Hughes  <gnu_andrew at member.fsf.org>

	* java/lang/Byte.java:
	(static): Use a short as the loop counter, not
	a byte as this can't exceed MAX_VALUE.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
-------------- next part --------------
Index: java/lang/Byte.java
===================================================================
RCS file: /sources/classpath/classpath/java/lang/Byte.java,v
retrieving revision 1.27
diff -u -r1.27 Byte.java
--- java/lang/Byte.java	18 Apr 2008 21:00:10 -0000	1.27
+++ java/lang/Byte.java	21 Apr 2008 10:30:52 -0000
@@ -90,8 +90,8 @@
   private static Byte[] byteCache = new Byte[MAX_VALUE - MIN_VALUE + 1];
   static
   {
-    for (byte i=MIN_VALUE; i <= MAX_VALUE; i++)
-      byteCache[i - MIN_VALUE] = new Byte(i);
+    for (short i=MIN_VALUE; i <= MAX_VALUE; i++)
+      byteCache[i - MIN_VALUE] = new Byte((byte) i);
   }
 
 


More information about the Classpath-patches mailing list