Skip to content

Commit 35760b0

Browse files
committed
Revert "Refactor conditional method invocation to more robust approach (#175)"
This reverts commit 6d4a89d.
1 parent 6d4a89d commit 35760b0

5 files changed

Lines changed: 14 additions & 22 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ jobs:
4545
java -version
4646
bb --version
4747
48-
- name: 🔧 Install bb from dev build (until next release)
49-
shell: bash
50-
run: |
51-
curl -sLO https://raw.githubusercontent.com/babashka/babashka/master/install
52-
chmod +x ./install
53-
./install --dev-build --dir /tmp
54-
cp /tmp/bb "$(which bb)"
55-
5648
- name: Run bb tests
5749
run: |
5850
bb test:bb

deps.edn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{:deps {babashka/fs {:mvn/version "0.4.18"}}
2-
:paths ["src" "resources"]
32
:aliases {:test {:extra-paths ["test"]
43
:extra-deps {io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}}
54
:main-opts ["-m" "cognitect.test-runner"]}

project.clj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
:url "https://www.eclipse.org/legal/epl-1.0/"}
88
:dependencies [[org.clojure/clojure "1.9.0"]
99
[babashka/fs "0.4.18"]]
10-
:source-paths ["src" "resources"]
1110
:deploy-repositories [["clojars" {:url "https://clojars.org/repo"
1211
:username :env/clojars_user
1312
:password :env/clojars_pass

resources/META-INF/native-image/babashka/process/reflect-config.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/babashka/process.cljc

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,16 @@
604604
:err :string} opts)]
605605
@(process* {:cmd cmd :opts opts :prev prev})))
606606

607-
(def ^:private exec-meth
608-
(delay (try (.getMethod (Class/forName "org.graalvm.nativeimage.ProcessProperties") "exec"
609-
(into-array [java.nio.file.Path (Class/forName "[Ljava.lang.String;") java.util.Map]))
610-
(catch Exception _ nil))))
607+
(def ^:private has-exec?
608+
(boolean (try (.getMethod ^Class
609+
(resolve 'org.graalvm.nativeimage.ProcessProperties) "exec"
610+
(into-array [java.nio.file.Path (Class/forName "[Ljava.lang.String;") java.util.Map]))
611+
(catch Exception _ false))))
612+
613+
(defmacro ^:no-doc
614+
if-has-exec [then else]
615+
(if has-exec?
616+
then else))
611617

612618
(defn exec
613619
"Replaces the current process image with the process image specified
@@ -643,10 +649,10 @@
643649
^java.util.Map env (into (or (as-string-map env)
644650
(into {} (System/getenv)))
645651
(as-string-map extra-env))]
646-
(if-let [^java.lang.reflect.Method meth @exec-meth]
647-
(.invoke meth nil (into-array Object [(fs/path program)
648-
(into-array String args)
649-
env]))
652+
(if-has-exec
653+
(org.graalvm.nativeimage.ProcessProperties/exec (fs/path program)
654+
(into-array String args)
655+
env)
650656
(throw (ex-info "exec is not supported in non-GraalVM environments" {:cmd cmd}))))))
651657

652658
(def ^:private default-shell-opts

0 commit comments

Comments
 (0)