I'm trying to compile jide_demo to machine code using GraalVM, which fails with the error message: unbalanced monitors - locked objects do not match
"Monitor" is bytecode speak for "lock", which happens at the Java level in `synchronized` blocks, and at the JVM for some internal operations (including class loading/initialization IIRC).
Unbalanced monitors are typically associated with exceptions.
The root cause is that the unbalanced monitors check is optional.
The JVM can deal with unbalanced monitors, which has been described as "runtime trickery using exception tables"; AOT compilers don't (maybe can't) do it, and if they don't report the situation, they risk run-time crashes.
The suggestion it to vary the Java idiom that triggers the error message, and use one that does not trigger it instead.
I can offer help in two ways:
- Publish the project on GitHub so the exact messages can be reproduced. (The project uses the obfuscated jide_demo.jar.)
- If I am provided with the source code of a class, I can quickly try out different Java idioms and check which of them will avoid the problem.
Anything else I can do to help?
Regards,
Jo
=============================
Here's one of the error messages.
The class/method that it's complaining about is in the "Parser context:" line.
- Code: Select all
Error: Frame states being merged are incompatible: unbalanced monitors - locked objects do not match
This frame state: [locals: [_,_,_,_,_,_,_,_,_,_,_,_,_] stack: [] locks: [533 / 32]]
Other frame state: [locals: [_,_,_,_,_,_,_,_,_,_,_,_,_] stack: [] locks: []]
Parser context: com.jidesoft.pane.FloorTabbedPane.insertTab(Unknown Source) [bci: 253, intrinsic: false]
253: goto 264
256: astore 12
258: aload 7
260: monitorexit
261: aload 12
263: athrow
Call path from entry point to com.jidesoft.pane.FloorTabbedPane.insertTab(String, Icon, Component, String, int):
at com.jidesoft.pane.FloorTabbedPane.insertTab(Unknown Source)
at javax.swing.JTabbedPane.addTab(JTabbedPane.java:802)
at com.jidesoft.docking.FrameContainer.addTab(Unknown Source)
at com.jidesoft.docking.DefaultDockingManager.a(Unknown Source)
at com.jidesoft.docking.DefaultDockingManager$r.run(Unknown Source)
at java.lang.Thread.runWith(Thread.java:1596)
at java.lang.Thread.run(Thread.java:1583)
at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:902)