From 1d0538995a3257ed4152aaed5f6606fadb47f4fd Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Mon, 4 Mar 2024 12:53:02 +0100 Subject: [PATCH] improve ClassInfo.recordComponents() in case the class is not a record --- core/src/main/java/org/jboss/jandex/ClassInfo.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/jboss/jandex/ClassInfo.java b/core/src/main/java/org/jboss/jandex/ClassInfo.java index 80e0ab71..dc591a40 100644 --- a/core/src/main/java/org/jboss/jandex/ClassInfo.java +++ b/core/src/main/java/org/jboss/jandex/ClassInfo.java @@ -885,12 +885,14 @@ public final RecordComponentInfo recordComponent(String name) { /** * Returns a list of all record components declared by this class. - * This list may be empty, but never null. + * This list may be empty, but never {@code null}. + *

+ * If this class is not a record, returns an empty list. * - * @return a list of record components + * @return immutable list of record components */ public final List recordComponents() { - if (extra == null || extra.recordComponents == null) { + if (!isRecord() || extra == null || extra.recordComponents == null) { return Collections.emptyList(); } @@ -907,7 +909,7 @@ public final List recordComponents() { * assumes that the bytecode order corresponds to declaration order, which is not guaranteed, * but practically always holds. * - * @return a list of record components + * @return immutable list of record components * @since 2.4 */ public final List unsortedRecordComponents() {