Skip to content

Commit

Permalink
Support babashka.process reload for exec fn (#1558)
Browse files Browse the repository at this point in the history
* Support babashka.process reload for exec fn

Exposed GraalVM `ProcessProperties/exec` signature used by
babashka.process/exec.

Add new `graal?` feature (on by default) to allow folks to build/use
babashka without this specific Graal API.

On my linux dev box bb executable increased by 8kb.

Closes #1557

* Respond to PR review feedback

1. Allow all Graal ProcessProperties/exec signatures

2. Instead of a feature flag, simply check if Graal ProcessProperties
class is available before including ProcessProperties/exec.
I did not see the value of adding a has-graal-process-properties fn, so
left that part out. Lemme know if you want/need that.

* Respond to PR review feedback

Because resolves can bloat GraalVM native-image size, we like to keep
the together and obvious instead of buried and non-obvious.
  • Loading branch information
lread committed May 13, 2023
1 parent b22092a commit 342cedb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,7 @@ in the CfP!
## Unreleased

- [#1524](https://github.com/babashka/babashka/issues/1524): Remove dynamic builds for linux-aarch64 ([@lispyclouds](https://github.com/lispyclouds))
- [#1577](https://github.com/babashka/babashka/issues/1557): Add support for `babashka.process/exec` after namespace reload of `babashka.process` ([@lread](https://github.com/lread))

## 1.3.179 (2023-04-26)

Expand Down
9 changes: 8 additions & 1 deletion src/babashka/impl/classes.clj
Expand Up @@ -15,6 +15,9 @@
(def has-domain-sockets?
(resolve 'java.net.UnixDomainSocketAddress))

(def has-graal-process-properties?
(resolve 'org.graalvm.nativeimage.ProcessProperties))

(def base-custom-map
`{clojure.lang.LineNumberingPushbackReader {:allPublicConstructors true
:allPublicMethods true}
Expand Down Expand Up @@ -182,7 +185,11 @@
`java.util.ResourceBundle
{:methods [{:name "getBundle"
:parameterTypes ["java.lang.String","java.util.Locale",
"java.lang.ClassLoader"]}]})))
"java.lang.ClassLoader"]}]})

has-graal-process-properties?
(assoc `org.graalvm.nativeimage.ProcessProperties
{:methods [{:name "exec"}]})))

(def java-net-http-classes
"These classes must be initialized at run time since GraalVM 22.1"
Expand Down

0 comments on commit 342cedb

Please sign in to comment.