Netflix / Netflix/dgs-codegen

Consider using all-args constructor automatically when JSpecify is enabled

Open
#884 0 comments 0 reactions 1 assignee View on GitHub

@sjohnr is already working on this.

Since Dec 1, 2025.

enhancement
Dominant language
Kotlin
Stars
217
Forks
116
PR merge metrics
No merged PRs in 30d

Description

It would be nice to omit the default no-arg constructor and use the all-args constructor when JSpecify annotations are generated (see gh-866). This would allow linting and static analysis tools to consider the generated types fully null-safe with no warnings.

Context:

By default, a no-arg constructor is generated for all Java types. Currently, this constructor is generated as private when generating JSpecify annotations on Java types. The all-args constructor is still optional and the no-arg constructor is used in the generated builder's build() method. Static analysis and linting tools cannot see that the no-arg constructor is private, the builder's build() method validates fields, and the all-args constructor is null-safe. This issue is flagged by IntelliJ code intentions with the following message on fields of the generated type:

@NullMarked fields must be initialized 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.