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

Implement an ijar equivalent for Scala 3 #1679

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jadenPete
Copy link

Description

From my comment in #1657:

From what I understand, though, TASTy markes a major shift in how type information is stored between compiler invocations from Scala 2.13's "Pickle" format in that it includes a completely typed representation of the program's AST. I'm of the opinion that this defeats the purpose of using ijar, since most changes to a program's source code will now induce changes in its TASTy files, thus changing the generated ijar and invalidating reverse dependencies' cached compilation actions.

When you consider that and the fact that "scalac doesn’t have to read their .class files anymore; it can read their .tasty files", it may make more sense to develop an alternative to ijar specially for Scala 3 targets, as opposed to modifying ijar. That way, we can strip out information from TASTy files not needed for compilation (e.g. positional information, documentation, private members, etc.), similar to what @susliko described.

Given these changes in how symbols are read from the compile classpath in Scala 3 vs Scala 2, I don't think ijar is an appropriate solution for producing Scala 3 interface JARs. For that reason, I've developed "dottyijar", a version of ijar that produces an interface JAR by removing all .class files and performing a few modifications to .tasty files:

  • Clearing the UUID, "Positions" section, and "Comments" section
  • Removing all val and def definitions that are private and not inline
  • Replace the values of all val and def definitions and class parent arguments with ???
  • Remove unused names from the name table

For context on the TASTy format, see dotty.tools.tasty.TastyFormat.

Thus, dottyijar produces interface JARs that are far less sensitive to implementation changes than those produced by ijar. Although it's not as fast as ijar (mainly because it's written in Scala and doesn't read and write in a single pass), it's very fast—dottyijar produced an interface JAR for the Scala 3 compiler, which contains 1,011 TASTy files, in 4.369 seconds on my machine, whereas ijar took 0.292 seconds.

Motivation

I'm implementing this change to close #1657.

Jaden Peterson added 5 commits January 15, 2025 00:05
Different versions of specs2 support different Scala versions, so it's
necessary to use a different version, depending on which Scala version
we're on. v4.10.6 is the last to support Scala 2.11, v4.20.9 is the last
to support Scala 2, and the latest version as of the time this commit
was written, v5.5.8, only supports Scala 3.
Currently, it just strips private `val`s and `def`s and definition
values, but I plan on making it more aggresive in the future.
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.

Better caching for Scala 3 (via ijar or tasty inspection)
1 participant