Browse Source

officially deprecated ClassUtils.forName variant without ClassLoader

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1005 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Juergen Hoeller 17 years ago
parent
commit
3d034cb046
  1. 6
      org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java
  2. 9
      org.springframework.core/src/main/java/org/springframework/util/MethodInvoker.java

6
org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java

@ -194,7 +194,10 @@ public abstract class ClassUtils {
* @throws LinkageError if the class file could not be loaded * @throws LinkageError if the class file could not be loaded
* @see Class#forName(String, boolean, ClassLoader) * @see Class#forName(String, boolean, ClassLoader)
* @see #getDefaultClassLoader() * @see #getDefaultClassLoader()
* @deprecated as of Spring 3.0, in favor of specifying a ClassLoader explicitly:
* see {@link #forName(String, ClassLoader)}
*/ */
@Deprecated
public static Class forName(String name) throws ClassNotFoundException, LinkageError { public static Class forName(String name) throws ClassNotFoundException, LinkageError {
return forName(name, getDefaultClassLoader()); return forName(name, getDefaultClassLoader());
} }
@ -298,7 +301,7 @@ public abstract class ClassUtils {
* according to the JVM's naming rules for primitive classes. * according to the JVM's naming rules for primitive classes.
* <p>Also supports the JVM's internal class names for primitive arrays. * <p>Also supports the JVM's internal class names for primitive arrays.
* Does <i>not</i> support the "[]" suffix notation for primitive arrays; * Does <i>not</i> support the "[]" suffix notation for primitive arrays;
* this is only supported by {@link #forName}. * this is only supported by {@link #forName(String, ClassLoader)}.
* @param name the name of the potentially primitive class * @param name the name of the potentially primitive class
* @return the primitive class, or <code>null</code> if the name does not denote * @return the primitive class, or <code>null</code> if the name does not denote
* a primitive class or primitive array class * a primitive class or primitive array class
@ -673,7 +676,6 @@ public abstract class ClassUtils {
* May be <code>null</code> or may not even implement the method. * May be <code>null</code> or may not even implement the method.
* @return the specific target method, or the original method if the * @return the specific target method, or the original method if the
* <code>targetClass</code> doesn't implement it or is <code>null</code> * <code>targetClass</code> doesn't implement it or is <code>null</code>
* @see org.springframework.aop.support.AopUtils#getMostSpecificMethod
*/ */
public static Method getMostSpecificMethod(Method method, Class targetClass) { public static Method getMostSpecificMethod(Method method, Class targetClass) {
if (method != null && targetClass != null && !targetClass.equals(method.getDeclaringClass())) { if (method != null && targetClass != null && !targetClass.equals(method.getDeclaringClass())) {

9
org.springframework.core/src/main/java/org/springframework/util/MethodInvoker.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2008 the original author or authors. * Copyright 2002-2009 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -37,8 +37,6 @@ import java.lang.reflect.Modifier;
* @since 19.02.2004 * @since 19.02.2004
* @see #prepare * @see #prepare
* @see #invoke * @see #invoke
* @see org.springframework.beans.factory.config.MethodInvokingFactoryBean
* @see org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean
*/ */
public class MethodInvoker { public class MethodInvoker {
@ -197,7 +195,7 @@ public class MethodInvoker {
* @throws ClassNotFoundException if the class name was invalid * @throws ClassNotFoundException if the class name was invalid
*/ */
protected Class resolveClassName(String className) throws ClassNotFoundException { protected Class resolveClassName(String className) throws ClassNotFoundException {
return ClassUtils.forName(className); return ClassUtils.forName(className, ClassUtils.getDefaultClassLoader());
} }
/** /**
@ -216,8 +214,7 @@ public class MethodInvoker {
int minTypeDiffWeight = Integer.MAX_VALUE; int minTypeDiffWeight = Integer.MAX_VALUE;
Method matchingMethod = null; Method matchingMethod = null;
for (int i = 0; i < candidates.length; i++) { for (Method candidate : candidates) {
Method candidate = candidates[i];
if (candidate.getName().equals(targetMethod)) { if (candidate.getName().equals(targetMethod)) {
Class[] paramTypes = candidate.getParameterTypes(); Class[] paramTypes = candidate.getParameterTypes();
if (paramTypes.length == argCount) { if (paramTypes.length == argCount) {

Loading…
Cancel
Save