From 4bf65d47327f15d1507f2d86e5b70edaf32e5d6d Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Sat, 19 Jul 2003 03:25:38 +0000 Subject: [PATCH] Severity Description Resource In Folder Location Creation Time The static method setAccessible(AccessibleObject[], boolean) from the type AccessibleObject should be accessed directly CompareToBuilder.java Apache Jakarta Commons/lang/src/java/org/apache/commons/lang/builder line 254 July 18, 2003 7:11:22 PM git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137451 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/lang/builder/CompareToBuilder.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/java/org/apache/commons/lang/builder/CompareToBuilder.java b/src/java/org/apache/commons/lang/builder/CompareToBuilder.java index 9ecfe0534..53c166d9e 100644 --- a/src/java/org/apache/commons/lang/builder/CompareToBuilder.java +++ b/src/java/org/apache/commons/lang/builder/CompareToBuilder.java @@ -53,6 +53,7 @@ */ package org.apache.commons.lang.builder; +import java.lang.reflect.AccessibleObject; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.Comparator; @@ -91,7 +92,7 @@ * *

Alternatively, there is a method that uses reflection to determine * the fields to test. Because these fields are usually private, the method, - * reflectionCompare, uses Field.setAccessible to change + * reflectionCompare, uses AccessibleObject.setAccessible to change * the visibility of the fields. This will fail under a security manager, * unless the appropriate permissions are set. It is also slower than testing * explicitly.

@@ -107,7 +108,7 @@ * @author Stephen Colebourne * @author Gary Gregory * @since 1.0 - * @version $Id: CompareToBuilder.java,v 1.16 2003/07/14 22:25:03 bayard Exp $ + * @version $Id: CompareToBuilder.java,v 1.17 2003/07/19 03:25:38 ggregory Exp $ */ public class CompareToBuilder { @@ -134,7 +135,7 @@ public CompareToBuilder() { *

This method uses reflection to determine the ordering between two * Objects.

* - *

It uses Field.setAccessible to gain access to private + *

It uses AccessibleObject.setAccessible to gain access to private * fields. This means that it will throw a security exception if run under * a security manger, if the permissions are not set up correctly. It is * also not as efficient as testing explicitly.

@@ -161,7 +162,7 @@ public static int reflectionCompare(Object lhs, Object rhs) { *

This method uses reflection to determine if the two Objects are * equal.

* - *

It uses Field.setAccessible to gain access to private + *

It uses AccessibleObject.setAccessible to gain access to private * fields. This means that it will throw a security exception if run under * a security manger, if the permissions are not set up correctly. It is * also not as efficient as testing explicitly.

@@ -190,7 +191,7 @@ public static int reflectionCompare(Object lhs, Object rhs, boolean testTransien *

This method uses reflection to determine if the two Objects are * equal.

* - *

It uses Field.setAccessible to gain access to private + *

It uses AccessibleObject.setAccessible to gain access to private * fields. This means that it will throw a security exception if run under * a security manger, if the permissions are not set up correctly. It is * also not as efficient as testing explicitly.

@@ -251,7 +252,7 @@ private static void reflectionAppend( CompareToBuilder builder, boolean useTransients) { Field[] fields = clazz.getDeclaredFields(); - Field.setAccessible(fields, true); + AccessibleObject.setAccessible(fields, true); for (int i = 0; i < fields.length && builder.comparison == 0; i++) { Field f = fields[i]; if ((f.getName().indexOf('$') == -1)