diff options
8 files changed, 79 insertions, 4 deletions
diff --git a/doc/changelog.markdown b/doc/changelog.markdown index 3aafea13..149c14c1 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -3,10 +3,11 @@ Lombok Changelog ### v1.16.11 "Edgy Guinea Pig" * v1.16.10 is the latest release -* CHANGE: `@Value` and `@FieldDefaults` no longer touch static fields [Issue #1254](https://github.com/rzwitserloot/lombok/issues/1254) * FEATURE: `var` is the mutable sister of `val`. For now experimental, and opt-in using `ALLOW` in the flagUsage configuration key. Thanks for the contribution, Bulgakov Alexander. -* BUGFIX: Annotation Processors that use ecj internally (dagger) no longer give linkage errors [Issue #1218](https://github.com/rzwitserloot/lombok/issues/1218) +* CHANGE: `@Value` and `@FieldDefaults` no longer touch static fields [Issue #1254](https://github.com/rzwitserloot/lombok/issues/1254) * BUGFIX: `val` in lambda expressions now work as expected [Issue #911](https://github.com/rzwitserloot/lombok/issues/911) +* BUGFIX: `Getter(lazy=true)` now emits an error message when used on a transient field [Issue #1236](https://github.com/rzwitserloot/lombok/issues/1236) +* BUGFIX: Annotation Processors that use ecj internally (dagger) no longer give linkage errors [Issue #1218](https://github.com/rzwitserloot/lombok/issues/1218) * PLATFORM: Red Hat JBoss Developer Studio is now correctly identified by the installer [Issue #1164](https://github.com/rzwitserloot/lombok/issues/1164) * BUGFIX: delombok: for-loops with initializers that are not local variables would be generated incorrectly [Issue #1076](https://github.com/rzwitserloot/lombok/issues/1076) diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java index 14f2fb72..77d678f2 100644 --- a/src/core/lombok/eclipse/handlers/HandleGetter.java +++ b/src/core/lombok/eclipse/handlers/HandleGetter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014 The Project Lombok Authors. + * Copyright (C) 2009-2016 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -183,6 +183,10 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { errorNode.addError("'lazy' requires the field to be private and final."); return; } + if ((field.modifiers & ClassFileConstants.AccTransient) != 0) { + errorNode.addError("'lazy' is not supported on transient fields."); + return; + } if (field.initialization == null) { errorNode.addError("'lazy' requires field initialization."); return; diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java index a330dbc1..0a2fe362 100644 --- a/src/core/lombok/javac/handlers/HandleGetter.java +++ b/src/core/lombok/javac/handlers/HandleGetter.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2014 The Project Lombok Authors. + * Copyright (C) 2009-2016 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -182,6 +182,10 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { source.addError("'lazy' requires the field to be private and final."); return; } + if ((fieldDecl.mods.flags & Flags.TRANSIENT) != 0) { + source.addError("'lazy' is not supported on transient fields."); + return; + } if (fieldDecl.init == null) { source.addError("'lazy' requires field initialization."); return; diff --git a/test/transform/resource/after-delombok/GetterLazyTransient.java b/test/transform/resource/after-delombok/GetterLazyTransient.java new file mode 100644 index 00000000..dbebad90 --- /dev/null +++ b/test/transform/resource/after-delombok/GetterLazyTransient.java @@ -0,0 +1,26 @@ +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") + @javax.annotation.Generated("lombok") + public int getNonTransientField() { + java.lang.Object value = this.nonTransientField.get(); + if (value == null) { + synchronized (this.nonTransientField) { + value = this.nonTransientField.get(); + if (value == null) { + final int actualValue = 1; + value = actualValue; + this.nonTransientField.set(value); + } + } + } + return (java.lang.Integer) value; + } + @java.lang.SuppressWarnings("all") + @javax.annotation.Generated("lombok") + public int getNonLazyTransientField() { + return this.nonLazyTransientField; + } +} diff --git a/test/transform/resource/after-ecj/GetterLazyTransient.java b/test/transform/resource/after-ecj/GetterLazyTransient.java new file mode 100644 index 00000000..9bc0d9ae --- /dev/null +++ b/test/transform/resource/after-ecj/GetterLazyTransient.java @@ -0,0 +1,28 @@ +class GetterLazyTransient { + private final @lombok.Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> nonTransientField = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>(); + private final transient @lombok.Getter(lazy = true) int transientField = 2; + private final transient @lombok.Getter int nonLazyTransientField = 3; + GetterLazyTransient() { + super(); + } + public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") int getNonTransientField() { + java.lang.Object value = this.nonTransientField.get(); + if ((value == null)) + { + synchronized (this.nonTransientField) + { + value = this.nonTransientField.get(); + if ((value == null)) + { + final int actualValue = 1; + value = actualValue; + this.nonTransientField.set(value); + } + } + } + return (java.lang.Integer) value; + } + public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") int getNonLazyTransientField() { + return this.nonLazyTransientField; + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/GetterLazyTransient.java b/test/transform/resource/before/GetterLazyTransient.java new file mode 100644 index 00000000..1a913669 --- /dev/null +++ b/test/transform/resource/before/GetterLazyTransient.java @@ -0,0 +1,10 @@ +class GetterLazyTransient { + @lombok.Getter(lazy=true) + private final int nonTransientField = 1; + + @lombok.Getter(lazy=true) + private final transient int transientField = 2; + + @lombok.Getter + private final transient int nonLazyTransientField = 3; +} diff --git a/test/transform/resource/messages-delombok/GetterLazyTransient.java.messages b/test/transform/resource/messages-delombok/GetterLazyTransient.java.messages new file mode 100644 index 00000000..8c1873eb --- /dev/null +++ b/test/transform/resource/messages-delombok/GetterLazyTransient.java.messages @@ -0,0 +1 @@ +5 'lazy' is not supported on transient fields.
\ No newline at end of file diff --git a/test/transform/resource/messages-ecj/GetterLazyTransient.java.messages b/test/transform/resource/messages-ecj/GetterLazyTransient.java.messages new file mode 100644 index 00000000..8c1873eb --- /dev/null +++ b/test/transform/resource/messages-ecj/GetterLazyTransient.java.messages @@ -0,0 +1 @@ +5 'lazy' is not supported on transient fields.
\ No newline at end of file |