Skip to content

Bug: Source Action -> "Generate Constructors..." only available after at least one class member was added #1352

Todo

Description

@Eden33

Environment:

  • VS Code Version: 1.89.1
  • Extension Version: v0.26.0
  • JDK Type & Version: Java version: 17.0.9, vendor: Oracle Corporation
  • OS Type & Version: Windows 11

Step to Reproduce:
2024-06-04_19h03_46

Expected Behavior:
The "Generate Constructors ..." option should instantly be available without the requirement to add a class member.

Actual Behavior:
The "Generate Constructors ..." option becomes available earliest when a single class member was added.

Additional comment:
This behaviour is also available in IntelliJ and makes sense.

Related Issues: No related issues found.

Activity

  1. github-actions commented on Nov 4, 2025

    @github-actions

    Hi Eduard Gopp (@Eden33), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.

    It looks like the JDT LS only offers “Generate Constructors…” when there are fields to initialize—because an empty (no-arg) constructor is implicit, the action isn’t shown for a totally empty class.

    Workarounds & suggestions:

    Other references worth checking:

    Other references with low confidence

    The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!

  2. issuelens commented on Nov 26, 2026

    @issuelens

    Thanks for reporting the missing Generate Constructors… action on an empty class. We didn’t find a matching duplicate.

    The Java Pack bundles the Java language support that provides this source action; the Pack does not declare the action itself. A likely explanation is that Java already gives an empty class an implicit no-argument constructor, so—with no fields or explicit superclass-constructor choices—the generator has nothing to select. We have not confirmed that rationale in the upstream implementation.

    As a workaround, you can add the explicit constructor manually, for example:

    public MyClass() {
        super();
    }

    Because the reported VS Code and extension versions are older, could you retest with current VS Code and redhat.java? If it still occurs, please share the smallest class that reproduces it and the exact current extension versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions