Skip to content

Conversation

smowton
Copy link
Contributor

@smowton smowton commented Sep 30, 2025

Quick drive-by FP fix found while triaging autofixes.

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

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

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

1 participant