Files
openide/plugins/lombok/testData/highlighting/GetterLazyVariableNotInitialized.java
Michail Plushnikov 9cd5278c5b [lombok] IDEA-255688 consolidated tests/examples for all remaining lombok highlight error filter
GitOrigin-RevId: 784ccab86eecf0921b09b65ff1dde7b079f651be
2021-04-03 20:38:43 +00:00

37 lines
1.1 KiB
Java

import lombok.Getter;
public class GetterLazyVariableNotInitialized {
private final String hoge;
public GetterLazyVariableNotInitialized(String hoge) {
this.hoge = hoge;
}
// without error
@Getter(lazy = true)
private final String method = hoge;
// with error "Variable .. might not have been initialized"
@Getter
private final String methodWithError = <error descr="Variable 'hoge' might not have been initialized">hoge</error>;
/* Example Lombok will change 'method' to:
private final AtomicReference<Object> method = new AtomicReference();
public String getMethod() {
Object value = this.method.get();
if (value == null) {
synchronized(this.method) {
value = this.method.get();
if (value == null) {
String actualValue = this.hoge;
value = actualValue == null ? this.method : actualValue;
this.method.set(value);
}
}
}
return (String)(value == this.method ? null : value);
}
*/
}