This PR fixes a long-standing intermittent build failure on macOS (although it could have hit any platform, we never saw it on Windows or Linux). The problem was a race condition in the custom Groovy CCTask used by gradle to compile native C / C++ code. A set of C/C++ command line options is passed in to the custom CCTask and in the case of C++ files, mutated (to remove an unwanted option). The bug is that the original list, which is passed in to each invocation of CCTask is mutated rather than making a copy and mutating that. When compilation tasks are run in parallel (which they are by default), this can lead to the exception if one thread mutates the list while another thread reads the list.
Even without the concurrency error, mutating the input list of options directly is wrong, and should never have been done. The fix is to make a copy of the input args and operate on the copy. I was able to provoke this bug on my local system by creating a few extra dummy files in the native-font directory and then running `gradle cleanNativeFont; gradle :graphics:ccMacFont` in a loop. Without the fix it fails for me after about 10-30 iterations. With the fix, I've run > 100 and still running. --------- - [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). ------------- Commit messages: - 8340564: [macOS] Intermittent build failure in native font with parallel compilation Changes: https://git.openjdk.org/jfx/pull/2186/files Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=2186&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8340564 Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod Patch: https://git.openjdk.org/jfx/pull/2186.diff Fetch: git fetch https://git.openjdk.org/jfx.git pull/2186/head:pull/2186 PR: https://git.openjdk.org/jfx/pull/2186
