https://kotlinlang.org logo
#announcements
Title
# announcements
k

karelpeeters

09/02/2017, 8:07 AM
@dragas Well this just works:
val myInt: Int = Integer.valueOf(200)
.
d

dragas

09/02/2017, 8:13 AM
What if
Int::class
may be provided via lambda? 🤔
err annotation
k

karelpeeters

09/02/2017, 8:13 AM
I don't know, what about it? Can you give an example?
d

dragas

09/02/2017, 8:14 AM
Hold on, I'll look into my spaghetti codebase
Copy code
val type = method.getAnnotation(On::class.java).value
builder.testCallback { route, it -> it as Any; type.java.isAssignableFrom(it.javaClass) }
You may provide any class via annotation
@On
Meanwhile it cast to any is necessary as at that particular spot it's a generic.
k

karelpeeters

09/02/2017, 8:54 AM
Hmm so your problem is that
isAssignableFrom
doesn't behave correctly?
Maybe file a YouTrack issue?
d

diesieben07

09/02/2017, 9:00 AM
You'll have to use
type.javaObjectType
if you want to always get the boxed class, which is the case here.
So
type.javaObjectType.isAssignableFrom(it.javaClass)
d

dragas

09/02/2017, 12:05 PM
Cheers. How would it behave with actual object types? Would it return like
it.java
would?
d

diesieben07

09/02/2017, 1:31 PM
Yes, it would