|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -421,14 +421,29 @@ private String textify(Object o) {
|
421 | 421 | return o.getClass().getName();
|
422 | 422 | }
|
423 | 423 | if (o.getClass().isArray()) {
|
424 |
| - Object[] array = (Object[]) o; |
425 |
| - if (array.length > 0) { |
426 |
| - return textify(array[0]) + "[]"; // can it be recursive? |
427 |
| - } |
| 424 | + return textifyArray((Object[])o); |
428 | 425 | }
|
429 | 426 | return String.valueOf(o);
|
430 | 427 | }
|
431 | 428 |
|
| 429 | + private String textifyArray(Object[] array) { |
| 430 | + int length = array.length; |
| 431 | + if (length > 0) { |
| 432 | + Object element = array[0]; |
| 433 | + if (element != null) { |
| 434 | + if (element instanceof String s) { |
| 435 | + // Probably an enumeration type, e.g. ThreadState. Remove array indirection |
| 436 | + return textify(s); |
| 437 | + } |
| 438 | + if (element.getClass().isArray()) { |
| 439 | + Object[] subArray = (Object[]) element; |
| 440 | + return element.getClass().getComponentType().getName() + "[" + subArray.length + "]" + "[" + length + "]"; |
| 441 | + } |
| 442 | + } |
| 443 | + } |
| 444 | + return array.getClass().getComponentType().getName() + "[" + length + "]"; |
| 445 | + } |
| 446 | + |
432 | 447 | private String getName(long id) {
|
433 | 448 | Type type = typeMap.get(id);
|
434 | 449 | return type == null ? ("unknown(" + id + ")") : type.getName();
|
|
0 commit comments