ReflectionUtils { @Nonnull public static String getCallerClassName() { return getCallerClassName(sunReflectReflectionInvocationFrame); }  @Nonnull static String getCallerClassName(); @Nonnull static Class<?> getCallerClass(); static Package getCallerPackage(); static void assertArrayIndex(Object array, int index); static void assertArrayType(Object array); static void assertFieldMatchType(Object object, String fieldName, Class<?> expectedType); @Nonnull static List<T> toList(Object array); @Nonnull static Map<String, Object> readFieldsAsMap(Object object); static final String SUN_REFLECT_REFLECTION_CLASS_NAME; }
@Test public void testGetCallerClassName() { String expectedClassName = ReflectionUtilsTest.class.getName(); String callerClassName = ReflectionUtils.getCallerClassName(); String callerClassNameInSunJVM = ReflectionUtils.getCallerClassNameInSunJVM(); String callerClassNameInGeneralJVM = ReflectionUtils.getCallerClassNameInGeneralJVM(); Assert.assertEquals(expectedClassName, callerClassName); Assert.assertEquals(callerClassNameInSunJVM, callerClassName); Assert.assertEquals(callerClassNameInGeneralJVM, callerClassName); }