mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
Used in case of lombok lazy Getter GitOrigin-RevId: 37699b68fd2431efe92d05e86a3b09cb59e673b8
33 lines
768 B
Java
33 lines
768 B
Java
import lombok.Getter;
|
|
|
|
public class GetterLazyInvocationProduceNPE {
|
|
private static class Bar {
|
|
public String sayHello() {
|
|
return "Bar{}";
|
|
}
|
|
}
|
|
|
|
private static class Car {
|
|
public String sayHello() {
|
|
return "Car{}";
|
|
}
|
|
}
|
|
|
|
private Bar <warning descr="Field 'bar' may be 'final'">bar</warning>;
|
|
private Car car;
|
|
|
|
public GetterLazyInvocationProduceNPE(Bar bar, Car car) {
|
|
this.bar = bar;
|
|
this.car = car;
|
|
}
|
|
|
|
// without warning
|
|
@Getter(lazy = true)
|
|
private final String barString = bar.sayHello();
|
|
|
|
//with warining!
|
|
@Getter
|
|
private final String carString = car.<warning descr="Method invocation 'sayHello' will produce 'NullPointerException'">sayHello</warning>();
|
|
|
|
}
|