Welcome! Please see the About page for a little more info on how this works.

0 votes
in Docs by
edited by

I have a problem that might be related to java interop & reflection. Researching the issue led me to the Clojure FAQ on illegal accesses. It says to add --illegal-access=debug. After half an hour, I still can't figure out how. This is an odd problem, but I honestly seem to be struggling at running the gauntlet of adding an argument. I looked at clj --help and the Deps and CLI Guide, but it is taking so much effort I must be missing a guide or page of documentation somewhere.

% clj -e "\*clojure-version\*"
{:major 1, :minor 10, :incremental 0, :qualifier nil}
% clj --illegal-access=debug
Exception in thread "main" java.io.FileNotFoundException: --illegal-access=debug (No such file or directory)
        at java.base/java.io.FileInputStream.open0(Native Method)
        at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:112)
        at clojure.lang.Compiler.loadFile(Compiler.java:7570)
        at clojure.main$load_script.invokeStatic(main.clj:452)
        at clojure.main$script_opt.invokeStatic(main.clj:512)
        at clojure.main$script_opt.invoke(main.clj:507)
        at clojure.main$main.invokeStatic(main.clj:598)
        at clojure.main$main.doInvoke(main.clj:561)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:705)
        at clojure.main.main(main.java:37)

I've also got a docker image running (FROM clojure:openjdk-18-tools-deps- that doesn't work either:

root@dd07c7fedc67:/app# clojure -e "\*clojure-version\*"
WARNING: Implicit use of clojure.main with options is deprecated, use -M
{:major 1, :minor 10, :incremental 3, :qualifier nil}
root@dd07c7fedc67:/app# clojure -M --illegal-access=debug
Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).
--illegal-access=debug (No such file or directory)
Full report at:
root@dd07c7fedc67:/app# clojure -M -m clojure.main --illegal-access=debug
Execution error (NullPointerException) at clojure.main/main (main.java:40).
Cannot invoke "clojure.lang.IFn.applyTo(clojure.lang.ISeq)" because "f" is null
Full report at:

1 Answer

+1 vote
selected by
Best answer
clojure -J--illegal-access=debug

clojure -J--illegal-access=debug -M -e '*clojure-version*'

The -J option is used to pass arguments to the JVM when the Clojure CLI runs.