Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Java/more thread safe initialisers#20910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
yoff wants to merge3 commits intogithub:main
base:main
Choose a base branch
Loading
fromyoff:java/more-thread-safe-initialisers

Conversation

@yoff
Copy link
Contributor

When a field is assigned a safe type in a constructor, that field is not exposed.

CopilotAI review requested due to automatic review settingsNovember 25, 2025 14:52
@yoffyoff requested a review froma team as acode ownerNovember 25, 2025 14:52
Copilot finished reviewing on behalf ofyoffNovember 25, 2025 14:55
Copy link
Contributor

CopilotAI 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 enhances Java thread safety analysis to recognize when fields are initialized with thread-safe types inside constructors, not just in field initializer expressions. This reduces false positives when fields are assigned thread-safe collections (likeConcurrentHashMap or synchronized maps) in constructors.

Key Changes:

  • AddedinitialValue predicate to check both field initializers and constructor assignments
  • ModifiedExposedField class to use the new predicate for more comprehensive thread-safety checking
  • Added comprehensive test coverage for the new functionality

Reviewed changes

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

FileDescription
java/ql/lib/semmle/code/java/ConflictingAccess.qllImplements the core logic by addinginitialValue predicate and updatingExposedField to check constructor assignments
java/ql/test/query-tests/ThreadSafe/examples/ThreadSafeInitializers.javaAdds test cases demonstrating thread-safe initialization patterns in constructors
java/ql/test/query-tests/ThreadSafe/ThreadSafe.expectedUpdates expected test results to include the new test case alert
java/ql/src/change-notes/2025-11-25-thread-safe-initializers.mdDocuments the enhancement in the release notes

💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.

yoffand others added3 commitsNovember 25, 2025 18:10
Co-authored-by: Raúl Pardo <raul.pardo@protonmail.com>
Whne a fiels is assigned a safe type in a constructor,that field is not exposed.
@yoffyoffforce-pushed thejava/more-thread-safe-initialisers branch from52296d4 toefb6a79CompareNovember 25, 2025 17:14
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@yoff

[8]ページ先頭

©2009-2025 Movatter.jp