I have a java class which reads data from some sou...
# android
r
I have a java class which reads data from some source and casts that data into given class. I pass the class name in which data has to be caste as SomeUserClass.java. How can i pass this info from Kotlin class to java function. I tried SomeUserClass::class.java but it gives me error. This is the java function signature public T getDataFromCache(Class<T> model) { // some operation } and while calling from java i use getDataFromCache(SomeUserClass.class); how can i call this function from Kotlin class ? Thanks in advance
a
Try simply
SomeUserClass::class
?
e
Using
SomeUserClass::class.java
works in my case, can you show the error message?
r
@adam-mcneilly when i do SomeUserClass::class i get type mismatch error. Required Class<SomeGroupClass!>! found KCLass<SomeUserClass>
@edwardwongtl i get type mismatch error. Required Class<SomeGroupClass!>! found KCLass<SomeUserClass>
a
You get the same error with or without
.java
at the end?
r
with
.java
i get Unresolved referance. and without java i get type mismatch
a
I took to Google because I think you're doing it right, and I found some stuff suggesting your configuration might be off. I'd double check some of it - https://stackoverflow.com/questions/34144392/kotlin-fooclass-java-unresolved-reference-java-error
r
@adam-mcneilly hey thanks for the link. I had forgot to configure kotlin in my project. I did that and it is not working with SomeUserClass::class.java. Thanks for the help. Cheers !
a
😄