@Test public void testPackageName() { assertEquals("", ReflectionUtils.getPackageName(int.class)); assertEquals("java.lang", ReflectionUtils.getPackageName(Integer.class)); Class<?> p = new CompilingProxyFactory().getClassProxy(Random.class); assertEquals("proxy.java.util", ReflectionUtils.getPackageName(p)); }
public static String getPackageName(Class<?> c) { Package p = c.getPackage(); if (p != null) { return p.getName(); } if (c.isPrimitive()) { return ""; } String s = c.getName(); int lastDot = s.lastIndexOf('.'); if (lastDot < 0) { return ""; } return s.substring(0, lastDot); }
ReflectionUtils { public static String getPackageName(Class<?> c) { Package p = c.getPackage(); if (p != null) { return p.getName(); } if (c.isPrimitive()) { return ""; } String s = c.getName(); int lastDot = s.lastIndexOf('.'); if (lastDot < 0) { return ""; } return s.substring(0, lastDot); } }
ReflectionUtils { public static String getPackageName(Class<?> c) { Package p = c.getPackage(); if (p != null) { return p.getName(); } if (c.isPrimitive()) { return ""; } String s = c.getName(); int lastDot = s.lastIndexOf('.'); if (lastDot < 0) { return ""; } return s.substring(0, lastDot); }  }
ReflectionUtils { public static String getPackageName(Class<?> c) { Package p = c.getPackage(); if (p != null) { return p.getName(); } if (c.isPrimitive()) { return ""; } String s = c.getName(); int lastDot = s.lastIndexOf('.'); if (lastDot < 0) { return ""; } return s.substring(0, lastDot); }  static Object getDefaultValue(Class<?> c); static Class<?> getNonPrimitiveClass(Class<?> c); static String getPackageName(Class<?> c); static Object callStaticMethod(
            String classAndMethod, Object... params); static Object callMethod(
            Object instance,
            String methodName,
            Object... params); }
ReflectionUtils { public static String getPackageName(Class<?> c) { Package p = c.getPackage(); if (p != null) { return p.getName(); } if (c.isPrimitive()) { return ""; } String s = c.getName(); int lastDot = s.lastIndexOf('.'); if (lastDot < 0) { return ""; } return s.substring(0, lastDot); }  static Object getDefaultValue(Class<?> c); static Class<?> getNonPrimitiveClass(Class<?> c); static String getPackageName(Class<?> c); static Object callStaticMethod(
            String classAndMethod, Object... params); static Object callMethod(
            Object instance,
            String methodName,
            Object... params);  }