privatestaticvoid testField(Class<?> base, String fieldName) throws Exception {
Field f = base.getDeclaredField(fieldName);
String[] result = getFieldName(f);
System.out.println(Arrays.toString(result));
Class<?> declClass = getFieldDeclaringClass(f); if (base != declClass) { thrownew RuntimeException("Declaring class not equal: " + base + " vs " + declClass);
}
System.out.println(declClass);
int modifiers = getFieldModifiers(f); if (modifiers != f.getModifiers()) { thrownew RuntimeException( "Modifiers not equal: " + f.getModifiers() + " vs " + modifiers);
}
System.out.println(modifiers);
boolean synth = isFieldSynthetic(f); if (synth != f.isSynthetic()) { thrownew RuntimeException("Synthetic not equal: " + f.isSynthetic() + " vs " + synth);
}
System.out.println(synth);
}
privateclass Foo { publicvoid inc() { // Touch a field in the outer class. Needed to avoid a javac optimization which removes // the synthetic field that refers to the instance of the outer class (this$0).
fooVal++;
}
}
privateint fooVal = 0;
privatestaticinterface Bar { publicstaticint VAL = 1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.