我遇到的问题可能与Java互操作和反射有关。研究这个问题使我来到了Clojure FAQ中关于非法访问的页面。它建议添加--illegal-access=debug
。半小时后,我还是搞不清楚如何做到。这是一个奇怪的问题,但老实说,我觉得我好像在添加参数的过程中遇到了障碍。我查看了clj --help
和Deps和CLI指南,但这需要太多的精力,我必须在某个地方遗漏了一个指南或文档页。
% 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)
我还运行了一个Docker镜像(FROM clojure:openjdk-18-tools-deps-1.10.3.1040-bullseye
),它也没有起作用。
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:
/tmp/clojure-7987604327110923419.edn
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:
/tmp/clojure-17703419873584290207.edn