LANG-1354: FieldUtils should ignore any synthetic fields

This commit is contained in:
Chas Honton 2017-10-10 20:52:50 -07:00
parent 1e9e36640f
commit c56b87d6ef
4 changed files with 21 additions and 2 deletions

11
pom.xml
View File

@ -703,6 +703,17 @@
<reporting>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>

View File

@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
<body>
<release version="3.7" date="2017-MM-DD" description="New features and bug fixes. Requires Java 7.">
<action issue="LANG-1354" type="fix" dev="chas" due-to="Yegor Koldov">FieldUtils should ignore any synthetic fields</action>
<action issue="LANG-1355" type="add" dev="ggregory" due-to="Chas Honton">TimeZone.getTimeZone() in FastDateParser causes resource contention (PR #296.)</action>
<action issue="LANG-1348" type="fix" dev="pschumacher" due-to="mbusso">StackOverflowError on TypeUtils.toString(...) for a generic return type of Enum.valueOf</action>
<action issue="LANG-1346" type="update" dev="pschumacher">Remove deprecation from RandomStringUtils</action>

View File

@ -187,6 +187,7 @@ public static Field getDeclaredField(final Class<?> cls, final String fieldName,
/**
* Gets all fields of the given class and its parents (if any).
* Does not return any synthetic fields.
*
* @param cls
* the {@link Class} to query
@ -202,6 +203,7 @@ public static Field[] getAllFields(final Class<?> cls) {
/**
* Gets all fields of the given class and its parents (if any).
* Does not return any synthetic fields.
*
* @param cls
* the {@link Class} to query
@ -215,8 +217,11 @@ public static List<Field> getAllFieldsList(final Class<?> cls) {
final List<Field> allFields = new ArrayList<>();
Class<?> currentClass = cls;
while (currentClass != null) {
final Field[] declaredFields = currentClass.getDeclaredFields();
Collections.addAll(allFields, declaredFields);
for(final Field declaredField : currentClass.getDeclaredFields()) {
if(!declaredField.isSynthetic()) {
allFields.add(declaredField);
}
}
currentClass = currentClass.getSuperclass();
}
return allFields;
@ -224,6 +229,8 @@ public static List<Field> getAllFieldsList(final Class<?> cls) {
/**
* Gets all fields of the given class and its parents (if any) that are annotated with the given annotation.
* Does not return any synthetic fields.
*
* @param cls
* the {@link Class} to query
* @param annotationCls