mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 22:16:11 +00:00
Fixes #1236: Getter(lazy=true) now emits an error when used on a transient field
This commit is contained in:
1 parent
0727c8bfd3
commit
cf82dcfb80
8 files changed
+79
-4
No files matched your search
@@ -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)
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
5 'lazy' is not supported on transient fields.
|
||||
@@ -0,0 +1 @@
|
||||
5 'lazy' is not supported on transient fields.
|
||||
Reference in new issue
Block a user