Fork me on GitHub
#tools-deps
<
2022-03-23
>
Carlo21:03:59

what's the right way of writing the jvm option in a deps.edn file?

{:jvm-opts ["-Dsnoop.enabled"]
 :deps {}}
I can write -J-Dsnoop.enabled=true on the command line, and I would like the deps.edn equivalent

Alex Miller (Clojure team)21:03:45

there is no way to provide a global jvm opt

๐Ÿ™Œ 1
Alex Miller (Clojure team)21:03:08

you can provide them in an alias with :jvm-opts as you have above and then use the alias

๐Ÿ™Œ 1
Alex Miller (Clojure team)22:03:14

{:aliases {:snoop {:jvm-opts ["-Dsnoop.enabled"]}}}

clj -A:snoop

Carlo22:03:51

thanks! I'm sure there has to be a reason for that, but I don't see it at first glance

Carlo22:03:11

do you happen to have any insight on why that has to be the case?

Alex Miller (Clojure team)22:03:14

most jvm options don't make sense for the open world of all possible programs you might run in a project

๐Ÿ™Œ 1
Alex Miller (Clojure team)22:03:39

so I'm not terribly convinced yet that this is a good feature to have :)

Carlo22:03:59

I see, thank you! ๐Ÿ™‚

practicalli-johnny00:03:27

I've just added some pages on JVM options, showing how to use them with Clojure CLI. https://practical.li/clojure/reference/clojure-cli/jvm-options.html There are also a number of examples and https://practical.li/clojure/reference/jvm/java-17-flags.html. There are a lot of options to choose from ๐Ÿ™‚ It would be very interesting to know which options are commonly used. I've put together https://practical.li/clojure/reference/jvm/common-options.html. Appreciate any corrections if something is not quite right.

๐Ÿ˜ 1
Alex Miller (Clojure team)01:03:10

I would definitely add the OmitStackTrace one

Alex Miller (Clojure team)01:03:40

-XX:-OmitStackTraceInFastThrow

๐Ÿ‘ 1
Alex Miller (Clojure team)01:03:19

That is the most common jvm option I use

Alex Miller (Clojure team)01:03:38

And probably next most common are the โ€”illegal-access flags - debug and deny

practicalli-johnny01:03:53

Interesting. It seems the --illegal-access flag was marked deprecated in Java 16, with https://openjdk.java.net/jeps/403. So maybe one day it will be less common :)

Alex Miller (Clojure team)02:03:01

That's actually great, I'm glad they switched the default to deny as that means the reflection canAccess methods will actually work

Alex Miller (Clojure team)02:03:58

The Clojure reflector uses that feedback to look further up the inheritance chain for a public method to call

๐Ÿ‘ 1
Ben Sless06:03:14

Aren't server and tiered compilation on by default?