diff --git a/core-java-modules/core-java-reflection-2/pom.xml b/core-java-modules/core-java-reflection-2/pom.xml index e6bfe259db..b887f95823 100644 --- a/core-java-modules/core-java-reflection-2/pom.xml +++ b/core-java-modules/core-java-reflection-2/pom.xml @@ -22,14 +22,14 @@ test - org.reflections - reflections - 0.9.12 + org.reflections + reflections + 0.9.12 - com.google.guava - guava - 30.1.1-jre + com.google.guava + guava + 30.1.1-jre diff --git a/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/access/packages/AccessingAllClassesInPackage.java b/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/access/packages/AccessingAllClassesInPackage.java index 7da8e224ee..dfbfaca270 100644 --- a/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/access/packages/AccessingAllClassesInPackage.java +++ b/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/access/packages/AccessingAllClassesInPackage.java @@ -9,12 +9,16 @@ import java.util.stream.Collectors; import org.reflections.Reflections; import org.reflections.scanners.SubTypesScanner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.reflect.ClassPath; @SuppressWarnings("rawtypes") public class AccessingAllClassesInPackage { + private static final Logger LOG = LoggerFactory.getLogger(AccessingAllClassesInPackage.class); + public Set findAllClassesUsingClassLoader(String packageName) { InputStream stream = ClassLoader.getSystemClassLoader() .getResourceAsStream(packageName.replaceAll("[.]", "/")); @@ -29,7 +33,7 @@ public class AccessingAllClassesInPackage { try { return Class.forName(packageName + "." + className.substring(0, className.lastIndexOf('.'))); } catch (ClassNotFoundException e) { - e.printStackTrace(); + LOG.error("<>"); } return null; }