RFR: 8256189: Exact VarHandle tests should test withInvokeBehavior() works as expected

Jorn Vernee jvernee at openjdk.java.net
Tue Nov 17 18:38:08 UTC 2020


This PR sharpens the testing done by test/jdk/java/lang/invoke/VarHandles/VarHandleTestExact.java after @mcimadamore reported that the test was not catching an issue with memory access var handles; namely that the implementation of withInvokeBehavior was incorrect.

After some debugging it turned out that the test never actually tested:
(1) going back to invoke behavior from a var handle with invoke exact behavior
(2) the memory access handle implementation of withInvoke(Exact)Behavior, due to memory handles always being adapted.

The patch adds testing for (1), and adds a flag to jdk.internal.foreign.Utils to turn off the adaptation, so that we can test the 'naked' memory access var handles as well for (2).

I've also tried to reduce some of the code duplication by creating the higher order doTest function, that does most of the testing (besides setting up var handles and test values).

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

Commit messages:
 - Fix memory handles test to use un-adapted var handles, so we can test the invoke exact behaviour on 'naked' memory handles
 - - Reduce VarHandleTestExact code duplication

Changes: https://git.openjdk.java.net/jdk/pull/1267/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=1267&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8256189
  Stats: 173 lines in 3 files changed: 48 ins; 80 del; 45 mod
  Patch: https://git.openjdk.java.net/jdk/pull/1267.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/1267/head:pull/1267

PR: https://git.openjdk.java.net/jdk/pull/1267


More information about the core-libs-dev mailing list