Skip to content

Commit

Permalink
Further simplify QuarkusClassLoader#isApplicationClass()
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Aug 16, 2024
1 parent 34631a0 commit e37e940
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,15 @@ public static boolean isClassPresentAtRuntime(String className) {
* Indicates if a given class is considered an application class.
*/
public static boolean isApplicationClass(String className) {
String resourceName = fromClassNameToResourceName(className);
List<ClassPathElement> res = getElements(resourceName, true);
return !res.isEmpty();
final ClassLoader ccl = Thread.currentThread().getContextClassLoader();
if (!(ccl instanceof QuarkusClassLoader)) {
throw new IllegalStateException("The current classloader is not an instance of "
+ QuarkusClassLoader.class.getName() + " but " + ccl.getClass().getName());
}

ClassPathResourceIndex classPathResourceIndex = ((QuarkusClassLoader) ccl).getClassPathResourceIndex();

return classPathResourceIndex.getFirstClassPathElement(className) != null;
}

/**
Expand Down

0 comments on commit e37e940

Please sign in to comment.