From 3d034cb046475a373bfd4daff9bfe9f72b73226f Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 15 Apr 2009 22:33:56 +0000 Subject: [PATCH] officially deprecated ClassUtils.forName variant without ClassLoader git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1005 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../main/java/org/springframework/util/ClassUtils.java | 6 ++++-- .../java/org/springframework/util/MethodInvoker.java | 9 +++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java b/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java index ac69a88c0ab..349a13a2834 100644 --- a/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java +++ b/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 * @see Class#forName(String, boolean, ClassLoader) * @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 { return forName(name, getDefaultClassLoader()); } @@ -298,7 +301,7 @@ public abstract class ClassUtils { * according to the JVM's naming rules for primitive classes. *

Also supports the JVM's internal class names for primitive arrays. * Does not 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 * @return the primitive class, or null if the name does not denote * a primitive class or primitive array class @@ -673,7 +676,6 @@ public abstract class ClassUtils { * May be null or may not even implement the method. * @return the specific target method, or the original method if the * targetClass doesn't implement it or is null - * @see org.springframework.aop.support.AopUtils#getMostSpecificMethod */ public static Method getMostSpecificMethod(Method method, Class targetClass) { if (method != null && targetClass != null && !targetClass.equals(method.getDeclaringClass())) { diff --git a/org.springframework.core/src/main/java/org/springframework/util/MethodInvoker.java b/org.springframework.core/src/main/java/org/springframework/util/MethodInvoker.java index e13cdbdecba..5d8d3a09a97 100644 --- a/org.springframework.core/src/main/java/org/springframework/util/MethodInvoker.java +++ b/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"); * 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 * @see #prepare * @see #invoke - * @see org.springframework.beans.factory.config.MethodInvokingFactoryBean - * @see org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean */ public class MethodInvoker { @@ -197,7 +195,7 @@ public class MethodInvoker { * @throws ClassNotFoundException if the class name was invalid */ 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; Method matchingMethod = null; - for (int i = 0; i < candidates.length; i++) { - Method candidate = candidates[i]; + for (Method candidate : candidates) { if (candidate.getName().equals(targetMethod)) { Class[] paramTypes = candidate.getParameterTypes(); if (paramTypes.length == argCount) {