Skip to content

Commit

Permalink
Fix RTTI::getCategories returning overridden categories
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadelessFox committed Sep 24, 2024
1 parent 8a2bc36 commit 9e6a6ea
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions modules/decima-rtti/src/main/java/com/shade/decima/rtti/RTTI.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,19 @@ private static ExtraBinaryDataCallback<?> getExtraBinaryDataCallback0(@NotNull C

@NotNull
private static List<CategoryInfo> getCategories0(@NotNull Class<?> cls) {
return getAttributes(cls).stream()
.map(AttributeInfo::category)
.filter(Objects::nonNull)
.sorted(Comparator.comparing(CategoryInfo::name))
.distinct()
.toList();
List<CategoryInfo> categories = new ArrayList<>();
for (Method method : cls.getMethods()) {
if (!Modifier.isAbstract(method.getModifiers())) {
// Skips overridden methods (e.g. categories)
continue;
}
Category category = method.getDeclaredAnnotation(Category.class);
if (category != null) {
categories.add(new CategoryInfo(category.name(), method.getReturnType(), method));
}
}
categories.sort(Comparator.comparing(CategoryInfo::name));
return categories;
}

@NotNull
Expand Down

0 comments on commit 9e6a6ea

Please sign in to comment.