ycomp
ycomp

Reputation: 8563

Loading Kotlin generated classes at runtime from Java

I have 2 projects...

My main java project and a kotlin sub project that I moved some java classes out of the main project into and converted into kotlin.

I've configured the kotlin project to have a dependency on the main java project, it works quite well since IJ is constantly recompiling java classes in the main project.

But now that i've extracted classes from the Java project, it won't compile anymore of course - it needs to access the kotlin project.

However, I don't know how to do that.. can someone explain? thanks

my kotlin out folder is empty whenever I look at it

Upvotes: 0

Views: 1053

Answers (1)

yole
yole

Reputation: 97148

Kotlin generates perfectly ordinary Java class files, so you can use Class.forName() and Class<?>.getConstructor().getNewInstance() with them just as well as with classes compiled from Java source code.

Upvotes: 1

Related Questions