Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4e4c88a

Browse filesBrowse files
committed
Fix #116 : Java 16 support for ReflectionUtils (and Java 11 no warning)
1 parent 900acba commit 4e4c88a
Copy full SHA for 4e4c88a

File tree

Expand file treeCollapse file tree

1 file changed

+10
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-2
lines changed

‎src/main/java/org/codehaus/plexus/util/ReflectionUtils.java

Copy file name to clipboardExpand all lines: src/main/java/org/codehaus/plexus/util/ReflectionUtils.java
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* @author <a href="mailto:michal@codehaus.org">Michal Maczka</a>
3333
* @author <a href="mailto:jesse@codehaus.org">Jesse McConnell</a>
3434
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
35-
*
3635
*/
3736
public final class ReflectionUtils
3837
{
@@ -126,7 +125,7 @@ public static List<Method> getSetters( Class<?> clazz )
126125

127126
/**
128127
* @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.
130129
*/
131130
public static Class<?> getSetterType( Method method )
132131
{
@@ -163,6 +162,7 @@ public static void setVariableValueInObject( Object object, String variable, Obj
163162

164163
/**
165164
* Generates a map of the fields and values on a given object, also pulls from superclasses
165+
*
166166
* @param variable field name
167167
* @param object the object to generate the list of fields from
168168
* @return map containing the fields and their values
@@ -218,6 +218,14 @@ private static void gatherVariablesAndValuesIncludingSuperclasses( Object object
218218

219219
Class<?> clazz = object.getClass();
220220

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+
221229
Field[] fields = clazz.getDeclaredFields();
222230

223231
AccessibleObject.setAccessible( fields, true );

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.