Arrays cannot be synchronized on
See original GitHub issueUnder TeaVM 0.6.0-dev-751, the following code will throw a "$o.$monitor is undefined"
error within jl_Object_monitorEnterSync
:
int[] x = new int[0];
synchronized(x) { }
I believe this was caused by fe68bf700b21ce8cb2667296fbb35d25cf94831e - as arrays are no longer using jl_Object
’s constructor, they do not initialize $monitor
to null
, and so the if ($o.$monitor.$owner === null)
check fails, meaning the monitor is never actually initialised.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Java: how to synchronize array accesses and what are the ...
Yes, you can synchronize using an array as monitor object, because arrays (even arrays of primitives) are objects in Java.
Read more >Synchronization of ArrayList in Java - GeeksforGeeks
Implementation of ArrayList is not synchronized by default. It means if a thread modifies it structurally and multiple threads access it ...
Read more >is array synchronized??? (OCPJP forum at Coderanch)
There are no threading issues with that as long as you go through a synchronized block before letting a reference to the array...
Read more >Synchronize storage array clocks - NetApp
The Synchronize Storage Array Clocks dialog box opens. It shows the current date and time for the controller(s) and the computer used as...
Read more >MirrorView - Cannot Sync A Group That Is Already Synchronized
I have a MirrorView consistency group that I am attempting to synchronize to force a push of refreshed data to the target array....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
BTW, I just published 0.6.0-dev-764 version, which includes fix for this issue. This means you can build your project against this version without any patches.
Amazing, thank you very much!