-
-
Notifications
You must be signed in to change notification settings - Fork 776
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
Setting value in constructor aliases collections #1642
Comments
try to use .intercept(MethodCall.invoke(getConstructor(entityClass))
.onSuper()
.andThen(MethodCall.construct(HashSet.class.getConstructor())
.setsField(named(MODIFIED_FIELDS_TRACKER_FIELD_NAME))
)
); |
That seems to have worked! The only thing now is the decompiled constructor isn't calling super. Is that okay?
(Same behavior if lombok is replaced with manually-declared methods.) |
You could not load the class if it did not call super, I assume it's simply not printed as this is implicit. |
That's my assumption too. It's just a bit disconcerting that the .class bytecode doesn't render showing it. Could also be an IntelliJ limitation. Was going to try some command-line decompiler but jad isn't maintained, fernflower requires cloning their mirror, etc. Javap doesn't appear to be able to reconstruct pretty-printed source. |
What does javap show? |
In #1638 I thought we had a solution to defining a constructor that initializes a field to a value:
But that turns out to put the same collection in all instances of the class, instead of creating a new hash set per instance:
How can I create a new hash set each time?
The text was updated successfully, but these errors were encountered: