diff options
Diffstat (limited to 'tests/bugs150/pr121197.aj')
-rw-r--r-- | tests/bugs150/pr121197.aj | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/bugs150/pr121197.aj b/tests/bugs150/pr121197.aj new file mode 100644 index 000000000..29fed9c52 --- /dev/null +++ b/tests/bugs150/pr121197.aj @@ -0,0 +1,57 @@ +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; + +@Aspect( "perthis( readOperations() || writeOperations() )" ) +public abstract class pr121197 { + @Pointcut( "" ) + protected abstract void readOperations(); + + @Pointcut( "" ) + protected abstract void writeOperations(); + + private ReadWriteLock _lock = new ReentrantReadWriteLock(); + + @Before( "readOperations()" ) + public void beforeReading() { + _lock.readLock().lock(); + } + + @After( "readOperations()" ) + public void afterReading() { + _lock.readLock().unlock(); + } + + @Before( "writeOperations()" ) + public void beforeWriting() { + _lock.writeLock().lock(); + } + + @After( "writeOperations()" ) + public void afterWriting() { + _lock.writeLock().unlock(); + } + +} + +@Aspect +class ModelThreadSafety extends pr121197 { + @Pointcut( "execution( * C.read*(..) )" ) + @Override + protected void readOperations() {} + + @Pointcut( "execution( * C.write*(..) )" ) + @Override + protected void writeOperations() { } +} + +class C { + + public void readSomething() {} + public void writeSomething() {} + +} |