Skip to content

Always pass filename into AOT root scope creation#7292

Merged
headius merged 2 commits intojruby:jruby-9.3from
headius:dynamic_filename_for_aot
Aug 9, 2022
Merged

Always pass filename into AOT root scope creation#7292
headius merged 2 commits intojruby:jruby-9.3from
headius:dynamic_filename_for_aot

Conversation

@headius
Copy link
Member

@headius headius commented Aug 5, 2022

The filename from which a script is loaded can change after that
script has been AOT compiled to either serialized IR or JVM
bytecode formats. Previous commits broke this dynamic filename
handling by hardcoding the filename into the serialized IR and JVM
bytecode, causing #7211.

This commit reinstates the dynamic filename by passing it through
from load logic to the root scope creation, and removing the
hardcoded filenames produced by both AOT forms.

Note that one path has always been broken and remains broken: the
JVM main entry point provided to run a script directly as a Java
class. There is no way to reliably determine the real path of the
main class, so it continues to hardcode the original filename
(which is similar to javac embedding the original filename of a
compiled Java source file).

Fixes #7211

The filename from which a script is loaded can change after that
script has been AOT compiled to either serialized IR or JVM
bytecode formats. Previous commits broke this dynamic filename
handling by hardcoding the filename into the serialized IR and JVM
bytecode, causing jruby#7211.

This commit reinstates the dynamic filename by passing it through
from load logic to the root scope creation, and removing the
hardcoded filenames produced by both AOT forms.

Note that one path has always been broken and remains broken: the
JVM `main` entry point provided to run a script directly as a Java
class. There is no way to reliably determine the real path of the
main class, so it continues to hardcode the original filename
(which is similar to javac embedding the original filename of a
compiled Java source file).

Fixes jruby#7211
@headius headius force-pushed the dynamic_filename_for_aot branch from c0ddfe9 to b88a8e6 Compare August 9, 2022 15:45
@headius headius merged commit a34105a into jruby:jruby-9.3 Aug 9, 2022
@headius headius deleted the dynamic_filename_for_aot branch August 9, 2022 17:57
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.

1 participant