From 5e3c61ca813c47fe5a2f9c29fd99fb09564c7155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E6=96=97=E6=B8=B8=E4=BE=A0?= <1633486422@qq.com> Date: Thu, 4 Apr 2024 20:53:16 +0800 Subject: [PATCH] Added a step to model checking.Check if the annotated class collection obtained is empty. --- .../elide/core/utils/DefaultClassScanner.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/elide-core/src/main/java/com/yahoo/elide/core/utils/DefaultClassScanner.java b/elide-core/src/main/java/com/yahoo/elide/core/utils/DefaultClassScanner.java index 0102bc6666..092edbe8a6 100644 --- a/elide-core/src/main/java/com/yahoo/elide/core/utils/DefaultClassScanner.java +++ b/elide-core/src/main/java/com/yahoo/elide/core/utils/DefaultClassScanner.java @@ -47,11 +47,17 @@ public Set> getAnnotatedClasses(Package toScan, Class> getAnnotatedClasses(String packageName, Class annotation) { - return startupCache.get(annotation.getCanonicalName()).stream() - .filter(clazz -> - clazz.getPackage().getName().equals(packageName) - || clazz.getPackage().getName().startsWith(packageName + ".")) + LinkedHashSet> annotatedClasses = startupCache.get(annotation.getCanonicalName()).stream() + .filter(clazz -> clazz.getPackage().getName().equals(packageName) + || clazz.getPackage().getName().startsWith(packageName + ".")) .collect(Collectors.toCollection(LinkedHashSet::new)); + + // Check if the annotated class collection obtained is empty + if (annotatedClasses.isEmpty()) { + throw new IllegalArgumentException("No annotated classes found in the specified package: " + packageName); + } + + return annotatedClasses; } @Override