Skip to content

Compiling with JDK 12 causes runtime crash under JDK 11 #11398

@max-kammerer

Description

@max-kammerer

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions