Skip to content

Commit f1254fd

Browse files
committed
Javadoc
- Upper case private constant - Remove unused private method
1 parent 7a73349 commit f1254fd

File tree

1 file changed

+8
-33
lines changed

1 file changed

+8
-33
lines changed

src/main/java/org/apache/commons/beanutils2/MethodUtils.java

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public int hashCode() {
113113
* <p>
114114
* Note that when this class is deployed via a shared classloader in a container, this will affect all webapps. However making this configurable per webapp
115115
* would mean having a map keyed by context classloader which may introduce memory-leak problems.
116+
* </p>
116117
*/
117118
private static boolean CACHE_METHODS = true;
118119

@@ -123,12 +124,14 @@ public int hashCode() {
123124
* the WeakHashMap is used only as a mechanism for limiting the size of the cache, that is, a way to tell the garbage collector that the contents of the
124125
* cache can be completely garbage-collected whenever it needs the memory. Whether this is a good approach to this problem is doubtful; something like the
125126
* commons-collections LRUMap may be more appropriate (though of course selecting an appropriate size is an issue).
127+
* </p>
126128
* <p>
127129
* This static variable is safe even when this code is deployed via a shared classloader because it is keyed via a MethodDescriptor object which has a Class
128130
* as one of its members and that member is used in the MethodDescriptor.equals method. So two components that load the same class via different class
129131
* loaders will generate non-equal MethodDescriptor objects and hence end up with different entries in the map.
132+
* </p>
130133
*/
131-
private static final Map<MethodDescriptor, Reference<Method>> cache = Collections.synchronizedMap(new WeakHashMap<>());
134+
private static final Map<MethodDescriptor, Reference<Method>> CACHE = Collections.synchronizedMap(new WeakHashMap<>());
132135

133136
/**
134137
* Add a method to the cache.
@@ -138,7 +141,7 @@ public int hashCode() {
138141
*/
139142
private static void cacheMethod(final MethodDescriptor md, final Method method) {
140143
if (CACHE_METHODS && method != null) {
141-
cache.put(md, new WeakReference<>(method));
144+
CACHE.put(md, new WeakReference<>(method));
142145
}
143146
}
144147

@@ -149,16 +152,14 @@ private static void cacheMethod(final MethodDescriptor md, final Method method)
149152
* @since 1.8.0
150153
*/
151154
public static synchronized int clearCache() {
152-
final int size = cache.size();
153-
cache.clear();
155+
final int size = CACHE.size();
156+
CACHE.clear();
154157
return size;
155158
}
156159

157160
/**
158-
* <p>
159161
* Return an accessible method (that is, one that can be invoked via reflection) that implements the specified Method. If no such method can be found,
160162
* return {@code null}.
161-
* </p>
162163
*
163164
* @param clazz The class of the object
164165
* @param method The method that we wish to call
@@ -209,10 +210,8 @@ public static Method getAccessibleMethod(Class<?> clazz, Method method) {
209210
}
210211

211212
/**
212-
* <p>
213213
* Return an accessible method (that is, one that can be invoked via reflection) with given name and parameters. If no such method can be found, return
214214
* {@code null}. This is just a convenient wrapper for {@link #getAccessibleMethod(Method method)}.
215-
* </p>
216215
*
217216
* @param clazz get method from this class
218217
* @param methodName get method with this name
@@ -237,10 +236,8 @@ public static Method getAccessibleMethod(final Class<?> clazz, final String meth
237236
}
238237

239238
/**
240-
* <p>
241239
* Return an accessible method (that is, one that can be invoked via reflection) that implements the specified Method. If no such method can be found,
242240
* return {@code null}.
243-
* </p>
244241
*
245242
* @param method The method that we wish to call
246243
* @return The accessible method
@@ -255,10 +252,8 @@ public static Method getAccessibleMethod(final Method method) {
255252
}
256253

257254
/**
258-
* <p>
259255
* Return an accessible method (that is, one that can be invoked via reflection) that implements the specified method, by scanning through all implemented
260256
* interfaces and subinterfaces. If no such method can be found, return {@code null}.
261-
* </p>
262257
*
263258
* <p>
264259
* There isn't any good reason why this method must be private. It is because there doesn't seem any reason why other classes should call this rather than
@@ -311,10 +306,8 @@ private static Method getAccessibleMethodFromInterfaceNest(Class<?> clazz, final
311306
}
312307

313308
/**
314-
* <p>
315309
* Return an accessible method (that is, one that can be invoked via reflection) by scanning through the superclasses. If no such method can be found,
316310
* return {@code null}.
317-
* </p>
318311
*
319312
* @param clazz Class to be checked
320313
* @param methodName Method name of the method we wish to call
@@ -343,7 +336,7 @@ private static Method getAccessibleMethodFromSuperclass(final Class<?> clazz, fi
343336
*/
344337
private static Method getCachedMethod(final MethodDescriptor md) {
345338
if (CACHE_METHODS) {
346-
final Reference<Method> methodRef = cache.get(md);
339+
final Reference<Method> methodRef = CACHE.get(md);
347340
if (methodRef != null) {
348341
return methodRef.get();
349342
}
@@ -352,10 +345,8 @@ private static Method getCachedMethod(final MethodDescriptor md) {
352345
}
353346

354347
/**
355-
* <p>
356348
* Find an accessible method that matches the given name and has compatible parameters. Compatible parameters mean that every method parameter is assignable
357349
* from the given parameters. In other words, it finds a method with the given name that will take the parameters given.
358-
* </p>
359350
*
360351
* <p>
361352
* This method is slightly indeterministic since it loops through methods names and return the first matching method.
@@ -527,9 +518,7 @@ private static float getTotalTransformationCost(final Class<?>[] srcArgs, final
527518
}
528519

529520
/**
530-
* <p>
531521
* Invoke a method whose parameter types match exactly the object types.
532-
* </p>
533522
*
534523
* <p>
535524
* This uses reflection to invoke the method obtained from a call to {@code getAccessibleMethod()}.
@@ -558,9 +547,7 @@ public static Object invokeExactMethod(final Object object, final String methodN
558547
}
559548

560549
/**
561-
* <p>
562550
* Invoke a method whose parameter types match exactly the parameter types given.
563-
* </p>
564551
*
565552
* <p>
566553
* This uses reflection to invoke the method obtained from a call to {@code getAccessibleMethod()}.
@@ -594,9 +581,7 @@ public static Object invokeExactMethod(final Object object, final String methodN
594581
}
595582

596583
/**
597-
* <p>
598584
* Invoke a static method whose parameter types match exactly the parameter types given.
599-
* </p>
600585
*
601586
* <p>
602587
* This uses reflection to invoke the method obtained from a call to {@link #getAccessibleMethod(Class, String, Class[])}.
@@ -631,9 +616,7 @@ public static Object invokeExactStaticMethod(final Class<?> objectClass, final S
631616
}
632617

633618
/**
634-
* <p>
635619
* Invoke a named method whose parameter type matches the object type.
636-
* </p>
637620
*
638621
* <p>
639622
* The behavior of this method is less deterministic than
@@ -718,14 +701,6 @@ private static void setMethodAccessible(final Method method) {
718701
}
719702
}
720703

721-
private static Object[] toArray(final Object arg) {
722-
Object[] args = null;
723-
if (arg != null) {
724-
args = new Object[] { arg };
725-
}
726-
return args;
727-
}
728-
729704
private MethodUtils() {
730705
// empty
731706
}

0 commit comments

Comments
 (0)