ClassCastException when casting Character to int #1021
Closed
Description
The following code seems to yield different results on Java and in ObjC:
Character c = '\n';
try {
System.out.println((int) c);
} catch (Exception e) {
System.out.println(e);
}
Compiling with javac, this yields 10 (correctly), while j2objc throws this exception:
java.lang.ClassCastException: Cannot cast object of type java.lang.Character to JavaLangInteger
Which seems to be due to the fact that unboxing + widening casts are handled for all numeric types except Character (which does not have the intValue/longValue/doubleValue etc. conversion methods).
I'll upload a PR with an attempt to address this issue shortly.
Metadata
Assignees
Labels
No labels
Activity