FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Java: note that classes with entirely private constructors can't be subclassed by smowton · Pull Request #20560 · github/codeql · GitHub

/ codeql Public

Java: note that classes with entirely private constructors can't be subclassed - #20560

Merged
smowton merged 1 commit into
github:mainfrom
smowton:smowton/fix/start-in-constructor-fp
Oct 1, 2025
Merged

Java: note that classes with entirely private constructors can't be subclassed#20560
smowton merged 1 commit into
github:mainfrom
smowton:smowton/fix/start-in-constructor-fp

Conversation

smowton commented Sep 30, 2025

Copy link
Copy Markdown
Contributor

Quick drive-by FP fix found while triaging autofixes.

smowton requested a review from a team as a code owner September 30, 2025 12:57
Copilot AI review requested due to automatic review settings September 30, 2025 12:57
github-actions Bot added the Java label Sep 30, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull Request Overview

This PR fixes a false positive in the StartInConstructor query by recognizing that classes with only private constructors cannot be subclassed, making thread starts in their constructors safe.

Key changes:

  • Adds logic to detect classes with entirely private constructors
  • Updates the cannotBeExtended predicate to include this case
  • Adds a test case demonstrating the fix

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
java/ql/src/Likely Bugs/Concurrency/StartInConstructor.ql Enhanced query logic to recognize classes with all-private constructors as non-extendable
java/ql/test/query-tests/StartInConstructor/Test.java Added test case for class with private constructors that starts a thread

smowton force-pushed the smowton/fix/start-in-constructor-fp branch from 8fba678 to f88daff Compare September 30, 2025 12:57
smowton added the no-change-note-required This PR does not need a change note label Sep 30, 2025

aschackmull left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

smowton merged commit f5ae5be into github:main Oct 1, 2025
17 of 18 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL