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

Failure to use jar file produced by 'scala -savecompiled' #15180

Closed
lilyevsky opened this issue May 13, 2022 · 3 comments
Closed

Failure to use jar file produced by 'scala -savecompiled' #15180

lilyevsky opened this issue May 13, 2022 · 3 comments
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label

Comments

@lilyevsky
Copy link

Compiler version 3.1.2

If I use 'scala -savecompiled ....' when running a scala script, it properly produces the jar file. It is expected that on the second run it would use that jar file in order to speed up execution, but it is not happening.

I clearly see this by timing the execution: in my example the run using scala runner always takes around 7 seconds, while direct run using 'java -jar ...' takes less than 0.5 seconds.

As a workaround, I wrote a shell script that compares files timestamps and based on that decides how to run the script.

According to http://www.mit.edu/afs.new/sipb/project/scala/scala/scala-2.10.0/doc/tools/scala.html , this feature used to work before in 2.10 version.

Related documentation issue: if I run 'scala --help', I don't even see any mentioning of '-savecompile'. So I wonder what is the story here - maybe this feature is not yet fully implemented?

@lilyevsky lilyevsky added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 13, 2022
@SethTisue
Copy link
Member

SethTisue commented May 13, 2022

-savecompiled (aka -save) support landed in #11379; fyi @philwalk

note that scala-cli is the new hotness in this general area

@philwalk
Copy link
Contributor

philwalk commented May 14, 2022

@lilyevsky - the feature is fully implemented, with one exception: -save cannot currently be used with scripts that reference any java classes not in module java.base. The problem only appears when running from the compiled jar. See #13760.
The problem seems to be fixed by #15103 which is being reviewed.

@lilyevsky
Copy link
Author

@philwalk Thanks for your comment; however, I believe you are talking about different issue.
My issue was, when using '-savecompiled', it runs, but on the second run it compiles it again.

Luckily, I found the source of the problem.
@SethTisue mentioned

-savecompiled (aka -save) ....

These two options are not the same! It occurred to me just to try '-save', and it worked as expected.

So I will close this issue, but I would expect some sort of minor fix in the future version:

  1. Add the '-save' option to the output of help text (and maybe some others that are missing).
  2. Remove '-savecompiled' completely, or at least add it to the help and explain what it does ant what it does not do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label
Projects
None yet
Development

No branches or pull requests

3 participants