Java/Kotlin Interop
JVM compatibility
Section titled “JVM compatibility”Skotch produces standard Java 17 class files (major version 61).
Compiled .class files run on any JVM that supports Java 17 or later.
Top-level Kotlin functions are compiled to static methods on a wrapper
class named after the source file (e.g., main.kt → MainKt). This
matches the convention used by JetBrains’ kotlinc.
skotch emit --target jvm hello.kt -o HelloKt.classjava -cp . HelloKtDEX compatibility
Section titled “DEX compatibility”Skotch produces DEX v035 bytecode, compatible with Android API 13+. The output can be included in an APK and run on Android devices or emulators.
Calling Java static methods
Section titled “Calling Java static methods”Skotch supports calling static methods on well-known Java classes directly:
fun main() { val timestamp = System.currentTimeMillis() println(timestamp)
println(Math.abs(-42)) // 42 println(Math.max(10, 20)) // 20 println(Integer.parseInt("123")) // 123}This also works in the REPL:
skotch> println(System.currentTimeMillis())1744385123456Fully-qualified names
Section titled “Fully-qualified names”You can also use fully-qualified Java class names:
fun main() { println(java.lang.System.getProperty("file.separator")) println(java.lang.Math.random())}Import statements
Section titled “Import statements”Explicit imports are supported:
import java.lang.Mathimport java.lang.Integer
fun main() { println(Math.abs(-42)) println(Integer.parseInt("123"))}java.lang.* is implicitly imported, matching Kotlin’s default imports.
Supported Java classes
Section titled “Supported Java classes”| Class | Methods | Notes |
|---|---|---|
System | currentTimeMillis(), nanoTime(), exit(Int), getProperty(String), getenv(String) | java.lang.System |
Math | abs(Int), max(Int,Int), min(Int,Int), random(), sqrt(Double), pow(Double,Double) | java.lang.Math |
Integer | parseInt(String), toString(Int), valueOf(Int) | java.lang.Integer |
Long | parseLong(String) | java.lang.Long |
String | valueOf(Int) | java.lang.String |
Thread | sleep(Long) | java.lang.Thread |
Current limitations
Section titled “Current limitations”| Feature | Status |
|---|---|
| Calling arbitrary Java libraries | JDK classes resolved from jmod files; CLASSPATH JARs/dirs scanned |
import package.Class | Working — resolves class names for static calls |
import package.* | Parsed but classes not enumerated (hardcoded set only) |
| External dependency resolution | Not yet — Maven/Gradle deps ignored |
| Kotlin standard library | Not bundled; println is a compiler intrinsic |
| Reflection | Not supported |
| Annotations | Not yet compiled |
What works today
Section titled “What works today”- Compiled
.classfiles are valid Java bytecode and can be loaded by standard JVM tools (java,javap,jstack, etc.) - The REPL executes compiled code in an embedded JVM via JNI
- Multiple Skotch-compiled files can call each other’s functions via
invokestatic - Static method calls on
System,Math,Integer, andStringviainvokestatic