Skip to content

Running multiple fastOptJS causes java.lang.NoClassDefFoundError: jdk/internal/reflect/MethodAccessorImpl #3921

@xerial

Description

@xerial

Symptom:

  • MethodAccessorImpl NoClassDefError happens with Scala.js 1.0.0-RC2, when compiling multiple Scala.JS projects. We have no such issue with Scala.js 0.6.x
  • After rerunning fastOptJS, the compilation eventually succeeds.
  • I'm using sbt 1.3.6 and JDK11. The same error happens with JDK8.

image

It might be an issue of sbt-scalajs plugin and sbt-1.3.x's new classloader. (The same problem happens with sbt 1.2.8) I'll work on reproduction of this issue.

It seems the reflection call of PathOutputFile in the LinkerImpl is failing:

    private val outputFileMethod =
      loadMethod("PathOutputFile", "atomic", classOf[LinkerOutput.File], classOf[Path])

This is used here:

            val out = LinkerOutput(linkerImpl.outputFile(output.toPath))
              .withSourceMap(linkerImpl.outputFile(sourceMapFile.toPath)) <--------
              .withSourceMapURI(relURI(sourceMapFile.getName))
              .withJSFileURI(relURI(output.getName))

A workaround is splitting an aggregated project into a smaller set of projects and running fastOptJS individually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bug. Needs to be fixed.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions