|
32 | 32 | * @author <a href="mailto:[email protected]">Michal Maczka</a> |
33 | 33 | * @author <a href="mailto:[email protected]">Jesse McConnell</a> |
34 | 34 | * @author <a href="mailto:[email protected]">Trygve Laugstøl</a> |
35 | | - * |
36 | 35 | */ |
37 | 36 | public final class ReflectionUtils |
38 | 37 | { |
@@ -126,7 +125,7 @@ public static List<Method> getSetters( Class<?> clazz ) |
126 | 125 |
|
127 | 126 | /** |
128 | 127 | * @param method the method |
129 | | - * @return the class of the argument to the setter. Will throw an RuntimeException if the method isn't a setter. |
| 128 | + * @return the class of the argument to the setter. Will throw an RuntimeException if the method isn't a setter. |
130 | 129 | */ |
131 | 130 | public static Class<?> getSetterType( Method method ) |
132 | 131 | { |
@@ -163,6 +162,7 @@ public static void setVariableValueInObject( Object object, String variable, Obj |
163 | 162 |
|
164 | 163 | /** |
165 | 164 | * Generates a map of the fields and values on a given object, also pulls from superclasses |
| 165 | + * |
166 | 166 | * @param variable field name |
167 | 167 | * @param object the object to generate the list of fields from |
168 | 168 | * @return map containing the fields and their values |
@@ -218,6 +218,14 @@ private static void gatherVariablesAndValuesIncludingSuperclasses( Object object |
218 | 218 |
|
219 | 219 | Class<?> clazz = object.getClass(); |
220 | 220 |
|
| 221 | + if ( Float.parseFloat( System.getProperty( "java.specification.version" ) ) >= 11 |
| 222 | + && Class.class.getCanonicalName().equals( clazz.getCanonicalName() ) ) |
| 223 | + { |
| 224 | + // Updating Class fields accessibility is forbidden on Java 16 (and throws warning from version 11) |
| 225 | + // No concrete use case to modify accessibility at this level |
| 226 | + return; |
| 227 | + } |
| 228 | + |
221 | 229 | Field[] fields = clazz.getDeclaredFields(); |
222 | 230 |
|
223 | 231 | AccessibleObject.setAccessible( fields, true ); |
|
0 commit comments