FieldCache { public Field[] getInstanceFields(final Class<?> clazz) { if (clazz == null) { return null; } return cache.get(ClassUtil.getFriendlyClassName(clazz) + ".instance", new Callable<Field[]>() { @Override public Field[] call() throws Exception { return ReflectionUtil.getAllInstanceFields(clazz, true); } }); } private  FieldCache(); static FieldCache getInstance(); Field[] getFields(final Class<?> clazz); Field[] getInstanceFields(final Class<?> clazz); Field[] getFields(final Class<?> clazz, final Class<? extends Annotation> annotationClass); Field getField(final Class<?> clazz, String fieldName); Field getInstanceField(final Class<?> clazz, String fieldName); Field getField(final Class<?> clazz, final Class<? extends Annotation> annotationClass, String fieldName);  }
@Test public void getInstanceFields() { Field[] result = cache.getInstanceFields(String.class); Field[] fields = ReflectionUtil.getAllInstanceFields(String.class); assertArrayEquals(result, fields); instanceFieldSize = result.length; result = cache.getInstanceFields(AnnotationClass.class); fields = ReflectionUtil.getAllInstanceFields(AnnotationClass.class); assertArrayEquals(result, fields); getFields(); assertTrue(fieldSize > 0); assertTrue(instanceFieldSize > 0); assertTrue(fieldSize > instanceFieldSize); }