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).

Nice refactoring. The fix looks good in general. Requested just a couple of 
nits.

src/jdk.jdwp.agent/share/native/libjdwp/ArrayTypeImpl.c line 98:

> 96: 
> 97:     /* Hidden classes and their arrays are not included in 
> GetClassLoaderClasses. */
> 98:     if (strchr(componentSignature, '.') == NULL) {

Nit: I'd suggest to add a comment at line 98 explaining that we are checking 
for non-hidden class case. You need to figure this out yourselves if there is 
no comment.

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

PR Review: https://git.openjdk.org/jdk/pull/33414#pullrequestreview-5608751421
PR Review Comment: https://git.openjdk.org/jdk/pull/33414#discussion_r4344119442

Reply via email to