diff --git a/test/transform/resource/after-delombok/LockedInRecord.java b/test/transform/resource/after-delombok/LockedInRecord.java new file mode 100644 index 00000000..14d5a4ef --- /dev/null +++ b/test/transform/resource/after-delombok/LockedInRecord.java @@ -0,0 +1,6 @@ +// version 14: +public record LockedInRecord(String a, String b) { + public void foo() { + String foo = "bar"; + } +} diff --git a/test/transform/resource/after-delombok/LockedName.java b/test/transform/resource/after-delombok/LockedName.java new file mode 100644 index 00000000..1c6e1083 --- /dev/null +++ b/test/transform/resource/after-delombok/LockedName.java @@ -0,0 +1,31 @@ +class LockedName { + @java.lang.SuppressWarnings("all") + private final java.util.concurrent.locks.ReentrantLock basicLock = new java.util.concurrent.locks.ReentrantLock(); + @java.lang.SuppressWarnings("all") + private final java.util.concurrent.locks.ReentrantReadWriteLock rwLock = new java.util.concurrent.locks.ReentrantReadWriteLock(); + + void test() { + this.basicLock.lock(); + try { + System.out.println("one"); + } finally { + this.basicLock.unlock(); + } + } + void test2() { + this.rwLock.readLock().lock(); + try { + System.out.println("two"); + } finally { + this.rwLock.readLock().unlock(); + } + } + void test3() { + this.rwLock.writeLock().lock(); + try { + System.out.println("three"); + } finally { + this.rwLock.writeLock().unlock(); + } + } +} diff --git a/test/transform/resource/after-delombok/LockedOnStatic.java b/test/transform/resource/after-delombok/LockedOnStatic.java new file mode 100644 index 00000000..1280b858 --- /dev/null +++ b/test/transform/resource/after-delombok/LockedOnStatic.java @@ -0,0 +1,24 @@ +class LockedOnStatic { + static class Inner { + private static final java.util.concurrent.locks.ReentrantLock LCK = new java.util.concurrent.locks.ReentrantLock(); + public void foo() { + LockedOnStatic.Inner.LCK.lock(); + try { + System.out.println(); + } finally { + LockedOnStatic.Inner.LCK.unlock(); + } + } + } + class Inner2 { + private final java.util.concurrent.locks.ReentrantLock LCK = new java.util.concurrent.locks.ReentrantLock(); + public void foo() { + this.LCK.lock(); + try { + System.out.println(); + } finally { + this.LCK.unlock(); + } + } + } +} diff --git a/test/transform/resource/after-delombok/LockedPlain.java b/test/transform/resource/after-delombok/LockedPlain.java new file mode 100644 index 00000000..302b967b --- /dev/null +++ b/test/transform/resource/after-delombok/LockedPlain.java @@ -0,0 +1,80 @@ +class LockedPlain { + @java.lang.SuppressWarnings("all") + private final java.util.concurrent.locks.ReentrantLock lock = new java.util.concurrent.locks.ReentrantLock(); + void test() { + this.lock.lock(); + try { + System.out.println("one"); + } finally { + this.lock.unlock(); + } + } + void test2() { + this.lock.lock(); + try { + System.out.println("two"); + } finally { + this.lock.unlock(); + } + } +} +class LockedPlainStatic { + @java.lang.SuppressWarnings("all") + private static final java.util.concurrent.locks.ReentrantLock LOCK = new java.util.concurrent.locks.ReentrantLock(); + static void test() { + LockedPlainStatic.LOCK.lock(); + try { + System.out.println("three"); + } finally { + LockedPlainStatic.LOCK.unlock(); + } + } + static void test2() { + LockedPlainStatic.LOCK.lock(); + try { + System.out.println("four"); + } finally { + LockedPlainStatic.LOCK.unlock(); + } + } +} +class LockedPlainRead { + @java.lang.SuppressWarnings("all") + private static final java.util.concurrent.locks.ReentrantReadWriteLock LOCK = new java.util.concurrent.locks.ReentrantReadWriteLock(); + static void test() { + LockedPlainRead.LOCK.readLock().lock(); + try { + System.out.println("five"); + } finally { + LockedPlainRead.LOCK.readLock().unlock(); + } + } + static void test2() { + LockedPlainRead.LOCK.readLock().lock(); + try { + System.out.println("six"); + } finally { + LockedPlainRead.LOCK.readLock().unlock(); + } + } +} +class LockedPlainWrite { + @java.lang.SuppressWarnings("all") + private final java.util.concurrent.locks.ReentrantReadWriteLock lock = new java.util.concurrent.locks.ReentrantReadWriteLock(); + void test() { + this.lock.writeLock().lock(); + try { + System.out.println("seven"); + } finally { + this.lock.writeLock().unlock(); + } + } + void test2() { + this.lock.writeLock().lock(); + try { + System.out.println("eight"); + } finally { + this.lock.writeLock().unlock(); + } + } +} diff --git a/test/transform/resource/after-delombok/LockedStaticMix.java b/test/transform/resource/after-delombok/LockedStaticMix.java new file mode 100644 index 00000000..201c9d7e --- /dev/null +++ b/test/transform/resource/after-delombok/LockedStaticMix.java @@ -0,0 +1,34 @@ +class LockedGeneratedStaticMismatch { + @java.lang.SuppressWarnings("all") + private static final java.util.concurrent.locks.ReentrantLock LOCK = new java.util.concurrent.locks.ReentrantLock(); + static void test() { + LockedGeneratedStaticMismatch.LOCK.lock(); + try { + System.out.println("one"); + } finally { + LockedGeneratedStaticMismatch.LOCK.unlock(); + } + } + void test2() { + System.out.println("two"); + } +} +class LockedUserStaticMismatch { + private static final java.util.concurrent.locks.ReentrantLock userLock = new java.util.concurrent.locks.ReentrantLock(); + static void test() { + LockedUserStaticMismatch.userLock.lock(); + try { + System.out.println("one"); + } finally { + LockedUserStaticMismatch.userLock.unlock(); + } + } + void test2() { + LockedUserStaticMismatch.userLock.lock(); + try { + System.out.println("two"); + } finally { + LockedUserStaticMismatch.userLock.unlock(); + } + } +} diff --git a/test/transform/resource/after-delombok/LockedTypeMismatch.java b/test/transform/resource/after-delombok/LockedTypeMismatch.java new file mode 100644 index 00000000..bbd916f4 --- /dev/null +++ b/test/transform/resource/after-delombok/LockedTypeMismatch.java @@ -0,0 +1,34 @@ +class LockedGeneratedTypeMismatch { + @java.lang.SuppressWarnings("all") + private final java.util.concurrent.locks.ReentrantLock lock = new java.util.concurrent.locks.ReentrantLock(); + void test() { + this.lock.lock(); + try { + System.out.println("one"); + } finally { + this.lock.unlock(); + } + } + void test2() { + System.out.println("two"); + } +} +class LockedUserTypeMismatch { + private final java.util.concurrent.locks.ReentrantLock userLock = new java.util.concurrent.locks.ReentrantLock(); + void test() { + this.userLock.lock(); + try { + System.out.println("one"); + } finally { + this.userLock.unlock(); + } + } + void test2() { + this.userLock.readLock().lock(); + try { + System.out.println("two"); + } finally { + this.userLock.readLock().unlock(); + } + } +} diff --git a/test/transform/resource/after-ecj/LockedInRecord.java b/test/transform/resource/after-ecj/LockedInRecord.java new file mode 100644 index 00000000..54a5ec0d --- /dev/null +++ b/test/transform/resource/after-ecj/LockedInRecord.java @@ -0,0 +1,14 @@ +import lombok.experimental.Locked; +public record LockedInRecord(java lock, String a) { + private final java.util.concurrent.locks.ReentrantLock lock = new java.util.concurrent.locks.ReentrantLock(); +/* Implicit */ private final String a; +/* Implicit */ private final String b; + public LockedInRecord(String a, String b) { + super(); + .a = a; + .b = b; + } + public @Locked void foo() { + String foo = "bar"; + } +} diff --git a/test/transform/resource/after-ecj/LockedName.java b/test/transform/resource/after-ecj/LockedName.java new file mode 100644 index 00000000..3fb996de --- /dev/null +++ b/test/transform/resource/after-ecj/LockedName.java @@ -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(); + } + } +} diff --git a/test/transform/resource/after-ecj/LockedOnStatic.java b/test/transform/resource/after-ecj/LockedOnStatic.java new file mode 100644 index 00000000..02d00721 --- /dev/null +++ b/test/transform/resource/after-ecj/LockedOnStatic.java @@ -0,0 +1,41 @@ +class LockedOnStatic { + static class Inner { + private static final java.util.concurrent.locks.ReentrantLock LCK = new java.util.concurrent.locks.ReentrantLock(); + () { + } + Inner() { + super(); + } + public @lombok.experimental.Locked("LCK") void foo() { + LockedOnStatic.Inner.LCK.lock(); + try + { + System.out.println(); + } + finally + { + LockedOnStatic.Inner.LCK.unlock(); + } + } + } + class Inner2 { + private final java.util.concurrent.locks.ReentrantLock LCK = new java.util.concurrent.locks.ReentrantLock(); + Inner2() { + super(); + } + public @lombok.experimental.Locked("LCK") void foo() { + this.LCK.lock(); + try + { + System.out.println(); + } + finally + { + this.LCK.unlock(); + } + } + } + LockedOnStatic() { + super(); + } +} diff --git a/test/transform/resource/after-ecj/LockedPlain.java b/test/transform/resource/after-ecj/LockedPlain.java new file mode 100644 index 00000000..b0b91719 --- /dev/null +++ b/test/transform/resource/after-ecj/LockedPlain.java @@ -0,0 +1,117 @@ +import lombok.experimental.Locked; +class LockedPlain { + private final java.util.concurrent.locks.ReentrantLock lock = new java.util.concurrent.locks.ReentrantLock(); + LockedPlain() { + super(); + } + @lombok.experimental.Locked void test() { + this.lock.lock(); + try + { + System.out.println("one"); + } + finally + { + this.lock.unlock(); + } + } + @Locked void test2() { + this.lock.lock(); + try + { + System.out.println("two"); + } + finally + { + this.lock.unlock(); + } + } +} +class LockedPlainStatic { + private static final java.util.concurrent.locks.ReentrantLock LOCK = new java.util.concurrent.locks.ReentrantLock(); + () { + } + LockedPlainStatic() { + super(); + } + static @lombok.experimental.Locked void test() { + LockedPlainStatic.LOCK.lock(); + try + { + System.out.println("three"); + } + finally + { + LockedPlainStatic.LOCK.unlock(); + } + } + static @Locked void test2() { + LockedPlainStatic.LOCK.lock(); + try + { + System.out.println("four"); + } + finally + { + LockedPlainStatic.LOCK.unlock(); + } + } +} +class LockedPlainRead { + private static final java.util.concurrent.locks.ReentrantReadWriteLock LOCK = new java.util.concurrent.locks.ReentrantReadWriteLock(); + () { + } + LockedPlainRead() { + super(); + } + static @lombok.experimental.Locked.Read void test() { + LockedPlainRead.LOCK.readLock().lock(); + try + { + System.out.println("five"); + } + finally + { + LockedPlainRead.LOCK.readLock().unlock(); + } + } + static @Locked.Read void test2() { + LockedPlainRead.LOCK.readLock().lock(); + try + { + System.out.println("six"); + } + finally + { + LockedPlainRead.LOCK.readLock().unlock(); + } + } +} +class LockedPlainWrite { + private final java.util.concurrent.locks.ReentrantReadWriteLock lock = new java.util.concurrent.locks.ReentrantReadWriteLock(); + LockedPlainWrite() { + super(); + } + @lombok.experimental.Locked.Write void test() { + this.lock.writeLock().lock(); + try + { + System.out.println("seven"); + } + finally + { + this.lock.writeLock().unlock(); + } + } + @Locked.Write void test2() { + this.lock.writeLock().lock(); + try + { + System.out.println("eight"); + } + finally + { + this.lock.writeLock().unlock(); + } + } +} diff --git a/test/transform/resource/after-ecj/LockedStaticMix.java b/test/transform/resource/after-ecj/LockedStaticMix.java new file mode 100644 index 00000000..3ec8ca2d --- /dev/null +++ b/test/transform/resource/after-ecj/LockedStaticMix.java @@ -0,0 +1,52 @@ +class LockedGeneratedStaticMismatch { + private static final java.util.concurrent.locks.ReentrantLock LOCK = new java.util.concurrent.locks.ReentrantLock(); + () { + } + LockedGeneratedStaticMismatch() { + super(); + } + static @lombok.experimental.Locked void test() { + LockedGeneratedStaticMismatch.LOCK.lock(); + try + { + System.out.println("one"); + } + finally + { + LockedGeneratedStaticMismatch.LOCK.unlock(); + } + } + @lombok.experimental.Locked("LOCK") void test2() { + System.out.println("two"); + } +} +class LockedUserStaticMismatch { + private static final java.util.concurrent.locks.ReentrantLock userLock = new java.util.concurrent.locks.ReentrantLock(); + () { + } + LockedUserStaticMismatch() { + super(); + } + static @lombok.experimental.Locked("userLock") void test() { + LockedUserStaticMismatch.userLock.lock(); + try + { + System.out.println("one"); + } + finally + { + LockedUserStaticMismatch.userLock.unlock(); + } + } + @lombok.experimental.Locked("userLock") void test2() { + LockedUserStaticMismatch.userLock.lock(); + try + { + System.out.println("two"); + } + finally + { + LockedUserStaticMismatch.userLock.unlock(); + } + } +} diff --git a/test/transform/resource/after-ecj/LockedTypeMismatch.java b/test/transform/resource/after-ecj/LockedTypeMismatch.java new file mode 100644 index 00000000..57e3f44a --- /dev/null +++ b/test/transform/resource/after-ecj/LockedTypeMismatch.java @@ -0,0 +1,48 @@ +class LockedGeneratedTypeMismatch { + private final java.util.concurrent.locks.ReentrantLock lock = new java.util.concurrent.locks.ReentrantLock(); + LockedGeneratedTypeMismatch() { + super(); + } + @lombok.experimental.Locked void test() { + this.lock.lock(); + try + { + System.out.println("one"); + } + finally + { + this.lock.unlock(); + } + } + @lombok.experimental.Locked.Read void test2() { + System.out.println("two"); + } +} +class LockedUserTypeMismatch { + private final java.util.concurrent.locks.ReentrantLock userLock = new java.util.concurrent.locks.ReentrantLock(); + LockedUserTypeMismatch() { + super(); + } + @lombok.experimental.Locked("userLock") void test() { + this.userLock.lock(); + try + { + System.out.println("one"); + } + finally + { + this.userLock.unlock(); + } + } + @lombok.experimental.Locked.Read("userLock") void test2() { + this.userLock.readLock().lock(); + try + { + System.out.println("two"); + } + finally + { + this.userLock.readLock().unlock(); + } + } +} diff --git a/test/transform/resource/before/LockedInRecord.java b/test/transform/resource/before/LockedInRecord.java new file mode 100644 index 00000000..9bb16001 --- /dev/null +++ b/test/transform/resource/before/LockedInRecord.java @@ -0,0 +1,10 @@ +// version 14: + +import lombok.experimental.Locked; + +public record LockedInRecord(String a, String b) { + @Locked + public void foo() { + String foo = "bar"; + } +} diff --git a/test/transform/resource/before/LockedName.java b/test/transform/resource/before/LockedName.java new file mode 100644 index 00000000..3a73e5a3 --- /dev/null +++ b/test/transform/resource/before/LockedName.java @@ -0,0 +1,11 @@ +class LockedName { + @lombok.experimental.Locked("basicLock") void test() { + System.out.println("one"); + } + @lombok.experimental.Locked.Read("rwLock") void test2() { + System.out.println("two"); + } + @lombok.experimental.Locked.Write("rwLock") void test3() { + System.out.println("three"); + } +} diff --git a/test/transform/resource/before/LockedOnStatic.java b/test/transform/resource/before/LockedOnStatic.java new file mode 100644 index 00000000..4da5af4c --- /dev/null +++ b/test/transform/resource/before/LockedOnStatic.java @@ -0,0 +1,16 @@ +class LockedOnStatic { + static class Inner { + private static final java.util.concurrent.locks.ReentrantLock LCK = new java.util.concurrent.locks.ReentrantLock(); + @lombok.experimental.Locked("LCK") + public void foo() { + System.out.println(); + } + } + class Inner2 { + private final java.util.concurrent.locks.ReentrantLock LCK = new java.util.concurrent.locks.ReentrantLock(); + @lombok.experimental.Locked("LCK") + public void foo() { + System.out.println(); + } + } +} diff --git a/test/transform/resource/before/LockedPlain.java b/test/transform/resource/before/LockedPlain.java new file mode 100644 index 00000000..7bcba019 --- /dev/null +++ b/test/transform/resource/before/LockedPlain.java @@ -0,0 +1,33 @@ +import lombok.experimental.Locked; +class LockedPlain { + @lombok.experimental.Locked void test() { + System.out.println("one"); + } + @Locked void test2() { + System.out.println("two"); + } +} +class LockedPlainStatic { + @lombok.experimental.Locked static void test() { + System.out.println("three"); + } + @Locked static void test2() { + System.out.println("four"); + } +} +class LockedPlainRead { + @lombok.experimental.Locked.Read static void test() { + System.out.println("five"); + } + @Locked.Read static void test2() { + System.out.println("six"); + } +} +class LockedPlainWrite { + @lombok.experimental.Locked.Write void test() { + System.out.println("seven"); + } + @Locked.Write void test2() { + System.out.println("eight"); + } +} diff --git a/test/transform/resource/before/LockedStaticMix.java b/test/transform/resource/before/LockedStaticMix.java new file mode 100644 index 00000000..9506ac04 --- /dev/null +++ b/test/transform/resource/before/LockedStaticMix.java @@ -0,0 +1,17 @@ +class LockedGeneratedStaticMismatch { + @lombok.experimental.Locked static void test() { + System.out.println("one"); + } + @lombok.experimental.Locked("LOCK") void test2() { + System.out.println("two"); + } +} +class LockedUserStaticMismatch { + private static final java.util.concurrent.locks.ReentrantLock userLock = new java.util.concurrent.locks.ReentrantLock(); + @lombok.experimental.Locked("userLock") static void test() { + System.out.println("one"); + } + @lombok.experimental.Locked("userLock") void test2() { + System.out.println("two"); + } +} diff --git a/test/transform/resource/before/LockedTypeMismatch.java b/test/transform/resource/before/LockedTypeMismatch.java new file mode 100644 index 00000000..67e96b56 --- /dev/null +++ b/test/transform/resource/before/LockedTypeMismatch.java @@ -0,0 +1,17 @@ +class LockedGeneratedTypeMismatch { + @lombok.experimental.Locked void test() { + System.out.println("one"); + } + @lombok.experimental.Locked.Read void test2() { + System.out.println("two"); + } +} +class LockedUserTypeMismatch { + private final java.util.concurrent.locks.ReentrantLock userLock = new java.util.concurrent.locks.ReentrantLock(); + @lombok.experimental.Locked("userLock") void test() { + System.out.println("one"); + } + @lombok.experimental.Locked.Read("userLock") void test2() { + System.out.println("two"); + } +} diff --git a/test/transform/resource/messages-delombok/LockedInRecord.java.messages b/test/transform/resource/messages-delombok/LockedInRecord.java.messages new file mode 100644 index 00000000..0165764d --- /dev/null +++ b/test/transform/resource/messages-delombok/LockedInRecord.java.messages @@ -0,0 +1 @@ +5 @Locked is legal only on methods in classes and enums. diff --git a/test/transform/resource/messages-delombok/LockedStaticMix.java.messages b/test/transform/resource/messages-delombok/LockedStaticMix.java.messages new file mode 100644 index 00000000..9320bb37 --- /dev/null +++ b/test/transform/resource/messages-delombok/LockedStaticMix.java.messages @@ -0,0 +1 @@ +5 The generated field LOCK does not match the static status of this method diff --git a/test/transform/resource/messages-delombok/LockedTypeMismatch.java.messages b/test/transform/resource/messages-delombok/LockedTypeMismatch.java.messages new file mode 100644 index 00000000..ad329880 --- /dev/null +++ b/test/transform/resource/messages-delombok/LockedTypeMismatch.java.messages @@ -0,0 +1 @@ +5 Expected field lock to be of type java.util.concurrent.locks.ReentrantReadWriteLock but got type java.util.concurrent.locks.ReentrantLock! Did you mix @Locked with @Locked.Read/Write on the same generated field? diff --git a/test/transform/resource/messages-ecj/LockedInRecord.java.messages b/test/transform/resource/messages-ecj/LockedInRecord.java.messages new file mode 100644 index 00000000..1e921a76 --- /dev/null +++ b/test/transform/resource/messages-ecj/LockedInRecord.java.messages @@ -0,0 +1 @@ +6 @Locked is legal only on methods in classes and enums. diff --git a/test/transform/resource/messages-ecj/LockedStaticMix.java.messages b/test/transform/resource/messages-ecj/LockedStaticMix.java.messages new file mode 100644 index 00000000..9320bb37 --- /dev/null +++ b/test/transform/resource/messages-ecj/LockedStaticMix.java.messages @@ -0,0 +1 @@ +5 The generated field LOCK does not match the static status of this method diff --git a/test/transform/resource/messages-ecj/LockedTypeMismatch.java.messages b/test/transform/resource/messages-ecj/LockedTypeMismatch.java.messages new file mode 100644 index 00000000..ac159d72 --- /dev/null +++ b/test/transform/resource/messages-ecj/LockedTypeMismatch.java.messages @@ -0,0 +1,2 @@ +5 Expected field lock to be of type java.util.concurrent.locks.ReentrantReadWriteLock but got type java.util.concurrent.locks.ReentrantLock! Did you mix @Locked with @Locked.Read/Write on the same generated field? +14 The method readLock() is undefined for the type ReentrantLock diff --git a/test/transform/resource/messages-idempotent/LockedTypeMismatch.java.messages b/test/transform/resource/messages-idempotent/LockedTypeMismatch.java.messages new file mode 100644 index 00000000..195f1466 --- /dev/null +++ b/test/transform/resource/messages-idempotent/LockedTypeMismatch.java.messages @@ -0,0 +1,2 @@ +27 cannot find symbol +31 cannot find symbol