RFR: 8238549: Add explicit cast to correct implementation type in VarHandle implementation methods
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Thu Feb 6 01:25:12 UTC 2020
Hi,
as promised, I took a look into adding a bit more structure under our var handle implementations - more specifically, I've tweaked the signatures of the various implementation methods to take a plain VarHandle instead of a var handle implementation class.
This was tedious, but ultimately easy to do. Since, to do this in a complete way I also had to touch regular var handles (e.g. non-memory access ones), it seemed like a good idea to take an existing var handle test (VarHandleTestMethodTypeXYZ) and tweak it so that it tests all combinations of (adpated=yes/no, guards=yes/no). This revealed several issues in the adapter logic:
* first, varType() and coordinates() triggered a resolution of some of the underlying MH attached to the indirect handle - since this can fail with UOE, these methods could also fail spuriously with UOE which is wrong
* second, accessModeTypeUncached, in addition to the aforementioned problem, also had an issue in that it didn't make correct use of the direct handle target
* third, I realized that I did not update the lambda forms for var handle invokers to also call VarHandle::asDirect - this was causing issues when calling an adapted handle through the invoker
With these changes, all tests pass despite the extra layers of adaptation. So, in the end it turned out to be a fruitful bug hunt (thanks for the hint Paul!).
Cheers
Maurizio
-------------
Commits:
- 066559b2: Strengthen var handle checks
Changes: https://git.openjdk.java.net/panama-foreign/pull/6/files
Webrev: https://webrevs.openjdk.java.net/panama-foreign/6/webrev.00
Issue: https://bugs.openjdk.java.net/browse/JDK-8238549
Stats: 440 lines in 18 files changed: 227 ins; 0 del; 213 mod
Patch: https://git.openjdk.java.net/panama-foreign/pull/6.diff
Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/6/head:pull/6
PR: https://git.openjdk.java.net/panama-foreign/pull/6
More information about the panama-dev
mailing list