@Throws(ConfigurationError::class) fun findClassLoader(): ClassLoader? { val ss: SecuritySupport = SecuritySupport.getInstance() val context: ClassLoader = ss.getContextClassLoader() val system: ClassLoader = ss.getSystemClassLoader() var chain = system while (true) { if (context === chain) { val current: ClassLoader = ObjectFactory::class.java.getClassLoader() chain = system while (true) { if (current === chain) { return system } if (chain == null) { break } chain = ss.getParentClassLoader(chain) } return current } if (chain == null) { break } chain = ss.getParentClassLoader(chain) } return context }
Figure out which ClassLoader to use . For JDK 1.2 and later use the context ClassLoader .