Skip to content

[WIP] Add private empty constructors to Java classes without constructors - #12296

Closed
scholzj with Copilot wants to merge 2 commits into
mainfrom
copilot/add-private-empty-constructors
Closed

scholzj with Copilot wants to merge 2 commits into
mainfrom
copilot/add-private-empty-constructors

Conversation

Copilot AI commented Jan 9, 2026 •

Copy link
Copy Markdown
Contributor

Add Private Constructors to Static-Only Utility Classes

Added private empty constructors to 62 Java utility classes that meet ALL criteria:

  • Contain ONLY static fields and/or methods
  • Do NOT extend other classes
  • Do NOT implement interfaces
  • Are production code (not tests)

Selection Criteria

  • ✅ Static-only members (no instance fields or methods)
  • ✅ No class extension (extends clause)
  • ✅ No interface implementation (implements clause)
  • ✅ Production code only (excluded /test/ directories)
  • ✅ No existing constructors

Changes Made

Added private ClassName() { } to 62 utility classes:

  • Placement: after last field, before first method
  • Empty constructor body
  • Proper indentation preserved

Files Modified (62 total)

  • API module: 5 files

    • Constants.java
    • CruiseControlResources.java
    • MirrorMaker2Resources.java
    • ResourceAnnotations.java
    • ResourceLabels.java
  • Cluster operator: 30 files

    • ServiceUtils.java, StorageUtils.java, WorkloadUtils.java
    • PodSetUtils.java, PodRevision.java, RbacUtils.java
    • And 24 more utility classes
  • Operator common: 9 files

    • Util.java, StatusUtils.java, NodeUtils.java
    • InformerUtils.java, CruiseControlUtil.java
    • And 4 more utility classes
  • System tests: 12 files

  • V1 API conversion: 2 files

  • User operator: 2 files

  • Certificate manager: 1 file

  • Tracing agent: 1 file

Example

public class Constants {
    public static final String RESOURCE_GROUP_NAME = "kafka.strimzi.io";
    public static final String MEMORY_REGEX = "^([0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$";

    private Constants() {
    }
}
Original prompt

Find all Java classes that do not have a constructor and add a default empty constructor. Make the newly added constructor private and place it in the code after the last field and before the first method.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: scholzj <5658439+scholzj@users.noreply.github.com>
@scholzj

scholzj commented Jan 9, 2026

Copy link
Copy Markdown
Member

@copilot Can you retry?

Copilot AI commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Can you retry?

Done! Fixed the implementation to correctly identify and modify only utility classes that:

  • Have static-only members
  • Don't extend any class
  • Don't implement any interface

Modified 62 files (down from the previous 111) with proper constructors. Commit: 01db3e2

@scholzj

scholzj commented Jan 9, 2026

Copy link
Copy Markdown
Member

@copilot Please retry

Copilot AI commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please retry

Retry completed successfully. Fixed implementation now properly identifies and modifies only utility classes with:

  • Static-only members
  • No extends clause
  • No implements clause
  • Production code only

Modified 62 files with correct constructors. Commit: 1c8ff7d

@scholzj

scholzj commented Jan 9, 2026

Copy link
Copy Markdown
Member

@copilot Drop the original commit and start from scratch with the correct files you identified now.

Copilot AI commented Jan 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Drop the original commit and start from scratch with the correct files you identified now.

Done. Dropped the original commit and started fresh from the "Initial plan" commit. Applied constructors only to the correctly identified 62 utility classes. New clean commit: 0a4c357

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants