RFR: 8261407: ReflectionFactory.checkInitted() is not thread-safe [v3]
liach
duke at openjdk.java.net
Fri Jan 21 23:51:02 UTC 2022
> Upon review of [8261407](https://bugs.openjdk.java.net/browse/JDK-8261407), by design, duplicate initialization of ReflectionFactory should be safe as it performs side-effect-free property read actions, and the suggesting of making the `initted` field volatile cannot prevent concurrent initialization either; however, having `initted == true` published without the other fields' values is a possibility, which this patch addresses.
>
> This simulates what's done in `CallSite`'s constructor for `ConstantCallSite`. Please feel free to point out the problems with this patch, as I am relatively inexperienced in this field of fences and there are relatively less available documents. (Thanks to https://shipilev.net/blog/2014/on-the-fence-with-dependencies/)
liach has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
- Merge branch 'master' into 8261407-reflectionfactory
- Merge branch '8261407-reflectionfactory'
- Just use volatile directly to ensure read order
- 8261407: ReflectionFactory.checkInitted() is not thread-safe
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/6889/files
- new: https://git.openjdk.java.net/jdk/pull/6889/files/1deb5207..0afb76d1
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=6889&range=02
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=6889&range=01-02
Stats: 32523 lines in 992 files changed: 22689 ins; 5684 del; 4150 mod
Patch: https://git.openjdk.java.net/jdk/pull/6889.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/6889/head:pull/6889
PR: https://git.openjdk.java.net/jdk/pull/6889
More information about the core-libs-dev
mailing list