Please review this performance fix.

For reference arrays, `ArrayType.newInstance()` searches all loaded classes for 
the component class, which can be slow when many classes are loaded.

**Fix:**

Search the array's class loader first, with the global lookup as a fallback. 
Hidden classes continue to use the global lookup.

**Testing:**

- Added hidden-class and `int[][]` coverage to `NewInstanceTest`.
- `vmTestbase/nsk/jdi/ArrayType/newInstance`: 4 passed.
- Local JDI `Object[]` measurement with 70,000 additional classes: **17.27 
ms/call -> 0.156 ms/call**.

---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - 8343851: Slow new array creation in case of many classes loaded

Changes: https://git.openjdk.org/jdk/pull/33414/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33414&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8343851
  Stats: 122 lines in 2 files changed: 73 ins; 32 del; 17 mod
  Patch: https://git.openjdk.org/jdk/pull/33414.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/33414/head:pull/33414

PR: https://git.openjdk.org/jdk/pull/33414

Reply via email to