-
Notifications
You must be signed in to change notification settings - Fork 91
Move statements before super(..) in Java constructor #733 #736
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
base: main
Are you sure you want to change the base?
Conversation
src/main/java/org/openrewrite/java/migrate/util/RelocateSuperCall.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- src/main/resources/META-INF/rewrite/examples.yml
- lines 997-1007
- lines 1036-1042
src/main/java/org/openrewrite/java/migrate/util/RelocateSuperCall.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/util/RelocateSuperCallTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/util/RelocateSuperCallTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/util/RelocateSuperCallTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- src/main/resources/META-INF/rewrite/examples.yml
- lines 997-1007
- lines 1036-1042
- lines 7108-7107
src/test/java/org/openrewrite/java/migrate/util/RelocateSuperCallTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/util/RelocateSuperCallTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- src/main/resources/META-INF/rewrite/examples.yml
- lines 997-1007
- lines 1036-1042
- lines 7108-7107
We're seeing some unrelated test failures; no need for alarm or debugging; we'll try to get those sorted soon. :) |
… YAML configuration to reflect the change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- src/main/resources/META-INF/rewrite/examples.yml
- lines 701-700
- lines 997-1007
- lines 1036-1042
} | ||
|
||
// Move super() to the end | ||
List<Statement> updated = new java.util.ArrayList<>(statements); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ATM you move the super()
call to the very end of a constructor call. If i recall correctly there are limitations regarding the reference to instance fields. Could you please revisit JEP 513s section about Early-construction-contexts and verify that we are producing JLS compliant code?
Thanks for your contribution, I love seeing new Language features been picked up :) I think 1 or 2 tests should be enough to make sure we are JLS compliant in the context of the Early construction contexts. |
What's changed?
Jep 513 calls for allowing statements before the call to super() in Java constructors, allowing for simple assignments and validations before doing expensive construction.
Java version >= 25
(Also double check Jep 513 lands in Java 25)
Before Applying Recipe
After Applying Recipe
What's your motivation?
Anything in particular you'd like reviewers to focus on?
Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
Any additional context
Checklist