Mikael Ståldal
10/24/2022, 7:50 AMpackage mypackage
fun main(args: Array<String>) {
// ...
}
Usually used as program entrypoint in JVM.
However, when I try to call it from another Kotlin module:
import mypackage.main
class MyClass {
fun myMethod() {
main(arrayOf("foo", "bar"))
}
}
I get this strange error:
Kotlin: Overload resolution ambiguity:
public fun main(args: Array<String>): Unit defined in mypackage
public fun main(args: Array<String>): Unit defined in mypackage
Mikael Ståldal
10/24/2022, 8:16 AMmain
fun defined in the same package. That's not a problem when running the programs, since then end up in different JVM classes (with Kt
suffix). And not a problem when calling from Java. But how can I call from Kotlin?Joffrey
10/24/2022, 8:57 AMmain()
functions that call those.Mikael Ståldal
10/24/2022, 9:01 AMJoffrey
10/24/2022, 3:37 PMmain()
functions?Mikael Ståldal
10/24/2022, 3:40 PMMikael Ståldal
10/24/2022, 3:41 PMMikael Ståldal
10/24/2022, 3:42 PMJoffrey
10/24/2022, 3:44 PMmain
).Joffrey
10/24/2022, 3:44 PMProcessBuilder
(this would be the "proper way" to use the CLI application)Mikael Ståldal
10/24/2022, 3:45 PMmain
methods use private methods, so I cannot inline it. 🤷