diff --git a/cider.el b/cider.el index ba7013f9e..c8372ee7e 100644 --- a/cider.el +++ b/cider.el @@ -173,7 +173,6 @@ then concatenated into the \"-M[your-aliases]:cider/nrepl\" form." :safe #'stringp :package-version '(cider . "1.1")) - (defcustom cider-clojure-cli-global-aliases nil "Global aliases to include when jacking in with the clojure CLI. @@ -186,7 +185,6 @@ then concatenated into the \"-M[your-aliases]:cider/nrepl\" form." :safe #'stringp :package-version '(cider . "1.14")) - (defcustom cider-shadow-cljs-command "npx shadow-cljs" "The command used to execute shadow-cljs. @@ -376,6 +374,13 @@ The repl dependendcies are most likely to be nREPL middlewares." :safe #'booleanp :version '(cider . "0.11.0")) +(defcustom cider-enable-nrepl-jvmti-agent nil + "When t, add `-Djdk.attach.allowAttachSelf' to the command-line arguments, +so that nREPL JVMTI agent can be loaded." + :type 'boolean + :safe #'booleanp + :version '(cider . "1.15.0")) + (defcustom cider-offer-to-open-cljs-app-in-browser t "When nil, do not offer to open ClojureScript apps in a browser on connect." :type 'boolean @@ -536,7 +541,7 @@ Throws an error if PROJECT-TYPE is unknown." "List of dependencies where elements are lists of artifact name and version.") (put 'cider-jack-in-dependencies 'risky-local-variable t) -(defcustom cider-injected-nrepl-version "1.1.2" +(defcustom cider-injected-nrepl-version "1.2.0-beta2" "The version of nREPL injected on jack-in. We inject the newest known version of nREPL just in case your version of Boot or Leiningen is bundling an older one." @@ -813,7 +818,9 @@ removed, LEIN-PLUGINS, LEIN-MIDDLEWARES and finally PARAMS." (seq-map (lambda (middleware) (concat "update-in :middleware conj " middleware)) - lein-middlewares)) + lein-middlewares) + (when cider-enable-nrepl-jvmti-agent + `(,(concat "update-in :jvm-opts conj " (shell-quote-argument "-Djdk.attach.allowAttachSelf"))))) " -- ") " -- " (if (not cider-enrich-classpath) @@ -903,9 +910,10 @@ your aliases contain any mains, the cider/nrepl one will be the one used." (deps (format "{:deps {%s} :aliases {:cider/nrepl {:main-opts [%s]}}}" (string-join all-deps " ") main-opts)) (deps-quoted (cider--shell-quote-argument deps command))) - (format "%s-Sdeps %s -M%s:cider/nrepl%s" + (format "%s%s-Sdeps %s -M%s:cider/nrepl%s" ;; TODO: global-options are deprecated and should be removed in CIDER 2.0 (if global-options (format "%s " global-options) "") + (if cider-enable-nrepl-jvmti-agent "-J-Djdk.attach.allowAttachSelf " "") deps-quoted (cider--combined-aliases) (if params (format " %s" params) "")))) diff --git a/doc/modules/ROOT/pages/basics/up_and_running.adoc b/doc/modules/ROOT/pages/basics/up_and_running.adoc index b4af70b4f..e24a29b0c 100644 --- a/doc/modules/ROOT/pages/basics/up_and_running.adoc +++ b/doc/modules/ROOT/pages/basics/up_and_running.adoc @@ -204,6 +204,14 @@ You can further customize the command line CIDER uses for `cider-jack-in` by modifying the some options. Those differ a bit between the various tools, so we'll examine them tool by tool. +==== Enabling nREPL JVMTI agent + +Since version 1.2.0, nREPL ships together with a native JVMTI agent, so that the +eval interrupts properly work on Java 20 and later. To enable the agent, the +Java process should be launched with `-Djdk.attach.allowAttachSelf`. CIDER will +do it automatically during jack-in if you change +`cider-enable-nrepl-jvmti-agent` customizable to `t`. + ==== Leiningen Options * `cider-lein-command` - the name of the Leiningen executable (`lein` by default)