RFR: 8291065: Creating a VarHandle for a static field triggers class initialization [v5]

Chen Liang liach at openjdk.org
Fri Jun 2 22:39:05 UTC 2023


On Fri, 2 Jun 2023 16:29:13 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

> I wonder if it is possible to transition from an lazy (indirect) VH to a direct VH once initialized i.e., `checkAccessModeThenIsDirect` returns the value of `initialized`. Thereby we reduce the potential footprint cost of inflating further MHs and take the more efficient route through the guard method on subsequent invocations.

Currently, the VH passed to linkToStatic-linked implementation methods must be of the correct implementation type. As a result, we have to at least add an `asDirect` call when we pass the VH instance, like the invocation for indirect VH's MHs. Would that be an acceptable refactor, or is that too costly as after constant folding, the two VHs already have similar performance?

-------------

PR Comment: https://git.openjdk.org/jdk/pull/13821#issuecomment-1574393507


More information about the core-libs-dev mailing list