The following three types are defined in KClass as properties that return Class.
.java.javaObjectType.javaPrimitiveTypeTaking the ʻInt type of Kotlin` as an example, the returned contents are as follows.
.java |
.javaObjectType |
.javaPrimitiveType |
|
|---|---|---|---|
Int::class |
int.class |
Integer.class |
int.class |
Integer::class |
Integer.class |
Integer.class |
int.class |
| Other | *.class |
*.class |
null |
You will need to use them properly depending on whether you need to distinguish between primitive types and wrapper types.
Also, I have followed the pattern of "Implementation that requires Class does not support primitive types ", so in such a case, it is necessary to call .javaObjectType.
-[Kotlin 1 \ .0 Beta 4 changes -Qiita](https://qiita.com/mattak/items/ba0e3294d539a86f120f#%E3%81%95%E3%82%89%E3%81%AB% E3% 83% 8F% E3% 82% A4% E3% 83% A9% E3% 82% A4% E3% 83% 88)
Recommended Posts