LANG-1354: FieldUtils should ignore any synthetic fields
diff --git a/pom.xml b/pom.xml
index 81f2d30..74d51a9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -704,6 +704,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>
<configuration>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c4491ee..5239f9c 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,7 @@
<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>
diff --git a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
index c4cccca..c45a73a 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java
@@ -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 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
@@ -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
diff --git a/src/site/resources/profile.cobertura b/src/site/resources/profile.jacoco
similarity index 100%
rename from src/site/resources/profile.cobertura
rename to src/site/resources/profile.jacoco