I noticed one interesting thing.
Java Integer.MAX_VALUE- 0x7fffffff(2147483647)
Kotlin Int.MAX_VALUEis there, 2147483647
but if you write in Java:
int value = 0xFFFFFFFF;
//everything is fine (but printed value is '-1')
in Kotlin:
val value: Int = 0xFFFFFFFF //You get exception
The integer literal does not conform to the expected type Int
Interesting right? That way you can do something like this new java.awt.Color(0xFFFFFFFF, true)in Java, but not in Kotlin.
Colorthe class works with this int at the "binary" level, so everything works fine for both platforms with all the constructors ( Color(int rgba)or Color(int r, int g, int b, int a)).
Only workaround that I've found for Kotlin, java.awt.Color(0xFFFFFFFF.toInt(), true).
Any idea why this is happening in Kotlin?
Kikju source
share