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

Add cookbook - Test your code with java 8 #179

Merged
merged 5 commits into from
Oct 6, 2021

Conversation

lwronski
Copy link
Contributor

@lwronski lwronski commented Oct 1, 2021

No description provided.

Copy link
Member

@romanowski romanowski left a comment

Choose a reason for hiding this comment

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

I left more comments to @alexarchambault then to the code itself what shows how important creating of this cookbooks is (there is a chance that we do not handle JVM versions correctly)

website/docs/cookbooks/scala-jvm.md Outdated Show resolved Hide resolved
website/docs/cookbooks/scala-jvm.md Outdated Show resolved Hide resolved
Passing `--jvm` to the `scala-cli` command and run your application with the specified java version.

```scala-cli
scala-cli Main.scala --jvm adopt:11
Copy link
Member

Choose a reason for hiding this comment

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

@alexarchambault would it be possible to specify just --jvm 11 that will default to adopt-11?

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, it is possible to specify just --jvm 11 or --jvm 8 etc. AdoptOpenJDK is used by default.

Here is more details about resolving jvm - coursier

Copy link
Contributor

Choose a reason for hiding this comment

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

We could default to Java 11. The default JVM id is currently defined here.

scala-cli Main.scala --jvm adopt:8
# In this case, it raises an error because the `Files.createTempFile` method is not available in java 8
#
# Exception in thread main: java.lang.Exception: java.lang.NoSuchMethodError: java.nio.file.Files.writeString(Ljava/nio/file/Path;Ljava/lang/CharSequence;[Ljava/nio/file/OpenOption;)Ljava/nio/file/Path;
Copy link
Member

Choose a reason for hiding this comment

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

@alexarchambault isn't it bad behaviour? Should code simply does not compile?

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 specially prepared a code snippet that shouldn't compile in jvm 8.

Copy link
Contributor

Choose a reason for hiding this comment

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

JVM switching only works well at runtime, and less so for compiling. When compiling, the JVM of Bloop is actually used.

Copy link
Member

Choose a reason for hiding this comment

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

but there are flags (--target if I am not mistaken) to force scala compiler to check if this will compile against given JVM. @prolativ can help here

 Co-authored-by: Krzysztof Romanowski <romanowski.kr@gmail.com>
website/docs/cookbooks/scala-jvm.md Outdated Show resolved Hide resolved
website/docs/cookbooks/scala-jvm.md Outdated Show resolved Hide resolved
website/docs/cookbooks/scala-jvm.md Outdated Show resolved Hide resolved
Co-authored-by: Alexandre Archambault <alexarchambault@users.noreply.github.com>
website/docs/cookbooks/scala-jvm.md Outdated Show resolved Hide resolved
website/docs/cookbooks/scala-jvm.md Outdated Show resolved Hide resolved
website/docs/cookbooks/scala-jvm.md Show resolved Hide resolved
lwronski and others added 2 commits October 6, 2021 14:43
Co-authored-by: Krzysztof Romanowski <romanowski.kr@gmail.com>
@romanowski romanowski merged commit 9861d31 into VirtusLab:master Oct 6, 2021
@lwronski lwronski deleted the cookbook-jvm branch October 26, 2021 06:46
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.

None yet

3 participants