[Test] Don't use stdlib from dist in `JavaModulesIntegrationTest`
diff --git a/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithExplicitDependency.txt b/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithExplicitDependency.txt
index d86bac9..f11ca36 100644
--- a/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithExplicitDependency.txt
+++ b/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithExplicitDependency.txt
@@ -1 +1,2 @@
+dist/kotlinc/lib/kotlin-stdlib.jar: warning: the root is ignored because a module with the same name 'kotlin.stdlib' has been found earlier on the module path at: $USER_DIR$/libraries/stdlib/build/libs/kotlin-stdlib-$VERSION$.jar
 OK
diff --git a/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithIndirectDependencyViaOtherModule.txt b/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithIndirectDependencyViaOtherModule.txt
index d86bac9..f11ca36 100644
--- a/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithIndirectDependencyViaOtherModule.txt
+++ b/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithIndirectDependencyViaOtherModule.txt
@@ -1 +1,2 @@
+dist/kotlinc/lib/kotlin-stdlib.jar: warning: the root is ignored because a module with the same name 'kotlin.stdlib' has been found earlier on the module path at: $USER_DIR$/libraries/stdlib/build/libs/kotlin-stdlib-$VERSION$.jar
 OK
diff --git a/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithIndirectDependencyViaReflect.txt b/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithIndirectDependencyViaReflect.txt
index d86bac9..f11ca36 100644
--- a/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithIndirectDependencyViaReflect.txt
+++ b/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithIndirectDependencyViaReflect.txt
@@ -1 +1,2 @@
+dist/kotlinc/lib/kotlin-stdlib.jar: warning: the root is ignored because a module with the same name 'kotlin.stdlib' has been found earlier on the module path at: $USER_DIR$/libraries/stdlib/build/libs/kotlin-stdlib-$VERSION$.jar
 OK
diff --git a/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency.txt b/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency.txt
index 9afa659..f6bc439 100644
--- a/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency.txt
+++ b/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency.txt
@@ -1,2 +1,3 @@
 compiler/tests-integration/testData/javaModules/dependencyOnStdlib/namedWithoutExplicitDependency/module-info.java: error: the Kotlin standard library is not found in the module graph. Please ensure you have the 'requires kotlin.stdlib' clause in your module definition
+dist/kotlinc/lib/kotlin-stdlib.jar: warning: the root is ignored because a module with the same name 'kotlin.stdlib' has been found earlier on the module path at: $USER_DIR$/libraries/stdlib/build/libs/kotlin-stdlib-$VERSION$.jar
 COMPILATION_ERROR
diff --git a/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/unnamed.txt b/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/unnamed.txt
index d86bac9..f11ca36 100644
--- a/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/unnamed.txt
+++ b/compiler/tests-integration/testData/javaModules/dependencyOnStdlib/unnamed.txt
@@ -1 +1,2 @@
+dist/kotlinc/lib/kotlin-stdlib.jar: warning: the root is ignored because a module with the same name 'kotlin.stdlib' has been found earlier on the module path at: $USER_DIR$/libraries/stdlib/build/libs/kotlin-stdlib-$VERSION$.jar
 OK
diff --git a/compiler/tests-integration/testData/javaModules/namedDoesNotReadAutomaticWithTransitiveStdlib/main.txt b/compiler/tests-integration/testData/javaModules/namedDoesNotReadAutomaticWithTransitiveStdlib/main.txt
index d86bac9..f11ca36 100644
--- a/compiler/tests-integration/testData/javaModules/namedDoesNotReadAutomaticWithTransitiveStdlib/main.txt
+++ b/compiler/tests-integration/testData/javaModules/namedDoesNotReadAutomaticWithTransitiveStdlib/main.txt
@@ -1 +1,2 @@
+dist/kotlinc/lib/kotlin-stdlib.jar: warning: the root is ignored because a module with the same name 'kotlin.stdlib' has been found earlier on the module path at: $USER_DIR$/libraries/stdlib/build/libs/kotlin-stdlib-$VERSION$.jar
 OK
