Skip to content

Commit 10e6eec

Browse files
committed
8360039: JFR: Improve parser logging of constants
Reviewed-by: mgronlun
1 parent 251f2ac commit 10e6eec

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ChunkParser.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
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.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -421,14 +421,29 @@ private String textify(Object o) {
421421
return o.getClass().getName();
422422
}
423423
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);
428425
}
429426
return String.valueOf(o);
430427
}
431428

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+
432447
private String getName(long id) {
433448
Type type = typeMap.get(id);
434449
return type == null ? ("unknown(" + id + ")") : type.getName();

0 commit comments

Comments
 (0)