diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2020-02-06 23:57:30 +0100 |
---|---|---|
committer | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2020-02-06 23:57:30 +0100 |
commit | 8943b49dfed95228e324422435a77597a95943c0 (patch) | |
tree | eeaadb526286cb8947abe06fb49379b8f3309b55 /test/transform/resource/after-ecj/GetterLazyGenerics.java | |
parent | 2e06cb3ff19fb25b709ddfe5513a953c3d658b2e (diff) | |
download | lombok-8943b49dfed95228e324422435a77597a95943c0.tar.gz lombok-8943b49dfed95228e324422435a77597a95943c0.tar.bz2 lombok-8943b49dfed95228e324422435a77597a95943c0.zip |
[fixes #880] get rid of an unchecked cast warning for `@Getter(lazy=true)`
Diffstat (limited to 'test/transform/resource/after-ecj/GetterLazyGenerics.java')
-rw-r--r-- | test/transform/resource/after-ecj/GetterLazyGenerics.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/transform/resource/after-ecj/GetterLazyGenerics.java b/test/transform/resource/after-ecj/GetterLazyGenerics.java new file mode 100644 index 00000000..67ef5543 --- /dev/null +++ b/test/transform/resource/after-ecj/GetterLazyGenerics.java @@ -0,0 +1,44 @@ +class GetterLazyGenerics<E> { + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> field = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> field2 = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + GetterLazyGenerics() { + super(); + } + public static <E>E getAny() { + return null; + } + public @java.lang.SuppressWarnings({"all", "unchecked"}) E getField() { + java.lang.Object value = this.field.get(); + if ((value == null)) + { + synchronized (this.field) + { + value = this.field.get(); + if ((value == null)) + { + final E actualValue = getAny(); + value = ((actualValue == null) ? this.field : actualValue); + this.field.set(value); + } + } + } + return (E) ((value == this.field) ? null : value); + } + public @java.lang.SuppressWarnings({"all", "unchecked"}) long getField2() { + java.lang.Object value = this.field2.get(); + if ((value == null)) + { + synchronized (this.field2) + { + value = this.field2.get(); + if ((value == null)) + { + final long actualValue = System.currentTimeMillis(); + value = actualValue; + this.field2.set(value); + } + } + } + return (java.lang.Long) value; + } +}
\ No newline at end of file |