-
Notifications
You must be signed in to change notification settings - Fork 378
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
Adding a custom record constructor prevents successful compilation #10045
Comments
Workaround: public record Rec(String s) {
public Rec { }
public Rec(int i) {
this("" + i);
}
} Two stack traces I've identified that can come from this bug - this looks like the one reported:
And another that is similar, but not quite the same:
The bug is that when being called in this way, the "super" constructor is incorrectly identified as being a native method as it has no body. I'm still working out why it has no body - it appears that either JDT doesn't emit a body for the canonical record constructor if there is a non-default constructor declared, or GWT just doesn't read it properly - but if the canonical constructor is declared or no constructors are declared at all, it will correctly have the field assignments as expected. |
This is an upstream JDT bug, already fixed there: eclipse-jdt/eclipse.jdt.core#365. It appears that updating to 3.33 may resolve this. That version is also compiled to work with Java 11 so we should be safe to update, but it might be risky to do so on a point release like 2.12.2. We should be able to work around it in a way that still works when JDT is later updated, by detecting if the body is missing from the canonical constructor, and if so, generate the field assignments. There is a caveat here that this must end up in the GwtAstBuilder rather than in ImplementRecordComponents - since the field assignments never were generated, the first |
Very helpful 👍 |
**GWT version: 2.12.1
**Browser (with version): any
**Operating System: any
Description
A custom record constructor prevents successful compilation even if never invoked
Steps to reproduce
invoked like this
Known workarounds
Don't use custom constructors
Links to further discussions
The text was updated successfully, but these errors were encountered: