Skip to content

Commit c93400d

Browse files
Rawi01rspilker
authored andcommitted
[fixes #2917] Use $value instead of value in lazy getter
1 parent 23307eb commit c93400d

23 files changed

+361
-361
lines changed

src/core/lombok/eclipse/handlers/HandleGetter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2009-2022 The Project Lombok Authors.
2+
* Copyright (C) 2009-2024 The Project Lombok Authors.
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -323,7 +323,7 @@ public Statement[] createSimpleGetterBody(ASTNode source, EclipseNode fieldNode)
323323
TYPE_MAP = Collections.unmodifiableMap(m);
324324
}
325325

326-
private static char[] valueName = "value".toCharArray();
326+
private static char[] valueName = "$value".toCharArray();
327327
private static char[] actualValueName = "actualValue".toCharArray();
328328

329329
private static final int PARENTHESIZED = (1 << ASTNode.ParenthesizedSHIFT) & ASTNode.ParenthesizedMASK;

src/core/lombok/javac/handlers/HandleGetter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2009-2022 The Project Lombok Authors.
2+
* Copyright (C) 2009-2024 The Project Lombok Authors.
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -358,7 +358,7 @@ public List<JCStatement> createLazyGetterBody(JavacTreeMaker maker, JavacNode fi
358358
}
359359
if (copyOfBoxedFieldType == null) copyOfBoxedFieldType = copyType(maker, field, source);
360360

361-
Name valueName = fieldNode.toName("value");
361+
Name valueName = fieldNode.toName("$value");
362362
Name actualValueName = fieldNode.toName("actualValue");
363363

364364
/* java.lang.Object value = this.fieldName.get();*/ {

test/transform/resource/after-delombok/DelegateOnGetter.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ private interface Bar {
66
}
77
@java.lang.SuppressWarnings({"all", "unchecked"})
88
public Bar getBar() {
9-
java.lang.Object value = this.bar.get();
10-
if (value == null) {
9+
java.lang.Object $value = this.bar.get();
10+
if ($value == null) {
1111
synchronized (this.bar) {
12-
value = this.bar.get();
13-
if (value == null) {
12+
$value = this.bar.get();
13+
if ($value == null) {
1414
final Bar actualValue = new Bar() {
1515
public void setList(java.util.ArrayList<String> list) {
1616
}
1717
public int getInt() {
1818
return 42;
1919
}
2020
};
21-
value = actualValue == null ? this.bar : actualValue;
22-
this.bar.set(value);
21+
$value = actualValue == null ? this.bar : actualValue;
22+
this.bar.set($value);
2323
}
2424
}
2525
}
26-
return (Bar) (value == this.bar ? null : value);
26+
return (Bar) ($value == this.bar ? null : $value);
2727
}
2828
@java.lang.SuppressWarnings("all")
2929
public void setList(final java.util.ArrayList<java.lang.String> list) {

test/transform/resource/after-delombok/GetterLazy.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ static class ValueType {
44
private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> fieldName = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>();
55
@java.lang.SuppressWarnings({"all", "unchecked"})
66
public ValueType getFieldName() {
7-
java.lang.Object value = this.fieldName.get();
8-
if (value == null) {
7+
java.lang.Object $value = this.fieldName.get();
8+
if ($value == null) {
99
synchronized (this.fieldName) {
10-
value = this.fieldName.get();
11-
if (value == null) {
10+
$value = this.fieldName.get();
11+
if ($value == null) {
1212
final ValueType actualValue = new ValueType();
13-
value = actualValue == null ? this.fieldName : actualValue;
14-
this.fieldName.set(value);
13+
$value = actualValue == null ? this.fieldName : actualValue;
14+
this.fieldName.set($value);
1515
}
1616
}
1717
}
18-
return (ValueType) (value == this.fieldName ? null : value);
18+
return (ValueType) ($value == this.fieldName ? null : $value);
1919
}
2020
}

test/transform/resource/after-delombok/GetterLazyArguments.java

+42-42
Original file line numberDiff line numberDiff line change
@@ -21,99 +21,99 @@ static String stringRunnable(String arg1, Runnable arg2) {
2121

2222
@java.lang.SuppressWarnings({"all", "unchecked"})
2323
public String getField1() {
24-
java.lang.Object value = this.field1.get();
25-
if (value == null) {
24+
java.lang.Object $value = this.field1.get();
25+
if ($value == null) {
2626
synchronized (this.field1) {
27-
value = this.field1.get();
28-
if (value == null) {
27+
$value = this.field1.get();
28+
if ($value == null) {
2929
final String actualValue = stringInt(("a"), (1));
30-
value = actualValue == null ? this.field1 : actualValue;
31-
this.field1.set(value);
30+
$value = actualValue == null ? this.field1 : actualValue;
31+
this.field1.set($value);
3232
}
3333
}
3434
}
35-
return (String) (value == this.field1 ? null : value);
35+
return (String) ($value == this.field1 ? null : $value);
3636
}
3737

3838
@java.lang.SuppressWarnings({"all", "unchecked"})
3939
public String getField2() {
40-
java.lang.Object value = this.field2.get();
41-
if (value == null) {
40+
java.lang.Object $value = this.field2.get();
41+
if ($value == null) {
4242
synchronized (this.field2) {
43-
value = this.field2.get();
44-
if (value == null) {
43+
$value = this.field2.get();
44+
if ($value == null) {
4545
final String actualValue = stringInt(true ? "a" : "b", true ? 1 : 0);
46-
value = actualValue == null ? this.field2 : actualValue;
47-
this.field2.set(value);
46+
$value = actualValue == null ? this.field2 : actualValue;
47+
this.field2.set($value);
4848
}
4949
}
5050
}
51-
return (String) (value == this.field2 ? null : value);
51+
return (String) ($value == this.field2 ? null : $value);
5252
}
5353

5454
@java.lang.SuppressWarnings({"all", "unchecked"})
5555
public String getField3() {
56-
java.lang.Object value = this.field3.get();
57-
if (value == null) {
56+
java.lang.Object $value = this.field3.get();
57+
if ($value == null) {
5858
synchronized (this.field3) {
59-
value = this.field3.get();
60-
if (value == null) {
59+
$value = this.field3.get();
60+
if ($value == null) {
6161
final String actualValue = stringInt(("a"), true ? 1 : 0);
62-
value = actualValue == null ? this.field3 : actualValue;
63-
this.field3.set(value);
62+
$value = actualValue == null ? this.field3 : actualValue;
63+
this.field3.set($value);
6464
}
6565
}
6666
}
67-
return (String) (value == this.field3 ? null : value);
67+
return (String) ($value == this.field3 ? null : $value);
6868
}
6969

7070
@java.lang.SuppressWarnings({"all", "unchecked"})
7171
public String getField4() {
72-
java.lang.Object value = this.field4.get();
73-
if (value == null) {
72+
java.lang.Object $value = this.field4.get();
73+
if ($value == null) {
7474
synchronized (this.field4) {
75-
value = this.field4.get();
76-
if (value == null) {
75+
$value = this.field4.get();
76+
if ($value == null) {
7777
final String actualValue = stringRunnable(fun(), () -> {
7878
});
79-
value = actualValue == null ? this.field4 : actualValue;
80-
this.field4.set(value);
79+
$value = actualValue == null ? this.field4 : actualValue;
80+
this.field4.set($value);
8181
}
8282
}
8383
}
84-
return (String) (value == this.field4 ? null : value);
84+
return (String) ($value == this.field4 ? null : $value);
8585
}
8686

8787
@java.lang.SuppressWarnings({"all", "unchecked"})
8888
public String getField5() {
89-
java.lang.Object value = this.field5.get();
90-
if (value == null) {
89+
java.lang.Object $value = this.field5.get();
90+
if ($value == null) {
9191
synchronized (this.field5) {
92-
value = this.field5.get();
93-
if (value == null) {
92+
$value = this.field5.get();
93+
if ($value == null) {
9494
final String actualValue = stringRunnable(("a"), () -> {
9595
});
96-
value = actualValue == null ? this.field5 : actualValue;
97-
this.field5.set(value);
96+
$value = actualValue == null ? this.field5 : actualValue;
97+
this.field5.set($value);
9898
}
9999
}
100100
}
101-
return (String) (value == this.field5 ? null : value);
101+
return (String) ($value == this.field5 ? null : $value);
102102
}
103103

104104
@java.lang.SuppressWarnings({"all", "unchecked"})
105105
public String getField6() {
106-
java.lang.Object value = this.field6.get();
107-
if (value == null) {
106+
java.lang.Object $value = this.field6.get();
107+
if ($value == null) {
108108
synchronized (this.field6) {
109-
value = this.field6.get();
110-
if (value == null) {
109+
$value = this.field6.get();
110+
if ($value == null) {
111111
final String actualValue = true ? stringInt(true ? "a" : "b", true ? 1 : 0) : "";
112-
value = actualValue == null ? this.field6 : actualValue;
113-
this.field6.set(value);
112+
$value = actualValue == null ? this.field6 : actualValue;
113+
this.field6.set($value);
114114
}
115115
}
116116
}
117-
return (String) (value == this.field6 ? null : value);
117+
return (String) ($value == this.field6 ? null : $value);
118118
}
119119
}

test/transform/resource/after-delombok/GetterLazyBoolean.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,32 @@ public java.lang.String toString() {
3333
}
3434
@java.lang.SuppressWarnings({"all", "unchecked"})
3535
public boolean isBooleanValue() {
36-
java.lang.Object value = this.booleanValue.get();
37-
if (value == null) {
36+
java.lang.Object $value = this.booleanValue.get();
37+
if ($value == null) {
3838
synchronized (this.booleanValue) {
39-
value = this.booleanValue.get();
40-
if (value == null) {
39+
$value = this.booleanValue.get();
40+
if ($value == null) {
4141
final boolean actualValue = calculateBoolean();
42-
value = actualValue;
43-
this.booleanValue.set(value);
42+
$value = actualValue;
43+
this.booleanValue.set($value);
4444
}
4545
}
4646
}
47-
return (java.lang.Boolean) value;
47+
return (java.lang.Boolean) $value;
4848
}
4949
@java.lang.SuppressWarnings({"all", "unchecked"})
5050
public boolean isOtherBooleanValue() {
51-
java.lang.Object value = this.otherBooleanValue.get();
52-
if (value == null) {
51+
java.lang.Object $value = this.otherBooleanValue.get();
52+
if ($value == null) {
5353
synchronized (this.otherBooleanValue) {
54-
value = this.otherBooleanValue.get();
55-
if (value == null) {
54+
$value = this.otherBooleanValue.get();
55+
if ($value == null) {
5656
final boolean actualValue = !calculateBoolean();
57-
value = actualValue;
58-
this.otherBooleanValue.set(value);
57+
$value = actualValue;
58+
this.otherBooleanValue.set($value);
5959
}
6060
}
6161
}
62-
return (java.lang.Boolean) value;
62+
return (java.lang.Boolean) $value;
6363
}
6464
}

test/transform/resource/after-delombok/GetterLazyEahcToString.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,18 @@ public java.lang.String toString() {
4646

4747
@java.lang.SuppressWarnings({"all", "unchecked"})
4848
public String getValue() {
49-
java.lang.Object value = this.value.get();
50-
if (value == null) {
49+
java.lang.Object $value = this.value.get();
50+
if ($value == null) {
5151
synchronized (this.value) {
52-
value = this.value.get();
53-
if (value == null) {
52+
$value = this.value.get();
53+
if ($value == null) {
5454
final String actualValue = "";
55-
value = actualValue == null ? this.value : actualValue;
56-
this.value.set(value);
55+
$value = actualValue == null ? this.value : actualValue;
56+
this.value.set($value);
5757
}
5858
}
5959
}
60-
return (String) (value == this.value ? null : value);
60+
return (String) ($value == this.value ? null : $value);
6161
}
6262

6363
@java.lang.SuppressWarnings("all")

test/transform/resource/after-delombok/GetterLazyErrorPosition.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ class GetterLazyErrorPosition {
33

44
@java.lang.SuppressWarnings({"all", "unchecked"})
55
public String getField() {
6-
java.lang.Object value = this.field.get();
7-
if (value == null) {
6+
java.lang.Object $value = this.field.get();
7+
if ($value == null) {
88
synchronized (this.field) {
9-
value = this.field.get();
10-
if (value == null) {
9+
$value = this.field.get();
10+
if ($value == null) {
1111
final String actualValue = true ? "" : new ErrorPosition();
12-
value = actualValue == null ? this.field : actualValue;
13-
this.field.set(value);
12+
$value = actualValue == null ? this.field : actualValue;
13+
this.field.set($value);
1414
}
1515
}
1616
}
17-
return (String) (value == this.field ? null : value);
17+
return (String) ($value == this.field ? null : $value);
1818
}
1919
}

test/transform/resource/after-delombok/GetterLazyGenerics.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,32 @@ public static <E> E getAny() {
66
}
77
@java.lang.SuppressWarnings({"all", "unchecked"})
88
public E getField() {
9-
java.lang.Object value = this.field.get();
10-
if (value == null) {
9+
java.lang.Object $value = this.field.get();
10+
if ($value == null) {
1111
synchronized (this.field) {
12-
value = this.field.get();
13-
if (value == null) {
12+
$value = this.field.get();
13+
if ($value == null) {
1414
final E actualValue = getAny();
15-
value = actualValue == null ? this.field : actualValue;
16-
this.field.set(value);
15+
$value = actualValue == null ? this.field : actualValue;
16+
this.field.set($value);
1717
}
1818
}
1919
}
20-
return (E) (value == this.field ? null : value);
20+
return (E) ($value == this.field ? null : $value);
2121
}
2222
@java.lang.SuppressWarnings({"all", "unchecked"})
2323
public long getField2() {
24-
java.lang.Object value = this.field2.get();
25-
if (value == null) {
24+
java.lang.Object $value = this.field2.get();
25+
if ($value == null) {
2626
synchronized (this.field2) {
27-
value = this.field2.get();
28-
if (value == null) {
27+
$value = this.field2.get();
28+
if ($value == null) {
2929
final long actualValue = System.currentTimeMillis();
30-
value = actualValue;
31-
this.field2.set(value);
30+
$value = actualValue;
31+
this.field2.set($value);
3232
}
3333
}
3434
}
35-
return (java.lang.Long) value;
35+
return (java.lang.Long) $value;
3636
}
3737
}

0 commit comments

Comments
 (0)