summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/runtime/BoxesRunTime.java16
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) {