Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Do not embed absolute path into class files when -Xcheckinit flag is used #10237

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

Merged
merged 1 commit into from
Dec 8, 2022

Conversation

rtar
Copy link
Contributor

@rtar rtar commented Dec 7, 2022

Fixes scala/bug#12698

It changes the code emitted when -Xcheckinit flag is used. The result of this fix will be that instead of emitting something like this:

ldc 'Uninitialized field: /home/ruslan/xcheckinit/CheckInit.scala: 2'

The following code will be emitted:

ldc 'Uninitialized field: CheckInit.scala: 2'

This will make sure that the classes do not contain absolute path embedded into them anymore.

It will allow to build such objects on another machine, with different directory structure, without changing the resulting artifact.

The potential issues

  • The error message will change, and might not be as easy to digest for IDE when running tests.
  • I did not check if there any other places under other flags embedding the absolute path in a similar manner. It might be worth to check if there are other places.

Possible alternatives
It might be possible to introduce the flag changing the behavior and, potentially, controlling other places if such issue to occur in these places. I.e. -Xreproducible or -Xstripabsolutepaths, or something like that.

Also see scala/scala-dev#405 for more discussion on why having reproducible builds is good.

@scala-jenkins scala-jenkins added this to the 2.13.11 milestone Dec 7, 2022
@rtar rtar changed the title Do not embed absolute path into class files Do not embed absolute path into class files when -Xcheckinit flag is used Dec 7, 2022
Copy link
Member

@lrytz lrytz left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

The change doesn't reflect in the existing tests because our test tool (partest) strips off file paths from test output, so the check file already has the right format (https://github.com/scala/scala/blob/2.13.x/test/files/run/checkinit.check).

Running the test manually shows the difference.

@lrytz lrytz merged commit f8d3c4d into scala:2.13.x Dec 8, 2022
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.

scalac embeds absolute file path into class files when -Xcheckinit flag is used
3 participants