Why an inline function defined in a Kotlin file cannot be used in Java code?

Viewed 241

I'm trying to understand why I cannot use my inline function defined in a Kotlin file in my Java code?

Project details

Kotlin: 1.5.20 - Java: 15.0.1

Mixed code (Java + Kotlin). I have same package structure both in Java & Kotlin as below:

com.app.company.util.Util.java

com.app.company.util.Util.kt

In Util.kt I have an inline function as below:

val commonMapper = jacksonObjectMapper()

inline fun <reified T> parseJson(content: String): T {
   return commonMapper.readValue(content)
}

I noticed that since I have the same name Util for both Java class and Kotlin file, If I want to refer to the Kotlin file I have to use UtilKt. I found this by decompiling the Kotlin file.

Interestingly, only commonMapper is exposed by getCommonMapper() method not parseJson.

Could someone please help me understand why parseJson is not visible from Java?

0 Answers
Related