Closed GoogleCodeExporter closed 9 years ago
> I resolved the issue by ... get rid of the lombok's @Data annotation and
producing getter-setters with Eclipse.
IMHO that's an outstandingly terrible solution. You could add a trivial
`toString` calling super and be done. You could also use
`ToString(exclude="InterestedParty")` in order to break the cycle. You could
replace `@Data` by `@Getter`, `@Setter`, and whatever else you need.
While Lombok could handle cycles, it's not free. The cost would be much longer
and slower code, auxiliary methods, thread-local magic, and/or a runtime
dependency. Note that neither JDK containers, nor Guava's and Apache's
`ToStringBuilder`, nor any class I've ever seen protects against cycles.
Original comment by Maaarti...@gmail.com
on 24 Jan 2015 at 11:40
As you said <<IMHO that's an outstandingly terrible solution. You could add a
trivial `toString` calling super and be done. You could also use
`ToString(exclude="InterestedParty")` in order to break the cycle. You could
replace `@Data` by `@Getter`, `@Setter`, and whatever else you need.>>
If you look at my comments carefully, I already mentioned it in point #1.
Terrible solution !!! Well, you could say that because as a Lombok tool
developer, you will want to promote your tool. I can't blame you.
Also... what is your explanation about debugging? Lombok is just good for
removing verbosity (or less code); that's all.
Thanks.
Original comment by mchi...@gmail.com
on 25 Jan 2015 at 6:56
For your information: the java standard libraries are also prone to stack
overflow problems. Try out the following code:
List<Object> list = new ArrayList<>();
list.add(list);
String content = "" + list;
As one of the core lombok developers, I am biased. I think
@ToString(exclude={"party"}) is very clear and concise.
Original comment by r.spilker
on 27 Jan 2015 at 4:54
[deleted comment]
I agree. Java standard libraries are also prone to StackOverflow. However in
the above scenario, the cyclic dependency was my main problem which caused the
build broken. The StackOverflow error occurred in this case because of the
cyclic dependency. Like I mentioned in my original post, developers won't even
have to worry about using ToString at all unless and until there is a
bi-directional relationship. In any other cases, no issues.
Anyway, you did not answer anything about the debugging problem (debugging of
getter-setters). Any clue or suggestion?
Thanks.
Original comment by mchi...@gmail.com
on 27 Jan 2015 at 8:23
#2 FYI, I'm not a Lombok developer (not even a contributor apart from some tiny
things), just a fan.
> If you look at my comments carefully, I already mentioned it in point #1.
You did, but you chose the worse solution. YMMV. For me, keeping the source
compact and clean is very important. And yes, that's all Lombok can do.
Concerning debugging, I guess you got no answer because there's no such
question? At least, I can't see it. When I run into a problem with a ToString
cycle, I just fix it. I don't try debug into trivial generated methods, just
like I don't try debug into bridge methods. It wouldn't work, but I couldn't
care less as there's nothing interesting there.
Original comment by Maaarti...@gmail.com
on 28 Jan 2015 at 6:12
[deleted comment]
[deleted comment]
[deleted comment]
[deleted comment]
As you mentioned <<When I run into a problem with a ToString cycle, I just fix
it. I don't try debug into trivial generated methods>>.
Answer: Neither do I. Let me explain: say you have a class with lomboks' @Data
annotated. Now read carefully: I an NOT talking about cyclic dependency and
ToString annotation. It is a different topic. (Cyclic dependency happens only
when there is bi-directional relationship and developer do not use ToString as
you mentioned). Now I will explain the debugging issue.
Let's say, at some point, your application is throwing an exception from UI
layer. E.G. you tick a checkbox in your page, you expect a boolean property
(someProperty) in your class to be true but it seems like the value is is still
false. What could be wrong? What is causing the value not to be updated? Is
ajax refresh working? Is the page re-rendered after a onclick event..... etc ..
etc.. lot of question. So you might want to debug whether the property values
are being set/updated correctly; if so, where or at what point; you might want
to set the debug point on isSomeProperty(), setSomeProperty() methods [don't
say you do not do debugging and you fix code without debugging). Can you do
that? You can't. Because there is NO is/get/set methods. Got it?
<<Concerning debugging, I guess you got no answer because there's no such
question?>>
Answer: I do not get it. Do you really have the answer? There is no such
question just because nobody asked it before? What's your point?
Thanks.
P.S. I am not expecting more answers like "I don't try debugging... I just fix
it... there is no such questions " ..... :). If you do not have the answer,
admit it.
Original comment by mchi...@gmail.com
on 28 Jan 2015 at 10:08
For debugging purposes you can always use delombok to (temporarily) convert
your files to plain java and use those files to compile and debug your project.
That said, there should really be no need to step into, say, a getter. Getters
and setters are simple. They do what they are supposed to do. If you get an
unexpected value, it's not the getter or setter that failed, but the one
calling the setter or constructor.
The Eclipse Outline View is also very helpful. If you right click on the lombok
generated method there are several useful options.
Toggle Method Breakpoint will break when the method is called. Although you
cannot see the actual source of the method, the Variables view will display the
values of the parameters. And Step Into, Over or Return will step to the
calling code. The Breakpoint View allows you to set more properties, allowing
for conditions, for instance to only break when a certain parameter is set, or
to break on exit, allowing inspection of state of the object.
The References option allows you to quickly find the callers of the lombok
generated code.
All in all, I think there are enough options to debug your lombok laced code.
Original comment by r.spilker
on 29 Jan 2015 at 5:16
Original issue reported on code.google.com by
mchi...@gmail.com
on 21 Jan 2015 at 7:56