Skip to content

Fix TastyPrinter's JAR-walking logic to include subdirectories - #25678

Merged
SolalPirelli merged 1 commit into
scala:mainfrom
dotty-staging:s/i4
Apr 1, 2026
Merged

Fix TastyPrinter's JAR-walking logic to include subdirectories#25678
SolalPirelli merged 1 commit into
scala:mainfrom
dotty-staging:s/i4

Conversation

@SolalPirelli

Copy link
Copy Markdown
Contributor

Previously it only looked at tasty files at the root of the JAR. I'm not sure if anyone uses this code.

How much have you relied on LLM-based tools in this contribution?

not

How was the solution tested?

it wasn't

@SolalPirelli
SolalPirelli requested a review from mbovel April 1, 2026 13:21

@mbovel mbovel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems to make sense at first sight.

JarArchive extends PlainDirectory:

class JarArchive private (val jarPath: Path, root: Directory) extends PlainDirectory(root) {

Which define iterator:

override def iterator: Iterator[PlainFile] = givenPath.list.filter(_.exists).map(new PlainFile(_))

Which uses Directory.list:

/** An iterator over the contents of this directory.
*/
def list: Iterator[Path] =
if (isDirectory) {
val fileStream = Files.list(jpath)
val files = fileStream.toArray(size => new Array[JPath](size))
fileStream.close()
files.iterator.map(Path.apply)
}
else Iterator.empty

While allFileNames uses nio.file.Files.walk:

def allFileNames(): Iterator[String] =
java.nio.file.Files.walk(jpath).iterator().asScala.map(_.toString)


it wasn't

Could it?

@mbovel
mbovel self-requested a review April 1, 2026 14:22
@SolalPirelli
SolalPirelli merged commit 6010a7f into scala:main Apr 1, 2026
64 checks passed
@SolalPirelli
SolalPirelli deleted the s/i4 branch April 1, 2026 15:11
@WojciechMazur WojciechMazur added this to the 3.8.4 milestone May 10, 2026
@WojciechMazur WojciechMazur added the backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it. label May 10, 2026
@WojciechMazur WojciechMazur added backport:accepted This PR needs to be backported, once it's been backported replace this tag by "backport:done" and removed backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it. labels May 10, 2026
WojciechMazur added a commit that referenced this pull request May 11, 2026
â€Ķies" to 3.8.4 (#26041)

Backports #25678 to the 3.8.4-RC2.

PR submitted by the release tooling.
[skip ci]
@WojciechMazur WojciechMazur added backport:done This PR was successfully backported. and removed backport:accepted This PR needs to be backported, once it's been backported replace this tag by "backport:done" labels May 11, 2026
val jar = JarArchive.open(Path(arg), create = false)
try
for file <- jar.iterator if file.hasTastyExtension do
for file <- jar.allFileNames().map(f => new PlainFile(Path(f))) if file.hasTastyExtension do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am having issue when backporting and I don't understand how can this work ðŸĪ”

Path(f) shouldn't correspond to the host filesystem instead of the jar file system?

Getting an exception on lts-3.3 because of this change:
Exception in thread "main" java.nio.file.NoSuchFileException: /App.tasty
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:218)
at java.base/java.nio.file.Files.newByteChannel(Files.java:380)
at java.base/java.nio.file.Files.newByteChannel(Files.java:432)
at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:422)
at java.base/java.nio.file.Files.newInputStream(Files.java:160)
at dotty.tools.io.File.inputStream(File.scala:53)
at dotty.tools.io.PlainFile.input(PlainFile.scala:70)
at dotty.tools.io.AbstractFile.toByteArray(AbstractFile.scala:172)
at dotty.tools.dotc.core.tasty.TastyPrinter$.main$$anonfun$1$$anonfun$3(TastyPrinter.scala:60)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:630)
at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:628)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

tbh this was one of the ostif bugs and when applying their recommended fix I wasn't sure if this code was even used anywhere.

But yeah you're right creating the file outside the jar doesn't make all that much sense.

What test/command are you running to trigger this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure, it's failing on CI https://github.com/scala/scala3-lts/actions/runs/25926858931/job/76210327085?pr=905

I think it's some of the scripted tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it might be removed in main, which would explain why it's not triggered.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

project/scripts/bootstrappedOnlyCmdTests is probably what fails

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Checking an alternative fix in scala@0835a90

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah that alternative seems more reasonable. I'll look into why this didn't cause trouble in main.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can make that fix in the main as well, what do you think? OR do you want to handle it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll handle it in #26082 along with whatever else might be needed to make those tests pass. Sorry for the bother.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no worries, thanks for the help!

tgodzik added a commit that referenced this pull request May 26, 2026
Previously it only looked at tasty files at the root of the JAR. I'm not
sure if anyone uses this code.

## How much have you relied on LLM-based tools in this contribution?

not

## How was the solution tested?

it wasn't
[Cherry-picked 6010a7f][modified]
alexarchambault pushed a commit to plasmon-scala/scala3 that referenced this pull request Jun 16, 2026
â€Ķ#25678)

Previously it only looked at tasty files at the root of the JAR. I'm not
sure if anyone uses this code.

## How much have you relied on LLM-based tools in this contribution?

not

## How was the solution tested?

it wasn't
[Cherry-picked 6010a7f]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:done This PR was successfully backported.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants