diff options
author | Paul Phillips <paulp@improving.org> | 2009-09-19 02:28:17 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-09-19 02:28:17 +0000 |
commit | 32f93874aca8caf4a899d4f481365803d1fc46b6 (patch) | |
tree | 4456a35aa79270f8fb1ab6b95db8abed128aee6e /src/library | |
parent | acf1e47be8f8d7cabcb900c56a0e1ae7c0d8c1e1 (diff) | |
download | scala-32f93874aca8caf4a899d4f481365803d1fc46b6.tar.gz scala-32f93874aca8caf4a899d4f481365803d1fc46b6.tar.bz2 scala-32f93874aca8caf4a899d4f481365803d1fc46b6.zip |
Working around a mysterious bug which was expos...
Working around a mysterious bug which was exposed in r17461.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/runtime/BoxesRunTime.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/library/scala/runtime/BoxesRunTime.java b/src/library/scala/runtime/BoxesRunTime.java index bd4ed42cd9..3f71bb9409 100644 --- a/src/library/scala/runtime/BoxesRunTime.java +++ b/src/library/scala/runtime/BoxesRunTime.java @@ -47,7 +47,20 @@ public class BoxesRunTime { } public static Character boxToCharacter(char c) { - return Character.valueOf(c); + // !!! Temporarily working around the "impossible" (?) fact that + // c can have a negative value here. In any revision since r17461 try: + // def foo = new (Short => Char) { def apply(x: Short) = x.toChar } + // foo(-100) + // and the -100 will get to Character, which will duly crash. + // The bug was masked before because the Characters were created + // with "new Character(c)" and the constructor avenue must have + // some check against negative values, whereas the static method doesn't. + // + // It appears to be Short-specific; I can't get anything similar + // out of Byte or Int. + return Character.valueOf((char)(c & 0xFFFF)); + // return new Character(c); <-- this also would work + // return Character.valueOf(c); <-- but not this } public static Byte boxToByte(byte b) { |