ReflectUtils { protected static boolean isPublicInstanceField(Field field) { return Modifier.isPublic(field.getModifiers()) && !Modifier.isStatic(field.getModifiers()) && !Modifier.isFinal(field.getModifiers()) && !field.isSynthetic(); }  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 testIsPublicInstanceField() throws Exception { Assert.assertTrue(isPublicInstanceField(TestReflect.class.getField("f1"))); Assert.assertFalse(isPublicInstanceField(TestReflect.class.getDeclaredField("f2"))); Assert.assertFalse(isPublicInstanceField(TestReflect.class.getDeclaredField("f3"))); Assert.assertFalse(isPublicInstanceField(TestReflect.class.getDeclaredField("f4"))); Assert.assertFalse(isPublicInstanceField(TestReflect.class.getDeclaredField("f5"))); }