I was working on the Android library which I'm developing in Kotlin. I kept access modifier of some classes as internal
. Internal classes are only visible in that library module in Kotlin. If I implement that library in the app then it's not visible at all.
But the problem comes when accessing that library from Java code. If I create .java
file and type name of that internal
class of library then IDE is suggesting name and it's resolved and compiled without any error.
For e.g.
Library Module:
internal class LibClass {
// Fields and Methods
}
After implementing above library in DemoApp module:
App Module
Kotlin:fun stuff() {
val lib = LibClass() // Error.. Not resolving
}
Java:
public void stuff() {
LibClass lib = new LibClass() // Successfully resolving and compiling
}
So that's the problem. How can I achieve securing that class from Java?
Thank you!
@JvmName
and give it an invalid Java name like containing a space, hyphen or something. – Saurabh Thorat@JvmName
but it's not working. It only works when top-level functions are created inside.kt
file. It's not working for the class. – Shreyas Patil