Extract Java 9 module test about irrelevant jars in JDK home
Skip it on JDKs where ant-javafx.jar is not present.
This commit is contained in:
+3
@@ -0,0 +1,3 @@
|
|||||||
|
module main {
|
||||||
|
requires kotlin.stdlib;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun main() {
|
||||||
|
val x: com.sun.javafx.tools.ant.AntLog? = null
|
||||||
|
println(x)
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun main() {
|
||||||
|
val x: com.sun.javafx.tools.ant.AntLog? = null
|
||||||
|
println(x)
|
||||||
|
}
|
||||||
@@ -14,20 +14,4 @@ public inline fun println(message: Long): Unit defined in kotlin.io
|
|||||||
public inline fun println(message: Short): Unit defined in kotlin.io
|
public inline fun println(message: Short): Unit defined in kotlin.io
|
||||||
println(s)
|
println(s)
|
||||||
^
|
^
|
||||||
compiler/testData/javaModules/jdkModulesFromNamed/main/test.kt:19:20: error: unresolved reference: javafx
|
|
||||||
val x: com.sun.javafx.tools.ant.AntLog? = null
|
|
||||||
^
|
|
||||||
compiler/testData/javaModules/jdkModulesFromNamed/main/test.kt:20:5: error: overload resolution ambiguity:
|
|
||||||
public inline fun println(message: Any?): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Boolean): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Byte): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Char): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: CharArray): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Double): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Float): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Int): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Long): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Short): Unit defined in kotlin.io
|
|
||||||
println(x)
|
|
||||||
^
|
|
||||||
COMPILATION_ERROR
|
COMPILATION_ERROR
|
||||||
|
|||||||
@@ -14,8 +14,4 @@ fun main(args: Array<String>) {
|
|||||||
// Module oracle.desktop
|
// Module oracle.desktop
|
||||||
val a: com.oracle.awt.AWTUtils? = null
|
val a: com.oracle.awt.AWTUtils? = null
|
||||||
println(a)
|
println(a)
|
||||||
|
|
||||||
// No module, this class is declared in $JDK_9/lib/ant-javafx.jar
|
|
||||||
val x: com.sun.javafx.tools.ant.AntLog? = null
|
|
||||||
println(x)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1 @@
|
|||||||
compiler/testData/javaModules/jdkModulesFromUnnamed/main/test.kt:19:33: error: unresolved reference: ant
|
OK
|
||||||
val x: com.sun.javafx.tools.ant.AntLog? = null
|
|
||||||
^
|
|
||||||
compiler/testData/javaModules/jdkModulesFromUnnamed/main/test.kt:20:5: error: overload resolution ambiguity:
|
|
||||||
public inline fun println(message: Any?): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Boolean): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Byte): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Char): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: CharArray): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Double): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Float): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Int): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Long): Unit defined in kotlin.io
|
|
||||||
public inline fun println(message: Short): Unit defined in kotlin.io
|
|
||||||
println(x)
|
|
||||||
^
|
|
||||||
COMPILATION_ERROR
|
|
||||||
|
|||||||
@@ -14,8 +14,4 @@ fun main(args: Array<String>) {
|
|||||||
// Module oracle.desktop
|
// Module oracle.desktop
|
||||||
val a: com.oracle.awt.AWTUtils? = null
|
val a: com.oracle.awt.AWTUtils? = null
|
||||||
println(a)
|
println(a)
|
||||||
|
|
||||||
// No module, this class is declared in $JDK_9/lib/ant-javafx.jar
|
|
||||||
val x: com.sun.javafx.tools.ant.AntLog? = null
|
|
||||||
println(x)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,12 @@ class Java9ModulesIntegrationTest : AbstractKotlinCompilerIntegrationTest() {
|
|||||||
get() = "compiler/testData/javaModules/"
|
get() = "compiler/testData/javaModules/"
|
||||||
|
|
||||||
private fun module(
|
private fun module(
|
||||||
name: String,
|
name: String,
|
||||||
modulePath: List<File> = emptyList(),
|
modulePath: List<File> = emptyList(),
|
||||||
addModules: List<String> = emptyList(),
|
addModules: List<String> = emptyList(),
|
||||||
additionalKotlinArguments: List<String> = emptyList(),
|
additionalKotlinArguments: List<String> = emptyList(),
|
||||||
manifest: Manifest? = null
|
manifest: Manifest? = null,
|
||||||
|
checkKotlinOutput: (String) -> Unit = this.checkKotlinOutput(name),
|
||||||
): File {
|
): File {
|
||||||
val paths = (modulePath + ForTestCompileRuntime.runtimeJarForTests()).joinToString(separator = File.pathSeparator) { it.path }
|
val paths = (modulePath + ForTestCompileRuntime.runtimeJarForTests()).joinToString(separator = File.pathSeparator) { it.path }
|
||||||
|
|
||||||
@@ -38,21 +39,21 @@ class Java9ModulesIntegrationTest : AbstractKotlinCompilerIntegrationTest() {
|
|||||||
kotlinOptions += additionalKotlinArguments
|
kotlinOptions += additionalKotlinArguments
|
||||||
|
|
||||||
return compileLibrary(
|
return compileLibrary(
|
||||||
name,
|
name,
|
||||||
additionalOptions = kotlinOptions,
|
additionalOptions = kotlinOptions,
|
||||||
compileJava = { _, javaFiles, outputDir ->
|
compileJava = { _, javaFiles, outputDir ->
|
||||||
val javaOptions = mutableListOf(
|
val javaOptions = mutableListOf(
|
||||||
"-d", outputDir.path,
|
"-d", outputDir.path,
|
||||||
"--module-path", paths
|
"--module-path", paths
|
||||||
)
|
)
|
||||||
if (addModules.isNotEmpty()) {
|
if (addModules.isNotEmpty()) {
|
||||||
javaOptions += "--add-modules"
|
javaOptions += "--add-modules"
|
||||||
javaOptions += addModules.joinToString()
|
javaOptions += addModules.joinToString()
|
||||||
}
|
}
|
||||||
KotlinTestUtils.compileJavaFilesExternallyWithJava9(javaFiles, javaOptions)
|
KotlinTestUtils.compileJavaFilesExternallyWithJava9(javaFiles, javaOptions)
|
||||||
},
|
},
|
||||||
checkKotlinOutput = checkKotlinOutput(name),
|
checkKotlinOutput = checkKotlinOutput,
|
||||||
manifest = manifest
|
manifest = manifest
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,4 +275,20 @@ class Java9ModulesIntegrationTest : AbstractKotlinCompilerIntegrationTest() {
|
|||||||
assertEquals("", stderr)
|
assertEquals("", stderr)
|
||||||
assertEquals("OK", stdout)
|
assertEquals("OK", stdout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testDoNotLoadIrrelevantJarsFromUnnamed() {
|
||||||
|
// This test checks that we don't load irrelevant .jar files from the JDK distribution when resolving JDK dependencies.
|
||||||
|
// Here we're testing that references to symbols from lib/ant-javafx are unresolved, if that file is present.
|
||||||
|
// The test succeeds though even if the file is absent, because it's not guaranteed to be present in JDK.
|
||||||
|
module("main", checkKotlinOutput = {
|
||||||
|
assertTrue(it, it.trimEnd().endsWith("COMPILATION_ERROR"))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testDoNotLoadIrrelevantJarsFromNamed() {
|
||||||
|
// See the comment in testDoNotLoadIrrelevantJarsFromUnnamed.
|
||||||
|
module("main", checkKotlinOutput = {
|
||||||
|
assertTrue(it, it.trimEnd().endsWith("COMPILATION_ERROR"))
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user