diff options
author | Paul Phillips <paulp@improving.org> | 2009-09-27 03:38:21 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-09-27 03:38:21 +0000 |
commit | 32cac0e3fde4a512d7322cd60146bdac7d1898d4 (patch) | |
tree | 8219061172e3bd44edde9cd45539c28b9e46896f /src/library | |
parent | f0dc32f686a08c427a8e159795d081e2ca396c8a (diff) | |
download | scala-32cac0e3fde4a512d7322cd60146bdac7d1898d4.tar.gz scala-32cac0e3fde4a512d7322cd60146bdac7d1898d4.tar.bz2 scala-32cac0e3fde4a512d7322cd60146bdac7d1898d4.zip |
My workaround for the negative chars didn't work.
All bets are off in negative char land. This workaround "works" but
there is still a negative value in the boxed char, which can come back
out. This needs fixing...
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/runtime/BoxesRunTime.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/library/scala/runtime/BoxesRunTime.java b/src/library/scala/runtime/BoxesRunTime.java index 2e4af2d13a..010e2738c9 100644 --- a/src/library/scala/runtime/BoxesRunTime.java +++ b/src/library/scala/runtime/BoxesRunTime.java @@ -60,9 +60,19 @@ public class BoxesRunTime // // 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 + Character ret; + + // straightforward workarounds like bitmasking do not seem to + // work here; is java optimizing out "impossible" tests/ops? I + // don't know, but this is the safe way: + try { + ret = Character.valueOf(c); + } + catch (ArrayIndexOutOfBoundsException e) { + ret = new Character(c); + } + + return ret; } public static Byte boxToByte(byte b) { |