Skip to content

Conversation

@liufengyun
Copy link
Contributor

Fix #9642: fix bootstrapping on Windows

@liufengyun liufengyun force-pushed the fix-9642 branch 3 times, most recently from 44a4158 to 598fcd2 Compare August 26, 2020 10:00
@liufengyun liufengyun mentioned this pull request Aug 26, 2020
@liufengyun liufengyun marked this pull request as ready for review August 27, 2020 16:31
@liufengyun
Copy link
Contributor Author

test performance please

@dottybot
Copy link
Member

performance test scheduled: 1 job(s) in queue, 0 running.

@dottybot
Copy link
Member

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/9644/ to see the changes.

Benchmarks is based on merging with master (757e431)

`dirPathTrailingSlash` is used both in `DirectoryPath` and `ZipArchiveFileLookup`,
the former is platform-depndent, while the latter always uses `/` as separator.

Previously, the code works by accident: `new JFile(dir, path)` and `dir.resolve(path)`
are able to handle `path = "java/lang"` on windows.
if (java.io.File.separatorChar == '/')
dirPathTrailingSlashJar
else
FileUtils.dirPath(dottedString) + java.io.File.separator
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if this is too cautious. One justification for the duplication is to save hours of debugging for future maintainers.

WDYT @sjrd ?

Copy link
Member

Choose a reason for hiding this comment

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

If this file name is used for lookup only, then it can be / on all platforms, including Windows. Java can find files that you specify with / as if they were \.

Where it breaks down is when listing files, then comparing their paths to some other data where you always have /, or if you split('/'). Because Windows will give you \, which won't be compared/split correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is the worry I have. String paths like a/b/c on windows are mines: if they are accidentally spliced to form a bigger string path, errors are guaranteed. Currently (before this commit), they already leak to DirectoryPath, and works accidentally.

@liufengyun liufengyun merged commit d828648 into scala:master Aug 28, 2020
@liufengyun liufengyun deleted the fix-9642 branch August 28, 2020 08:47
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.

The bootstrapped build is broken on Windows after #9615

3 participants