public static Field[] getFields(Class<?> clazz) {
if (!ClassDataStore.instance().isClassReplaced(clazz)) {
return clazz.getFields();
}
try {
ClassData cd = ClassDataStore.instance().getModifiedClassData(clazz.getClassLoader(), Descriptor.toJvmName(clazz.getName()));
if (cd == null) {
return clazz.getDeclaredFields();
}
Field[] meth = clazz.getFields();
Collection<FieldData> fieldData = cd.getFields();
List<Field> visible = new ArrayList<Field>(meth.length);
for (int i = 0; i < meth.length; ++i) {
for (FieldData f : fieldData) {
if (f.getAccessFlags() == meth[i].getModifiers() && f.getName().equals(meth[i].getName())) {
if (f.getMemberType() == MemberType.NORMAL) {
visible.add(meth[i]);
break;
}
}
}
}
ClassData cta = cd;
while (cta != null) {
for (FieldData i : cta.getFields()) {
if (i.getMemberType() == MemberType.FAKE && AccessFlag.isPublic(i.getAccessFlags())) {
Class<?> c = clazz.getClassLoader().loadClass(i.getClassName());
visible.add(i.getField(c));
}
}
cta = cta.getSuperClassInformation();
}
Field[] ret = new Field[visible.size()];
for (int i = 0; i < visible.size(); ++i) {
ret[i] = visible.get(i);