private void cacheResetMethod(String classNameWithDots) { if (!resetMethodCache.containsKey(loader)) { resetMethodCache.put(loader, new HashMap<>()); } Map<String, Method> methodMap = resetMethodCache.get(loader); if (methodMap.containsKey(classNameWithDots)) { return; } try { Class<?> clazz = loader.loadClass(classNameWithDots); if(clazz.isInterface() || clazz.isAnonymousClass()) { return; } Method m = clazz.getDeclaredMethod(STATIC_RESET, (Class<?>[]) null); m.setAccessible(true); methodMap.put(classNameWithDots, m); } catch (NoSuchMethodException e) { //this can happen if class was not instrumented with a static reset logger.debug("__STATIC_RESET() method does not exists in class {}", classNameWithDots); } catch (Exception | Error e) { logWarn(classNameWithDots, e.getClass() + " thrown while loading method __STATIC_RESET() for class " + classNameWithDots); } }
ClassResetter.getInstance().logWarn(className, e.getClass() + " thrown during execution of method __STATIC_RESET() for class " + className + ", " + e.getCause());