Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Data on extended objects broken on 1.16.22 #1712

Closed
aikar opened this issue Jun 3, 2018 · 4 comments
Closed

@Data on extended objects broken on 1.16.22 #1712

aikar opened this issue Jun 3, 2018 · 4 comments

Comments

@aikar
Copy link

aikar commented Jun 3, 2018

jdk8
1.16.16 and 1.16.20 compiled this code just fine
1.16.22 is broken

import lombok.Data;

@Data
public class Test1 {
    private final Integer foo;
    public Test1(Integer foo) {
        this.foo = foo;
    }
}
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data(staticConstructor = "x")
@EqualsAndHashCode(callSuper = true)
public class Test2 extends Test1 {
    public Test2(Integer foo) {
        super(foo);
    }
}

This worked in 1.16.16, updating to 1.12 breaks with:
[ERROR] /path/Test2.java:[13,1] Test1() has private access in Test1

Also having issues with

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project Empire: Compilation failure: Compilation failure:
[ERROR] EntitySummary.java:[19,1] EntityCounts() has private access in EntityCounts
[ERROR] ChunkEntitySummary.java:[20,1] EntitySummary() has private access in EntitySummary
[ERROR] UserResidenceOwner.java:[14,1] constructor ResidenceOwner in class ResidenceOwner cannot be applied to given types;
[ERROR] required: java.lang.String
[ERROR] found: no arguments
[ERROR] reason: actual and formal argument lists differ in length

This all worked before, and i can't figure out how to fix it.

These are all classes that inherit other data classes.

@aikar
Copy link
Author

aikar commented Jun 3, 2018

@Data
@AllArgsConstructor
public abstract class ResidenceOwner {
    String name;
}

@Data
@EqualsAndHashCode(callSuper = true)
public class UserResidenceOwner extends ResidenceOwner {
    private final long userId;

    public UserResidenceOwner(long userId, String name) {
        super(name);
        this.userId = userId;
    }

    public EmpireUser getUser() {
        return EmpireUser.getUser(userId);
    }
}

@aikar
Copy link
Author

aikar commented Jun 3, 2018

Related to #1708
Adding lombok.noArgsConstructor.extraPrivate = false also fixed it.

@andrebrait
Copy link
Contributor

andrebrait commented Jun 3, 2018

As a workaround for now, you can also put a @NoArgsConstructor before the @Data like this (this will make it generate the constructor instead of @Data):

@NoArgsConstructor
@Data
public class Foo {
}

In case you want it not to generate a constructor at all, you can use the access attribute set to NONE to make it not generate any no-args constructors.

@NoArgsConstructor(access = AccessLevel.NONE)
@Data
public class Foo {
}

@rspilker
Copy link
Collaborator

rspilker commented Jun 4, 2018

Yeah, we probably shouldn't add the no-args constructor for classes that extend something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants