Skip to content

Instantly share code, notes, and snippets.

@jeroenvandijk
Created April 17, 2019 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeroenvandijk/dacb9867d61fe0abc320429be5b4fe0f to your computer and use it in GitHub Desktop.
Save jeroenvandijk/dacb9867d61fe0abc320429be5b4fe0f to your computer and use it in GitHub Desktop.
(GraalVM) clojure -> js
(ns clojure_js
(:gen-class)
(:import [javax.script
ScriptEngineManager
ScriptException
SimpleBindings]))
;; GraalVM doesn't like reflections
(set! *warn-on-reflection* true)
(defn -main [& [f]]
(let [script-engine (.getEngineByName (ScriptEngineManager.) "js")
bindings (SimpleBindings.)
^String script (slurp f)]
(try
(prn (.eval script-engine script, bindings))
(catch ScriptException e
(println "Error " (.getMessage e))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment