Could java.util.concurrent.lock.Lock detect deadlocks caused by two threads acquiring the same locks in a different order?
Could it use a static list of all threads that have locks and ThreadLocal locks lists to know about all in use locks and then check for incorrect order when lock() is called.
Check the ThreadLocal list and if there are no other locks then proceed.
Else if there are other locks then look through other threads to determine if any have any of the same locks in a different order.
Add current lock to ThreadLocal list.
Remove current lock from ThreadLocal list.