GenericsUtil { public static boolean isLog4jLogger(Class<?> clazz) { if (clazz == null) { return false; } Logger log = LoggerFactory.getLogger(clazz); try { Class log4jClass = Class.forName("org.slf4j.impl.Log4jLoggerAdapter"); return log4jClass.isInstance(log); } catch (ClassNotFoundException e) { return false; } }  static Class<T> getClass(T t); static T[] toArray(Class<T> c, List<T> list); static T[] toArray(List<T> list); static boolean isLog4jLogger(Class<?> clazz);  }
@Test public void testIsLog4jLogger() throws Exception { assertFalse("False if clazz is null", GenericsUtil.isLog4jLogger(null)); assertTrue("The implementation is Log4j", GenericsUtil.isLog4jLogger(TestGenericsUtil.class)); }