Support JEP 513: this(...) after a constructor prologue
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Read NullAway.constructorInvokesAnother and trace how it checks constructor body statements, then inspect the related constructor analysis tests. Add a regression case with a statement before this(...); done means the example no longer reports an uninitialized @NonNull field, while existing constructor checks still pass.
Written by the indexing model from the issue text.
Description
JEP 513 (flexible constructor bodies) is final in Java 25. A constructor may now run statements before this(...). NullAway does not handle this case yet. It does not see the this(...) call, so it reports that the constructor does not initialize a @NonNull field.
import org.jspecify.annotations.NullMarked;
@NullMarked
class Example {
private String name;
Example(String name) {
this.name = name;
}
Example(String first, String last) {
String full = first + " " + last;
this(full);
}
}
Expected: no error. The second constructor calls this(full), and the first constructor initializes name.
Actual:
Example.java:[13,4] error: [NullAway] initializer method does not guarantee @NonNull field 'name' (line 7) is initialized along all control-flow paths (remember to check for exceptions or early returns).
There is no error when this(first + " " + last) is the first statement. There is also no error when the field is final.
NullAway.constructorInvokesAnother checks only the first statement of the body (statements.get(0)). With a prologue, the this(...) call is not the first statement. The code on master is the same.
Versions: NullAway 0.14.3, Error Prone 2.52.0, JDK 25.0.2. Options: OnlyNullMarked=true, JSpecifyMode=true.
- Dominant language
- Java
- Stars
- 4.1k
- Forks
- 379
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 106
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from uber/NullAway
-
Difficulty 1/5 1-3 hours Newbie friendliness 85/100
uber/NullAway#2058 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
uber/NullAway#1899 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
uber/NullAway#2160 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 50/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
johanhaleby/occurrent#1505 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
FasterXML/jackson-databind#6443 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
finos/fluxnova-bpm-platform#387 ·
Maintainers usually reply within 4 days
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100