Skip to content

Static methods used as values obey :static-methods config - #1118

Merged
borkdude merged 3 commits into
babashka:masterfrom
whilo:fix/closed-static-method-value
Oct 26, 2026
Merged

borkdude merged 3 commits into
babashka:masterfrom
whilo:fix/closed-static-method-value

Conversation

@whilo

@whilo whilo commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

A closed class's unlisted static method is denied when called directly, but callable when taken as a value:

(sci/eval-string "(let [f Integer/toHexString] (f 255))"
                 {:classes {'java.lang.Integer {:class Integer :closed true
                                                :static-methods {'parseInt true}}}})
;; => "ff"   (the direct call (Integer/toHexString 255) throws "not allowed")

and a :static-methods override is ignored in value position ((let [f Integer/valueOf] (f "42")) reflects instead of calling the override).

The value branch of analyze-interop built the reflective fn without consulting member-disposition; it now resolves :override / :deny / :reflect like the direct static call does. Tests added next to the existing closed-class static-method tests (sci.interop-test: 22 tests, 185 assertions, 0 failures; the new assertions fail without the change).

A closed class's unlisted static method was denied when called directly
but callable when taken as a value ((let [f Integer/toHexString] (f 255))),
and a :static-methods override was ignored in value position. The value
path now resolves member-disposition like the direct call.
whilo added a commit to replikativ/dvergr that referenced this pull request Oct 23, 2026
Rebased onto upstream SCI 0.15.59, plus the fix proposed upstream as
babashka/sci#1118. Random/from is now refused when taken as a value too,
so the note that it stayed reachable goes; the test pins it.
whilo added a commit to replikativ/dvergr that referenced this pull request Oct 23, 2026
…#394)

* Sandbox: seeded java.util.Random and SplittableRandom for simulations

Agents building simulations reach for java.util.Random and found it refused
(a company-cash attempt spent turns rewriting its model around rand). Both
classes are now exposed, closed to their draw methods: no stream methods
(doubles, ints, …), and SecureRandom stays out. A seed repeats the same
worlds, so plans compare on common random numbers and runs can be repeated;
SplittableRandom's split gives each world or entity its own stream. The
clojure_eval description says so.

* Sandbox Random: note that Random/from stays reachable as a value, and why that is harmless

* SCI 0.15.59-replikativ.2: static methods as values obey closed classes

Rebased onto upstream SCI 0.15.59, plus the fix proposed upstream as
babashka/sci#1118. Random/from is now refused when taken as a value too,
so the note that it stayed reachable goes; the test pins it.
@borkdude
borkdude merged commit 5322c69 into babashka:master Oct 26, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants