Repository navigation
Conversation
…s not thread safe
|
👋 Welcome back liach! A progress list of the required criteria for merging this PR into |
Webrevs
|
|
@liach This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 688 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@cl4es) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
Hello @liach, I don't follow what this change is achieving. I think I might be missing something though. I read through the linked JIRA which states:
Considering the I can understand that the The JBS issue also states:
I had a look at the RFR https://mail.openjdk.org/pipermail/core-libs-dev/2013-June/017798.html. That's a slightly different issue, from what I understand. In that case, the call to getGenericInfo() was being preceded by a call to some other expensive method. The change there proposed to first call getGenericInfo() and let it be initialized and only then decide whether to call the other expensive methods. |
|
I think of this pattern of reading a to-be-lazily-initialized value into a local as simple hygiene, |
|
The field needs to be volatile for these construction races to be thread-safe, otherwise no guarantee that seeing a non-null genericInfo will mean you see any writes done by the factory methods. |
|
We don't fear calling the factory twice for benign races, as the distinct constructor factory instances are behaviorally the same. The true issue lies in the double getfield operations: Java memory model doesn't require the second read to happen-after a write reflected in the first read, so return this.genericInfo may return null while this.genericInfo == null evaluates to false, in case genericInfo is initialized lazily by another thread. See https://bugs.openjdk.org/browse/JDK-8261404 |
|
Hi @liach, I think @dholmes-ora is worried about the fields in the object being returned by the getGenericInfo() method and similar. In above case this means fields in class ConstructorRepository.
Such objects may be published via data race and still be seen consistent on the accepting side. |
|
/integrate |
|
Thanks @plevart that was exactly my concern but I didn't have time to check whether the returned object could be safely published regardless of any race condition. Is it specified that way, or just a fortuitous occurrence? I would also be concerned about the guarantee of idempotency from the factory method - I hope its requirements in that area are clearly documented. |
The spec for the getGenericXXX methods are "Return a" rather than "Return the" so there shouldn't be any expectation on identity. The question about idempotency might be worth checking into as the underlying factory for reflective generic type objects does interact with the defining class loader. |
|
I've updated the fields to be volatile.
These objects should always be resolving types with the class loader of the declaring class in CoreReflectionsFctory::getDeclsLoader, so the resolved Class instances should be always the same. As far as I see, Type instances are otherwise compared by equals instead of identity, so returning distinct but equal type instances should be safe. |
|
@liach This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
keep-alive. Using volatile to ensure correctness of program order is still better than reading |
|
/integrate |
|
I don't have any issue with this version. Making the fields volatile is currently unnecessary to ensure correctness -- thanks @plevart for double-checking that all fields in the hierarchy is either |
|
/sponsor |
|
Going to push as commit be36096.
Your commit was automatically rebased without conflicts. |
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/12643/head:pull/12643$ git checkout pull/12643Update a local copy of the PR:
$ git checkout pull/12643$ git pull https://git.openjdk.org/jdk.git pull/12643/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 12643View PR using the GUI difftool:
$ git pr show -t 12643Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12643.diff
Webrev
Link to Webrev Comment