Skip to content

Commit

Permalink
Fix reflection issue in JDK19 (clojure-lsp#1519)
Browse files Browse the repository at this point in the history
* Fix reflection issue in JDK19

* changelog

* move to shared

* reflection test

* fix lint

* deal with reflection linter later
  • Loading branch information
borkdude authored Mar 12, 2023
1 parent a101810 commit b7111ef
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .clj-kondo/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
:linters {:unresolved-var {:exclude [digest
rewrite-clj.zip
rewrite-clj.node]}
:clojure-lsp/unused-public-var {:exclude [make]}}
:clojure-lsp/unused-public-var {:exclude [make]}
:unsorted-required-namespaces {:level :warning}}
:lint-as {rewrite-clj.zip.subedit/edit-> clojure.core/->
rewrite-clj.zip.subedit/subedit-> clojure.core/->
clojure-lsp.refactor.edit/my-defn clojure.core/defn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04]
jdk: [8, 11, 15, 17]
jdk: [8, 11, 15, 17, 19]
include:
- os: windows-latest
jdk: 8
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

- General
- Fix reflection issue in JDK19 with `Thread/sleep` #1520

- Editor
- Fix classpath issue message to properly ignore or retry after user input. #1500

Expand Down
3 changes: 2 additions & 1 deletion bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
prod-cli make/prod-cli
native-cli make/native-cli

test-reflection make/test-reflection
test-lib make/test-lib
test-cli make/test-cli
test {:doc "Run all unit tests."
:depends [test-lib test-cli]}
:depends [test-reflection test-lib test-cli]}

pod-test make/pod-test
integration-test make/integration-test
Expand Down
3 changes: 3 additions & 0 deletions cli/dev/user.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(ns user)

(alter-var-root #'*warn-on-reflection* (constantly true))
2 changes: 2 additions & 0 deletions lib/src/clojure_lsp/feature/restructure_keys.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[rewrite-clj.node :as n]
[rewrite-clj.zip :as z]))

(set! *warn-on-reflection* true)

(defn ^:private map-to-restructure [zloc uri db]
(when zloc
(let [{:keys [row col]} (meta (z/node zloc))
Expand Down
2 changes: 1 addition & 1 deletion lib/src/clojure_lsp/handlers.clj
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
(caught-up? db uri desired-version)))
seq)]
(do
(Thread/sleep backoff)
(Thread/sleep (long backoff))
(recur false (min backoff-max (* backoff-mult backoff)) processing-versions))
(if immediate?
{:delay/outcome :immediate
Expand Down
2 changes: 2 additions & 0 deletions lib/src/clojure_lsp/http.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
(java.net URL)
(javax.net.ssl HttpsURLConnection)))

(set! *warn-on-reflection* true)

(def ^:private connect-timeout-ms 1000)
(def ^:private read-timeout-ms 30000)

Expand Down
16 changes: 14 additions & 2 deletions scripts/make.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
(:require
[babashka.deps :as deps]
[babashka.fs :as fs]
[babashka.process :as p]))
[babashka.process :as p]
[babashka.tasks :refer [clojure]]
[clojure.string :as str]))

(set! *warn-on-reflection* true)

(def windows? (#'fs/windows?))

Expand Down Expand Up @@ -31,7 +35,7 @@
"Clean all artifacts produced by the various tasks."
[]
(let [lsp-bin-native (lsp-bin-filename :native)
lsp-bin-script (lsp-bin-filename :script)
lsp-bin-script (lsp-bin-filename :script)
files (into ["cli/target"
(fs/path "cli" lsp-bin-native)
(fs/path "cli" lsp-bin-script)
Expand Down Expand Up @@ -158,3 +162,11 @@
(fs/copy-tree "images" "docs" {:replace-existing true})
(p/shell "docker login docker.pkg.github.com")
(p/shell (str "docker run --rm -it -p 8000:8000 -v " (fs/cwd) ":/docs docker.pkg.github.com/clojure-lsp/docs-image/docs-image"))))

(defn test-reflection []
(let [err (:err (clojure
{:dir "cli" :continue true :err :string}
"-M:dev -e" "(require '[clojure-lsp.main])"))]
(when-not (str/blank? err)
(println err))
(assert (not (str/includes? err "Reflection warning")))))

0 comments on commit b7111ef

Please sign in to comment.