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-delombok | |
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-delombok')
7 files changed, 52 insertions, 17 deletions
diff --git a/test/transform/resource/after-delombok/DelegateOnGetter.java b/test/transform/resource/after-delombok/DelegateOnGetter.java index f41259df..edf1641b 100644 --- a/test/transform/resource/after-delombok/DelegateOnGetter.java +++ b/test/transform/resource/after-delombok/DelegateOnGetter.java @@ -4,7 +4,7 @@ class DelegateOnGetter { void setList(java.util.ArrayList<java.lang.String> list); int getInt(); } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public Bar getBar() { java.lang.Object value = this.bar.get(); if (value == null) { diff --git a/test/transform/resource/after-delombok/GetterLazy.java b/test/transform/resource/after-delombok/GetterLazy.java index 25a71848..1e30f94b 100644 --- a/test/transform/resource/after-delombok/GetterLazy.java +++ b/test/transform/resource/after-delombok/GetterLazy.java @@ -2,7 +2,7 @@ class GetterLazy { static class ValueType { } private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> fieldName = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public ValueType getFieldName() { java.lang.Object value = this.fieldName.get(); if (value == null) { diff --git a/test/transform/resource/after-delombok/GetterLazyBoolean.java b/test/transform/resource/after-delombok/GetterLazyBoolean.java index 3ca127e3..5b1f19dc 100644 --- a/test/transform/resource/after-delombok/GetterLazyBoolean.java +++ b/test/transform/resource/after-delombok/GetterLazyBoolean.java @@ -31,7 +31,7 @@ class GetterLazyBoolean { public java.lang.String toString() { return "GetterLazyBoolean(booleanValue=" + this.isBooleanValue() + ")"; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public boolean isBooleanValue() { java.lang.Object value = this.booleanValue.get(); if (value == null) { @@ -46,7 +46,7 @@ class GetterLazyBoolean { } return (java.lang.Boolean) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public boolean isOtherBooleanValue() { java.lang.Object value = this.otherBooleanValue.get(); if (value == null) { diff --git a/test/transform/resource/after-delombok/GetterLazyEahcToString.java b/test/transform/resource/after-delombok/GetterLazyEahcToString.java index e0a0f6b2..bec89818 100644 --- a/test/transform/resource/after-delombok/GetterLazyEahcToString.java +++ b/test/transform/resource/after-delombok/GetterLazyEahcToString.java @@ -44,9 +44,7 @@ class GetterLazyEahcToString { return "GetterLazyEahcToString(value=" + this.getValue() + ", value2=" + this.value2 + ")"; } - @java.lang.SuppressWarnings("all") - - + @java.lang.SuppressWarnings({"all", "unchecked"}) public String getValue() { java.lang.Object value = this.value.get(); if (value == null) { diff --git a/test/transform/resource/after-delombok/GetterLazyGenerics.java b/test/transform/resource/after-delombok/GetterLazyGenerics.java new file mode 100644 index 00000000..5e92cda7 --- /dev/null +++ b/test/transform/resource/after-delombok/GetterLazyGenerics.java @@ -0,0 +1,37 @@ +class GetterLazyGenerics<E> { + private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> field = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> field2 = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + public static <E> E getAny() { + return null; + } + @java.lang.SuppressWarnings({"all", "unchecked"}) + public 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); + } + @java.lang.SuppressWarnings({"all", "unchecked"}) + public 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 diff --git a/test/transform/resource/after-delombok/GetterLazyNative.java b/test/transform/resource/after-delombok/GetterLazyNative.java index b9d471ff..f43d5490 100644 --- a/test/transform/resource/after-delombok/GetterLazyNative.java +++ b/test/transform/resource/after-delombok/GetterLazyNative.java @@ -8,7 +8,7 @@ class GetterLazyNative { private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> doubleField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> charField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> intArrayField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public boolean isBooleanField() { java.lang.Object value = this.booleanField.get(); if (value == null) { @@ -23,7 +23,7 @@ class GetterLazyNative { } return (java.lang.Boolean) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public byte getByteField() { java.lang.Object value = this.byteField.get(); if (value == null) { @@ -38,7 +38,7 @@ class GetterLazyNative { } return (java.lang.Byte) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public short getShortField() { java.lang.Object value = this.shortField.get(); if (value == null) { @@ -53,7 +53,7 @@ class GetterLazyNative { } return (java.lang.Short) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public int getIntField() { java.lang.Object value = this.intField.get(); if (value == null) { @@ -68,7 +68,7 @@ class GetterLazyNative { } return (java.lang.Integer) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public long getLongField() { java.lang.Object value = this.longField.get(); if (value == null) { @@ -83,7 +83,7 @@ class GetterLazyNative { } return (java.lang.Long) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public float getFloatField() { java.lang.Object value = this.floatField.get(); if (value == null) { @@ -98,7 +98,7 @@ class GetterLazyNative { } return (java.lang.Float) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public double getDoubleField() { java.lang.Object value = this.doubleField.get(); if (value == null) { @@ -113,7 +113,7 @@ class GetterLazyNative { } return (java.lang.Double) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public char getCharField() { java.lang.Object value = this.charField.get(); if (value == null) { @@ -128,7 +128,7 @@ class GetterLazyNative { } return (java.lang.Character) value; } - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public int[] getIntArrayField() { java.lang.Object value = this.intArrayField.get(); if (value == null) { diff --git a/test/transform/resource/after-delombok/GetterLazyTransient.java b/test/transform/resource/after-delombok/GetterLazyTransient.java index 49093ed1..0fd85621 100644 --- a/test/transform/resource/after-delombok/GetterLazyTransient.java +++ b/test/transform/resource/after-delombok/GetterLazyTransient.java @@ -2,7 +2,7 @@ class GetterLazyTransient { private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> nonTransientField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); private final transient int transientField = 2; private final transient int nonLazyTransientField = 3; - @java.lang.SuppressWarnings("all") + @java.lang.SuppressWarnings({"all", "unchecked"}) public int getNonTransientField() { java.lang.Object value = this.nonTransientField.get(); if (value == null) { |