The checkstyle team wanted to start this issue in xwiki to let you be aware that we are deprecating parts of our code that revolves around using the JVM class loader passed in and loading the classes outside of Checkstyle's control. Checkstyle is a static analysis tool only, and we won't support this type of functionality anymore in our library. We have had issues with this type of class loading and it is not always stable.
During our PR and compiling the code removal with xwiki, we noticied xwiki was using some of this functionality in it's own custom checks. The first we saw was ComponentAnnotationCheck. Sincce it stopped the build at the first error, there could be more we are not aware of.
We are hoping xwiki can remove the usage of this class loading, or switch to some other way to handle the functionality needed by this check. Once the Checkstyle PR is merged, XWiki's check as it is now will be broken and getting the class loader will no longer work and may result in NPEs in your custom check with newer versions of Checkstyle.
Let us know if you have any questions or issues.
First XWiki code in question: https://github.com/xwiki/xwiki-commons/blob/e8ca631240fe07b4c7ba9f94853c386772986e5c/xwiki-commons-tools/xwiki-commons-tool-verification-resources/src/main/java/org/xwiki/tool/checkstyle/ComponentAnnotationCheck.java#L139
Prior XWiki PR that brought this up: https://github.com/xwiki/xwiki-commons/pull/78#issuecomment-534047649
Discussed in Maven Checkstyle: https://issues.apache.org/jira/browse/MCHECKSTYLE-377
Checkstyle Current Issue: https://github.com/checkstyle/checkstyle/issues/3773
Checkstyle Current PR: https://github.com/checkstyle/checkstyle/pull/7114