java-native-access / java-native-access/jna

Unsafe increment of static field

Open
#1,574 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
8.9k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

Mutable static fields should be synchronised to ensure safe publication.
There is no guarantee that the following code will generate unique names:

https://github.com/java-native-access/jna/blob/6706361d441f32280fcca61f8dd18c02c437e1af/contrib/platform/src/com/sun/jna/platform/win32/User32Util.java#L166-L170

The messageLoopId variable should probably be replaced by an AtomicLong.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in contrib/platform/src/com/sun/jna/platform/win32/User32Util.java around lines 166-170 and inspect how messageLoopId is incremented and used. Confirm the change preserves unique message names under concurrent access; done means the static counter is safely synchronized or atomic.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.