<@U4KK5S5NV> I believe the difference is whether a...
# announcements
s
@moelholm I believe the difference is whether a Java
Class
or a Kotlin
KClass
is expected.
::class.java
will return
Class
.
m
Hi Sven. I think you are spot on. But the @RunWith JUnit annotation does indeed expect a Class. When I look in IntelliJ. But I guess that a KClass "is-a" Class when observed from Java... and perhaps that's enough for the JUnit runner framework to work
o
This is a special case for annotations. A
KClass
does not in general share an is-a relationship with
Class
See quote: "If you need to specify a class as an argument of an annotation, use a Kotlin class (KClass). The Kotlin compiler will automatically convert it to a Java class, so that the Java code will be able to see the annotations and arguments normally." https://kotlinlang.org/docs/reference/annotations.html#constructors
m
Awesome, Ole - thanks for the explanation