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(staticConstructor = "of") doesn't create static Constructor #464

Closed
lombokissues opened this issue Jul 14, 2015 · 7 comments
Closed
Assignees
Milestone

Comments

@lombokissues
Copy link

Migrated from Google Code (issue 391)

@lombokissues
Copy link
Author

👤 BigMichi1   🕗 Jul 06, 2012 at 08:29 UTC

What steps will reproduce the problem?

  1. annotate Class with @ Data(staticConstructor = "of")
  2. no Cstatic Constructor generated named of()
  3. verify with delombok on the anotated class

What is the expected output? What do you see instead?
Constructor should be created like mentioned in doc

What version of the product are you using? On what operating system?
0.11.2

Please provide any additional information below.

@lombokissues
Copy link
Author

👤 reinierz   🕗 Jul 10, 2012 at 23:08 UTC

Cannot reproduce. This simple testcase:

@ lombok.Data(staticConstructor="of")
public class Test {
private final String test;
}

run through java -jar lombok.jar delombok -p Test.java

shows that the static constructor IS showing up. Presumably there's something strange happening with your source code. Can you attach it in a comment?

deadline before marking as invalid: July 21st, 2012.

@lombokissues
Copy link
Author

👤 BigMichi1   🕗 Jul 11, 2012 at 17:36 UTC

my beans are defined in this way:

import lombok.Data;
import lombok.NoArgsConstructor;

import javax.annotation.Nonnull;

@ Data(staticConstructor = "of")
@ NoArgsConstructor(access = AccessLevel.PROTECTED)
public class test {
@ Nonnull
private Integer test;
}

@lombokissues
Copy link
Author

👤 r.spilker   🕗 Jul 16, 2012 at 11:21 UTC

Could be related to issue #469

@lombokissues
Copy link
Author

👤 reinierz   🕗 Jul 16, 2012 at 21:19 UTC

Not related to issue #469.

The problem is simple: When an explicit constructor annotation is present (i.e. @ NoArgsConstructor), @ Data just offloads all responsibilities to that parameter. Your code is buggy: You should use:

@ Data
@ NoArgsConstructor(staticName="of")

instead of:

@ Data(staticConstructor="of")
@ NoArgsConstructor

Note that your confusion is entirely justified, as lombok silently ignores you. We've added a feature to @ Data that it will warn you that your 'staticConstructor' is going to do absolutely nothing in this scenario.

This will be in 0.11.4, which will be released soon.

@lombokissues
Copy link
Author

👤 reinierz   🕗 Jul 16, 2012 at 22:21 UTC

You can watch the warnings in action in the edge release:

https://projectlombok.org/download-edge.html

@lombokissues
Copy link
Author

End of migration

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

2 participants