Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix zinc binary dependencies #1904

Merged
merged 2 commits into from
Jun 24, 2022
Merged

Conversation

jilen
Copy link
Contributor

@jilen jilen commented Jun 23, 2022

Fix #1901
Sbt use a MappedFileConverter, it will converter jdk internal classes like /module/java.base/java.lang.String associated with a dummpy rt.jar.
https://github.com/sbt/zinc/blob/57d03412abe3810be5762a8c8e8c55cbf622ed03/internal/zinc-core/src/main/scala/sbt/internal/inc/MappedVirtualFile.scala#L56

def toVirtualFile(path: Path): VirtualFile = {
    rootPaths2.find { case (_, rootPath) => path.startsWith(rootPath) } match {
      case Some((key, rootPath)) =>
        MappedVirtualFile(s"$${$key}/${rootPath.relativize(path)}".replace('\\', '/'), rootPaths)
      case _ =>
        def isCtSym =
          path.getFileSystem
            .provider()
            .getScheme == "jar" && path.getFileSystem.toString.endsWith("ct.sym")
        def isJrt = path.getFileSystem.provider().getScheme == "jrt"
        if (isJrt || path.getFileName.toString == "rt.jar" || isCtSym)
          DummyVirtualFile("rt.jar", path)
        else if (allowMachinePath) MappedVirtualFile(s"$path".replace('\\', '/'), rootPaths)
        else sys.error(s"$path cannot be mapped using the root paths $rootPaths")
    }
  }

And later the Incremental will exclude such binary dependencies.
https://github.com/sbt/zinc/blob/57d03412abe3810be5762a8c8e8c55cbf622ed03/internal/zinc-core/src/main/scala/sbt/internal/inc/Incremental.scala#L783

        // dependency is some other binary on the classpath.
        // exclude dependency tracking with rt.jar, for example java.lang.String -> rt.jar.
        if (!vf.id.endsWith("rt.jar")) {
          externalLibraryDependency(
            vf,
            onBinaryName,
            sourceFile,
            context
          )
        }

@jilen jilen changed the title fix zinc dynamic dependencies fix zinc binary dependencies Jun 23, 2022
@jilen jilen force-pushed the fix_zinc_binary_dep branch 3 times, most recently from 862e366 to 5f68ded Compare June 23, 2022 05:02
@lefou
Copy link
Member

lefou commented Jun 23, 2022

About the test failures. I just created

which fixes an ordering issue in a test, which just popped up for some days. Once it is merged, we can rebase/merge your PR to get CI green.

@lefou
Copy link
Member

lefou commented Jun 23, 2022

I also created

which should succeed after we apply this fix.

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add some details to this PR description. Esp. a motivation for the solution. Also, where does the hard-coded rt.jar comes from?

@lefou
Copy link
Member

lefou commented Jun 23, 2022

Oh, I forgot, this PR indeed seems to fix the issue. #1907 runs successfully.

@lefou lefou merged commit 42d72a6 into com-lihaoyi:main Jun 24, 2022
@lefou lefou added this to the after 0.10.4 milestone Jun 24, 2022
@lefou
Copy link
Member

lefou commented Jun 24, 2022

Thank you!

lefou added a commit that referenced this pull request Jun 24, 2022
Regression test, making sure Zinc incremental compilation only compile changed files.

Related to

* #1901
* #1904

Pull request: #1907
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect zinc modified binary dependencies
2 participants