Next code fails at runtime if compiled against JDK 12 and runned with lower version of JDK (but work if compiled with JDK 11 and below)
object Foo {
def main(args: Array[String]): Unit = {
new Foo(classOf[Foo])
}
}
class Foo(val clazz: Class[_]) {
private var result = if (clazz.getEnclosingConstructor == null) clazz
else "123"
}
Error: Unable to initialize main class Foo
Caused by: java.lang.NoClassDefFoundError: java/lang/constant/Constable
'Constable' was added in JDK 12