Skip to content

Commit 6021822

Browse files
committed
Polishing
1 parent 045f78e commit 6021822

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,14 @@ public static void acceptClassLoader(ClassLoader classLoader) {
101101

102102
/**
103103
* Clear the introspection cache for the given ClassLoader, removing the
104-
* introspection results for all classes underneath that ClassLoader,
105-
* and deregistering the ClassLoader (and any of its children) from the
106-
* acceptance list.
104+
* introspection results for all classes underneath that ClassLoader, and
105+
* removing the ClassLoader (and its children) from the acceptance list.
107106
* @param classLoader the ClassLoader to clear the cache for
108107
*/
109108
public static void clearClassLoader(ClassLoader classLoader) {
110109
synchronized (classCache) {
111110
for (Iterator<Class> it = classCache.keySet().iterator(); it.hasNext();) {
112-
Class beanClass = it.next();
111+
Class<?> beanClass = it.next();
113112
if (isUnderneathClassLoader(beanClass.getClassLoader(), classLoader)) {
114113
it.remove();
115114
}
@@ -127,13 +126,11 @@ public static void clearClassLoader(ClassLoader classLoader) {
127126

128127
/**
129128
* Create CachedIntrospectionResults for the given bean class.
130-
* <P>We don't want to use synchronization here. Object references are atomic,
131-
* so we can live with doing the occasional unnecessary lookup at startup only.
132129
* @param beanClass the bean class to analyze
133130
* @return the corresponding CachedIntrospectionResults
134131
* @throws BeansException in case of introspection failure
135132
*/
136-
static CachedIntrospectionResults forClass(Class beanClass) throws BeansException {
133+
static CachedIntrospectionResults forClass(Class<?> beanClass) throws BeansException {
137134
CachedIntrospectionResults results;
138135
Object value;
139136
synchronized (classCache) {
@@ -225,7 +222,7 @@ private static boolean isUnderneathClassLoader(ClassLoader candidate, ClassLoade
225222
* @param beanClass the bean class to analyze
226223
* @throws BeansException in case of introspection failure
227224
*/
228-
private CachedIntrospectionResults(Class beanClass) throws BeansException {
225+
private CachedIntrospectionResults(Class<?> beanClass) throws BeansException {
229226
try {
230227
if (logger.isTraceEnabled()) {
231228
logger.trace("Getting BeanInfo for class [" + beanClass.getName() + "]");
@@ -248,7 +245,7 @@ private CachedIntrospectionResults(Class beanClass) throws BeansException {
248245
// garbage collection on class loader shutdown - we cache it here anyway,
249246
// in a GC-friendly manner. In contrast to CachedIntrospectionResults,
250247
// Introspector does not use WeakReferences as values of its WeakHashMap!
251-
Class classToFlush = beanClass;
248+
Class<?> classToFlush = beanClass;
252249
do {
253250
Introspector.flushFromCaches(classToFlush);
254251
classToFlush = classToFlush.getSuperclass();
@@ -286,7 +283,7 @@ BeanInfo getBeanInfo() {
286283
return this.beanInfo;
287284
}
288285

289-
Class getBeanClass() {
286+
Class<?> getBeanClass() {
290287
return this.beanInfo.getBeanDescriptor().getBeanClass();
291288
}
292289

@@ -314,7 +311,7 @@ PropertyDescriptor[] getPropertyDescriptors() {
314311
return pds;
315312
}
316313

317-
private PropertyDescriptor buildGenericTypeAwarePropertyDescriptor(Class beanClass, PropertyDescriptor pd) {
314+
private PropertyDescriptor buildGenericTypeAwarePropertyDescriptor(Class<?> beanClass, PropertyDescriptor pd) {
318315
try {
319316
return new GenericTypeAwarePropertyDescriptor(beanClass, pd.getName(), pd.getReadMethod(),
320317
pd.getWriteMethod(), pd.getPropertyEditorClass());

spring-core/src/main/java/org/springframework/util/ReflectionUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -98,8 +98,8 @@ public static void setField(Field field, Object target, Object value) {
9898
}
9999
catch (IllegalAccessException ex) {
100100
handleReflectionException(ex);
101-
throw new IllegalStateException("Unexpected reflection exception - " + ex.getClass().getName() + ": "
102-
+ ex.getMessage());
101+
throw new IllegalStateException(
102+
"Unexpected reflection exception - " + ex.getClass().getName() + ": " + ex.getMessage());
103103
}
104104
}
105105

@@ -153,8 +153,8 @@ public static Method findMethod(Class<?> clazz, String name, Class<?>... paramTy
153153
while (searchType != null) {
154154
Method[] methods = (searchType.isInterface() ? searchType.getMethods() : searchType.getDeclaredMethods());
155155
for (Method method : methods) {
156-
if (name.equals(method.getName())
157-
&& (paramTypes == null || Arrays.equals(paramTypes, method.getParameterTypes()))) {
156+
if (name.equals(method.getName()) &&
157+
(paramTypes == null || Arrays.equals(paramTypes, method.getParameterTypes()))) {
158158
return method;
159159
}
160160
}

0 commit comments

Comments
 (0)