Add tests for Locked annotations

This commit is contained in:
Pim van der Loos committed 2023-04-18 18:07:53 +02:00
1 parent 5e31bb253c
commit cb25fce7aa
25 files changed
+634

No files matched your search

@@ -0,0 +1,40 @@
class LockedName {
private final java.util.concurrent.locks.ReentrantLock basicLock = new java.util.concurrent.locks.ReentrantLock();
private final java.util.concurrent.locks.ReentrantReadWriteLock rwLock = new java.util.concurrent.locks.ReentrantReadWriteLock();
LockedName() {
super();
}
@lombok.experimental.Locked("basicLock") void test() {
this.basicLock.lock();
try
{
System.out.println("one");
}
finally
{
this.basicLock.unlock();
}
}
@lombok.experimental.Locked.Read("rwLock") void test2() {
this.rwLock.readLock().lock();
try
{
System.out.println("two");
}
finally
{
this.rwLock.readLock().unlock();
}
}
@lombok.experimental.Locked.Write("rwLock") void test3() {
this.rwLock.writeLock().lock();
try
{
System.out.println("three");
}
finally
{
this.rwLock.writeLock().unlock();
}
}
}