AnDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
internal function in Kotlin is a function whose visibility is restricted to the module in which it is declared. The internal visibility modifier ensures that the function can be accessed by any code within the same compiled module, regardless of the package structure, but remains strictly invisible to code residing in external modules.
In Kotlin, a “module” is defined as a set of Kotlin files compiled together. This specifically translates to:
- An IntelliJ IDEA module.
- A Maven project.
- A Gradle source set (with the exception that the
testsource set can access themainsource set’s internal declarations). - A set of files compiled with a single invocation of the
<kotlinc>Ant task.
- Package Independence: Unlike Java’s default “package-private” visibility, Kotlin’s
internalmodifier does not care about package boundaries. Aninternalfunction incom.example.networkcan be freely called by a class incom.example.ui, provided both packages are compiled within the same module. - Class Member Visibility: If an
internalfunction is declared inside a class, the caller must also have visibility access to the class itself. For example, aninternalfunction inside aprivateclass is only accessible within the file where theprivateclass is defined. - JVM Bytecode Representation: Because the Java Virtual Machine (JVM) lacks a direct equivalent to Kotlin’s module-level visibility, the Kotlin compiler translates
internalfunctions intopublicmethods in the generated Java bytecode. - Name Mangling: To prevent external Java code from accidentally invoking these compiled
publicmethods, the Kotlin compiler applies name mangling. It appends a dollar sign and the module name to the function’s bytecode signature (e.g.,parseConfiguration$my_module_name). If external Kotlin code attempts to call this mangled function, the Kotlin compiler will reject it during the compilation phase, enforcing the module boundary.
Master Kotlin with Deep Grasping Methodology!Learn More





