Is it possible to access Kotlin types from Java?

Suppose I have a Kotlin 1.1 typealias for a Kotlin function type like this

 typealias Consumer<T> = (T) -> Unit 

I can access this from Java as

 import kotlin.Unit; import kotlin.jvm.functions.Function1; Function1<? super T, Unit> action = ... 

How can I access the Kotlin Function1 interface from Java under its name like Kotlin (i.e. Consumer )?

+5
source share
1 answer

From the KEEP clause for type aliases:

NB Java does not have the concept of "type aliases" and cannot see them in class member signatures.

No, you cannot use typealiases from Java, you just see the actual types of any parameter or variable of type typealias'd in Kotlin.

+7
source

Source: https://habr.com/ru/post/1272316/


All Articles