以下测试在 JDK 8 下成功,但在 OpenJDK 10 下失败。
JDK 10 是否需要使用不同的类加载器来允许我遍历类路径?
class ExamplesTest {
companion object {
private val currentPackage = ExamplesTest::class.java.`package`.name
}
fun `examples test`() {
val allTopLevelClasses =
ClassPath
.from(Thread.currentThread().contextClassLoader)
.getTopLevelClasses(currentPackage)
assertThat("Should not be empty", allTopLevelClasses, !isEmpty)
}
}
java --version
openjdk 10.0.2 2018-07-17
OpenJDK Runtime Environment 18.3 (build 10.0.2+13)
OpenJDK 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)