diff --git a/compiler/tests-integration/testData/javaModules/namedDoesNotReadAutomaticWithUnrelatedNamed/main.txt b/compiler/tests-integration/testData/javaModules/namedDoesNotReadAutomaticWithUnrelatedNamed/main.txt
index d86bac9..f11ca36 100644
--- a/compiler/tests-integration/testData/javaModules/namedDoesNotReadAutomaticWithUnrelatedNamed/main.txt
+++ b/compiler/tests-integration/testData/javaModules/namedDoesNotReadAutomaticWithUnrelatedNamed/main.txt
@@ -1 +1,2 @@
+dist/kotlinc/lib/kotlin-stdlib.jar: warning: the root is ignored because a module with the same name 'kotlin.stdlib' has been found earlier on the module path at: $USER_DIR$/libraries/stdlib/build/libs/kotlin-stdlib-$VERSION$.jar
 OK
diff --git a/compiler/tests-integration/tests/org/jetbrains/kotlin/jvm/modules/JavaModulesIntegrationTest.kt b/compiler/tests-integration/tests/org/jetbrains/kotlin/jvm/modules/JavaModulesIntegrationTest.kt
index f40af53..3604afd 100644
--- a/compiler/tests-integration/tests/org/jetbrains/kotlin/jvm/modules/JavaModulesIntegrationTest.kt
+++ b/compiler/tests-integration/tests/org/jetbrains/kotlin/jvm/modules/JavaModulesIntegrationTest.kt
@@ -35,6 +35,7 @@
         additionalKotlinArguments: List<String> = emptyList(),
         manifest: Manifest? = null,
         destination: File? = null,
+        noStdlib: Boolean = true,
         checkKotlinOutput: (String) -> Unit = this.checkKotlinOutput(name),
     ): File {
         @Suppress("DEPRECATION")
@@ -44,8 +45,10 @@
             K2JVMCompilerArguments::jdkHome.cliArgument, jdkHome.path,
             K2JVMCompilerArguments::javaModulePath.cliArgument(paths),
             K2JVMCompilerArguments::suppressVersionWarnings.cliArgument,
-            K2JVMCompilerArguments::noStdlib.cliArgument,
         )
+        if (noStdlib) {
+            kotlinOptions += K2JVMCompilerArguments::noStdlib.cliArgument
+        }
         if (addModules.isNotEmpty()) {
             kotlinOptions += "-Xadd-modules=${addModules.joinToString()}"
         }
@@ -241,11 +244,11 @@
 
     @Suppress("DEPRECATION")
     fun testDependencyOnStdlib() {
-        module("unnamed")
-        val namedWithExplicitDependency = module("namedWithExplicitDependency")
-        module("namedWithoutExplicitDependency")
-        module("namedWithIndirectDependencyViaOtherModule", listOf(namedWithExplicitDependency))
-        module("namedWithIndirectDependencyViaReflect", listOf(ForTestCompileRuntime.reflectJarFromDistForTests()))
+        module("unnamed", noStdlib = false)
+        val namedWithExplicitDependency = module("namedWithExplicitDependency", noStdlib = false)
+        module("namedWithoutExplicitDependency", noStdlib = false)
+        module("namedWithIndirectDependencyViaOtherModule", listOf(namedWithExplicitDependency), noStdlib = false)
+        module("namedWithIndirectDependencyViaReflect", listOf(ForTestCompileRuntime.reflectJarFromDistForTests()), noStdlib = false)
     }
 
     fun testDependencyOnStdlibJdk78() {
@@ -326,14 +329,14 @@
         // But currently it's OK for compatibility, see KT-66622.
         val lib = module("lib")
         val unrelated = module("unrelated")
-        module("main", listOf(lib, unrelated))
+        module("main", listOf(lib, unrelated), noStdlib = false)
     }
 
     fun testNamedDoesNotReadAutomaticWithTransitiveStdlib() {
         // This test should result in an error because 'main' does not depend on 'lib' or any other automatic module.
         // But currently it's OK for compatibility, see KT-66622.
         val lib = module("lib")
-        module("main", listOf(lib))
+        module("main", listOf(lib), noStdlib = false)
     }
 
     fun testNamedReadsAutomaticWithUnrelatedAutomatic() {