My code is as followd
package test.lombok;
import lombok.*;
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class SuperClass {
private int foo;
@Getter
public static class SubClass extends SuperClass {
private int bar;
@Builder(toBuilder = true)
private SubClass(int foo, int bar) {
super(foo);
this.bar = bar;
}
}
}
As showed above, I'm trying to use @Builder(toBuilder = true) on a sub class.
When toBuilder set to false, there is no problem at all.
But when I set toBuilder = true, I got an compilation error "Error:java: foo has private access in test.lombok.SuperClass".
I'm wondering why does this happen and how to fix this.