diff --git a/src/main/java/org/codehaus/plexus/util/ReflectionUtils.java b/src/main/java/org/codehaus/plexus/util/ReflectionUtils.java index e83488cc..3ebf3b2d 100644 --- a/src/main/java/org/codehaus/plexus/util/ReflectionUtils.java +++ b/src/main/java/org/codehaus/plexus/util/ReflectionUtils.java @@ -32,7 +32,6 @@ * @author Michal Maczka * @author Jesse McConnell * @author Trygve Laugstøl - * */ public final class ReflectionUtils { @@ -126,7 +125,7 @@ public static List getSetters( Class clazz ) /** * @param method the method - * @return the class of the argument to the setter. Will throw an RuntimeException if the method isn't a setter. + * @return the class of the argument to the setter. Will throw an RuntimeException if the method isn't a setter. */ public static Class getSetterType( Method method ) { @@ -163,6 +162,7 @@ public static void setVariableValueInObject( Object object, String variable, Obj /** * Generates a map of the fields and values on a given object, also pulls from superclasses + * * @param variable field name * @param object the object to generate the list of fields from * @return map containing the fields and their values @@ -218,6 +218,14 @@ private static void gatherVariablesAndValuesIncludingSuperclasses( Object object Class clazz = object.getClass(); + if ( Float.parseFloat( System.getProperty( "java.specification.version" ) ) >= 11 + && Class.class.getCanonicalName().equals( clazz.getCanonicalName() ) ) + { + // Updating Class fields accessibility is forbidden on Java 16 (and throws warning from version 11) + // No concrete use case to modify accessibility at this level + return; + } + Field[] fields = clazz.getDeclaredFields(); AccessibleObject.setAccessible( fields, true );