On Fri, 16 Oct 2026 15:13:08 GMT, Yunbo Zhang <[email protected]> wrote:

> 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`.
> - `com/sun/jdi`: 191 passed (1 excluded by the existing ProblemList)
> - `vmTestbase/nsk/jdi`: 1143 passed (including 2 skips for a transport 
> unsupported)
> - `vmTestbase/nsk/jdwp`: 114 passed (1 excluded by the existing ProblemList)
> - `vmTestbase/nsk/jdb`: 68 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).

This pull request has now been integrated.

Changeset: e37ebb04
Author:    Yunbo Zhang <[email protected]>
Committer: Serguei Spitsyn <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/e37ebb048d738b8432bdc97392c7b0634ecc4faf
Stats:     122 lines in 2 files changed: 73 ins; 29 del; 20 mod

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

Reviewed-by: cjplummer, sspitsyn

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

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

Reply via email to