ReflectUtils { public static String getCodeBase(Class<?> cls) { if (cls == null) { return null; } ProtectionDomain domain = cls.getProtectionDomain(); if (domain == null) { return null; } CodeSource source = domain.getCodeSource(); if (source == null) { return null; } URL location = source.getLocation(); if (location == null) { return null; } return location.getFile(); }  static boolean isPrimitives(Class<?> clazz); static String getCodeBase(Class<?> cls); static Method getMethod(String clazzName, String methodName, String[] argsType); static Method getMethod(Class clazz, String methodName, Class... argsType); static Method getPropertySetterMethod(Class clazz, String property, Class propertyClazz); static Method getPropertyGetterMethod(Class clazz, String property);  }
@Test public void getCodeBase() { Assert.assertNull(ReflectUtils.getCodeBase(null)); String codebase = ReflectUtils.getCodeBase(ReflectUtils.class); LOGGER.info(codebase); Assert.assertNotNull(codebase); String codebase2 = ReflectUtils.getCodeBase(ReflectUtilsTest.class); LOGGER.info(codebase2); Assert.assertNotNull(codebase2); }