你好,
我在一个使用Clojure Spec的项目中遇到了这个问题。我制作了一个简单的项目来复现这个问题: https://github.com/alzadude/cljc-hello-world/tree/graalvm-spec-issue
我尝试使用应用了Clojure补丁的Graal native-image
来创建一个可工作的二进制文件。然而,当我使用修改过的Clojure jar时,我仍然得到“未平衡监视器”错误。我犯了什么错误?
谢谢!
1 使用补丁构建clojure
cd /mnt/d/Projects/clojure
patch -p1 < /mnt/c/Users/alex/Downloads/CLJ-1472-reentrant-finally2.patch
mvn clean
mvn -Plocal install -Dmaven.test.skip=true
2 尝试使用clj/deps.edn创建Graalvm本地镜像
cd /mnt/d/Projects/cljc-hello-world
GRAALVM_HOME=/usr/local/graalvm-ce-19.2.0.1/ clojure -Anative-image
即使应用了补丁,我仍然得到“未平衡监视器”错误
Cleaning target
Creating target/classes
Compiling hello-world.core
Creating target/cljc-hello-world
ERROR! Warning: Aborting stand-alone image build. unbalanced monitors: mismatch at monitorexit, 96|LoadField#lockee__5436__auto__ != 3|LoadField#lockee__5436__auto__
Detailed message:
Call path from entry point to clojure.spec.gen.alpha$dynaload$fn__2628.invoke():
at clojure.spec.gen.alpha$dynaload$fn__2628.invoke(alpha.clj:21)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:460)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)
Warning: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Warning: Image 'target/cljc-hello-world' is a fallback image that requires a JDK for execution (use --no-fallback to suppress fallback image generation).
3 尝试使用native-image和显式类路径创建Graalvm本地镜像,以排除deps.edn/cambada等问题
cd /mnt/d/Projects/cljc-hello-world
clojure -Auberjar
/usr/local/graalvm-ce-19.2.0.1/bin/native-image --class-path ../clojure/target/clojure-1.11.0-master-SNAPSHOT.jar --report-unsupported-elements-at-runtime --initialize-at-build-time -jar ./target/cljc-hello-world-1.0.0-SNAPSHOT-standalone.jar -H:Name=./target/cljc-hello-world
我仍然得到“未平衡监视器”错误
Build on Server(pid: 10328, port: 64314)*
[./target/cljc-hello-world:10328] classlist: 5,817.52 ms
[./target/cljc-hello-world:10328] (cap): 2,576.68 ms
[./target/cljc-hello-world:10328] setup: 3,923.40 ms
[./target/cljc-hello-world:10328] analysis: 11,800.59 ms
Warning: Aborting stand-alone image build. unbalanced monitors: mismatch at monitorexit, 96|LoadField#lockee__5436__auto__ != 3|LoadField#lockee__5436__auto__
Detailed message:
Call path from entry point to clojure.spec.gen.alpha$dynaload$fn__2628.invoke():
at clojure.spec.gen.alpha$dynaload$fn__2628.invoke(alpha.clj:21)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:748)
at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:460)
at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
at com.oracle.svm.core.code.IsolateEnterStub.PosixJavaThreads_pthreadStartRoutine_e1f4a8c0039f8337338252cd8734f63a79b5e3df(generated:0)
Warning: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
Build on Server(pid: 10328, port: 64314)
[./target/cljc-hello-world:10328] classlist: 217.19 ms
[./target/cljc-hello-world:10328] (cap): 1,244.81 ms
[./target/cljc-hello-world:10328] setup: 1,535.89 ms
[./target/cljc-hello-world:10328] (typeflow): 1,309.40 ms
[./target/cljc-hello-world:10328] (objects): 1,430.65 ms
[./target/cljc-hello-world:10328] (features): 120.57 ms
[./target/cljc-hello-world:10328] analysis: 2,906.19 ms
[./target/cljc-hello-world:10328] (clinit): 88.70 ms
[./target/cljc-hello-world:10328] universe: 250.93 ms
[./target/cljc-hello-world:10328] (parse): 315.62 ms
[./target/cljc-hello-world:10328] (inline): 739.40 ms
[./target/cljc-hello-world:10328] (compile): 3,100.68 ms
[./target/cljc-hello-world:10328] compile: 4,401.60 ms
[./target/cljc-hello-world:10328] image: 296.36 ms
[./target/cljc-hello-world:10328] write: 195.80 ms
[./target/cljc-hello-world:10328] [total]: 9,868.80 ms
Warning: Image './target/cljc-hello-world' is a fallback image that requires a JDK for execution (use --no-fallback to suppress fallback image generation).