diff --git a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt index 58c7f966ab1..f4ff3e8ab0f 100644 --- a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt +++ b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt @@ -211,8 +211,17 @@ private fun processCLib(args: Array, additionalArgs: Map = val outKtPkg = fqParts.joinToString(".") - val mode = parseGenerationMode(cinteropArguments.mode) - ?: error ("Unexpected interop generation mode: ${cinteropArguments.mode}") + val mode = run { + val providedMode = parseGenerationMode(cinteropArguments.mode) + ?: error ("Unexpected interop generation mode: ${cinteropArguments.mode}") + + if (providedMode == GenerationMode.METADATA && flavor == KotlinPlatform.JVM) { + warn("Metadata mode isn't supported for Kotlin/JVM! Falling back to sourcecode.") + GenerationMode.SOURCE_CODE + } else { + providedMode + } + } val allLibraryDependencies = when (flavor) { KotlinPlatform.NATIVE -> resolveDependencies(cinteropArguments, tool.target) diff --git a/build-tools/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy b/build-tools/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy index 56f7e9f84a7..d7e73fa50ce 100644 --- a/build-tools/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy +++ b/build-tools/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy @@ -225,6 +225,9 @@ class NamedNativeInteropConfig implements Named { args '-natives', nativeLibsDir args '-Xtemporary-files-dir', temporaryFilesDir args '-flavor', this.flavor + if (flavor == "jvm") { + args '-mode', 'sourcecode' + } // Uncomment to debug. // args '-verbose', 'true'