diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt index 8f5e1e9bcfe..e122148c8c5 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt @@ -43,10 +43,12 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu put(JVMConfigurationKeys.JDK_RELEASE, value) } if (jvmTargetArg != null && !isCompatibleJvmTargetAndRelease(jvmTargetArg, releaseTargetArg)) { + val suggestion = + if (value < 8) "Please change the value of the 'jvm-target' option to 1.8" + else "Please remove the '-jvm-target' option" messageCollector.report( ERROR, - "'-Xjdk-release=$releaseTargetArg' option conflicts with '-jvm-target $jvmTargetArg'. " + - "Please remove the '-jvm-target' option" + "'-Xjdk-release=$releaseTargetArg' option conflicts with '-jvm-target $jvmTargetArg'. $suggestion" ) } } @@ -57,7 +59,8 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu if (jvmTargetArg == null) { messageCollector.report( ERROR, - "'-Xjdk-release=$releaseTargetArg' option requires explicit JVM target. Please specify the '-jvm-target' option" + "'-Xjdk-release=$releaseTargetArg' option requires JVM target explicitly set to 1.8. " + + "Please specify the '-jvm-target' option" ) } jvmTargetArg diff --git a/compiler/testData/cli/jvm/jdkRelease6WithJvmTarget9.args b/compiler/testData/cli/jvm/jdkRelease6WithJvmTarget9.args new file mode 100644 index 00000000000..361de139499 --- /dev/null +++ b/compiler/testData/cli/jvm/jdkRelease6WithJvmTarget9.args @@ -0,0 +1,8 @@ +-Xjdk-release=1.6 +-jvm-target +9 +-jdk-home +$JDK_11_0 +$TESTDATA_DIR$/jdkRelease.kt +-d +$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/jdkRelease6WithJvmTarget9.out b/compiler/testData/cli/jvm/jdkRelease6WithJvmTarget9.out new file mode 100644 index 00000000000..2b947f1aad9 --- /dev/null +++ b/compiler/testData/cli/jvm/jdkRelease6WithJvmTarget9.out @@ -0,0 +1,2 @@ +error: '-Xjdk-release=1.6' option conflicts with '-jvm-target 9'. Please change the value of the 'jvm-target' option to 1.8 +COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/jdkRelease6WithoutExplicitJvmTarget.out b/compiler/testData/cli/jvm/jdkRelease6WithoutExplicitJvmTarget.out index ec15deca066..83595f9c3b7 100644 --- a/compiler/testData/cli/jvm/jdkRelease6WithoutExplicitJvmTarget.out +++ b/compiler/testData/cli/jvm/jdkRelease6WithoutExplicitJvmTarget.out @@ -1,2 +1,2 @@ -error: '-Xjdk-release=1.6' option requires explicit JVM target. Please specify the '-jvm-target' option +error: '-Xjdk-release=1.6' option requires JVM target explicitly set to 1.8. Please specify the '-jvm-target' option COMPILATION_ERROR diff --git a/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java index 70c5424c474..dd4c43f561e 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java @@ -775,6 +775,11 @@ public class CliTestGenerated extends AbstractCliTest { runTest("compiler/testData/cli/jvm/jdkRelease6WithJvmTarget8Jdk8.args"); } + @TestMetadata("jdkRelease6WithJvmTarget9.args") + public void testJdkRelease6WithJvmTarget9() { + runTest("compiler/testData/cli/jvm/jdkRelease6WithJvmTarget9.args"); + } + @TestMetadata("jdkRelease6WithoutExplicitJvmTarget.args") public void testJdkRelease6WithoutExplicitJvmTarget() { runTest("compiler/testData/cli/jvm/jdkRelease6WithoutExplicitJvmTarget.args");