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

Enable run,debug source links to process .jvmopts file. #326

Open
objektwerks opened this issue Jan 28, 2023 · 4 comments
Open

Enable run,debug source links to process .jvmopts file. #326

objektwerks opened this issue Jan 28, 2023 · 4 comments

Comments

@objektwerks
Copy link

Is your feature request related to a problem? Please describe.

No.

Describe the solution you'd like

When selecting run or debug in a runnable Scala source file, a local .jvmopts file should also be processed.

Describe alternatives you've considered

N/A

Additional context

If desired this project can be used to test the current and future state of the run | debug feature: https://github.com/objektwerks/scalafx.http

Search terms

.jvmopts run debug metals

@tgodzik
Copy link
Contributor

tgodzik commented Feb 2, 2023

Thanks for reporting! The current workaround is to use launch.json if using VS Code (other editors should also enable this in different ways) and defined jvm propeties there.

@objektwerks
Copy link
Author

objektwerks commented Feb 2, 2023

@tgodzik Okay, I created the following ./.vscode/launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "scala",
      "request": "launch",
      "name": "Chuck Norris App",
      "mainClass": "objektwerks.ChuckNorrisApp",
      "args": [],
      "jvmOptions": ["--enable-preview", "--add-modules=jdk.incubator.concurrent"],
      "env": {}
    }
  ]
}

I then selected the run link in the objektwerks.ChuckNorrisApp source file --- but VSCode failed to pick up the specified jvm options. I also tried a few other variations on the jvmOptions, but nothing worked.

The reported error is:

Exception in thread "main" java.lang.ExceptionInInitializerError
        at objektwerks.ChuckNorrisApp.main(ChuckNorrisApp.scala)
Caused by: java.lang.UnsupportedOperationException: Preview Features not enabled, need to run with --enable-preview
        at java.base/jdk.internal.misc.PreviewFeatures.ensureEnabled(PreviewFeatures.java:49)
        at java.base/java.lang.Thread.ofVirtual(Thread.java:833)
        at java.base/java.util.concurrent.Executors.newVirtualThreadPerTaskExecutor(Executors.java:274)
        at objektwerks.ChuckNorrisApp$.<clinit>(ChuckNorrisApp.scala:11)

Have you or someone you know successfully used this technique? Thanks!

@tgodzik
Copy link
Contributor

tgodzik commented Feb 2, 2023

You need to run from the run menu. There is a drop-down to choose which configuration you want to run. You should see the created configuration name. I am on my phone now, but let me know if you have any issues. I will try to show a gif when I am on my computer

@objektwerks
Copy link
Author

@tgodzik Indeed, selecting menu Run > Run Without Debugging works! :) The embedded run | debug source link does not. Thanks! ;)

@tgodzik tgodzik changed the title Enable run | debug source links to process .jvmopts file. Enable run,debug source links to process .jvmopts file. May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants