Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassCastException when casting Character to int #1021

Closed
omerp opened this issue Jan 3, 2019 · 1 comment
Closed

ClassCastException when casting Character to int #1021

omerp opened this issue Jan 3, 2019 · 1 comment

Comments

@omerp
Copy link
Contributor

omerp commented Jan 3, 2019

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.

@antonio-cortes-perez
Copy link
Contributor

Fixed in 2.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants