jdk/src/share/classes/com/sun/beans/finder/ConstructorFinder.java
Print this page
*** 22,36 ****
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.beans.finder;
! import com.sun.beans.WeakCache;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import static sun.reflect.misc.ReflectUtil.isPackageAccessible;
/**
* This utility class provides {@code static} methods
* to find a public constructor with specified parameter types
--- 22,37 ----
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.beans.finder;
! import com.sun.beans.util.Cache;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
+ import static com.sun.beans.util.Cache.Kind.SOFT;
import static sun.reflect.misc.ReflectUtil.isPackageAccessible;
/**
* This utility class provides {@code static} methods
* to find a public constructor with specified parameter types
*** 39,49 ****
* @since 1.7
*
* @author Sergey A. Malenkov
*/
public final class ConstructorFinder extends AbstractFinder<Constructor<?>> {
! private static final WeakCache<Signature, Constructor<?>> CACHE = new WeakCache<Signature, Constructor<?>>();
/**
* Finds public constructor
* that is declared in public class.
*
--- 40,61 ----
* @since 1.7
*
* @author Sergey A. Malenkov
*/
public final class ConstructorFinder extends AbstractFinder<Constructor<?>> {
! private static final Cache<Signature, Constructor<?>> CACHE = new Cache<Signature, Constructor<?>>(SOFT, SOFT) {
! @Override
! public Constructor create(Signature signature) {
! try {
! ConstructorFinder finder = new ConstructorFinder(signature.getArgs());
! return finder.find(signature.getType().getConstructors());
! }
! catch (Exception exception) {
! throw new SignatureException(exception);
! }
! }
! };
/**
* Finds public constructor
* that is declared in public class.
*
*** 67,83 ****
throw new NoSuchMethodException("Class is not accessible");
}
PrimitiveWrapperMap.replacePrimitivesWithWrappers(args);
Signature signature = new Signature(type, args);
! Constructor<?> constructor = CACHE.get(signature);
! if (constructor != null) {
! return constructor;
! }
! constructor = new ConstructorFinder(args).find(type.getConstructors());
! CACHE.put(signature, constructor);
! return constructor;
}
/**
* Creates constructor finder with specified array of parameter types.
*
--- 79,94 ----
throw new NoSuchMethodException("Class is not accessible");
}
PrimitiveWrapperMap.replacePrimitivesWithWrappers(args);
Signature signature = new Signature(type, args);
! try {
! return CACHE.get(signature);
! }
! catch (SignatureException exception) {
! throw exception.toNoSuchMethodException("Constructor is not found");
! }
}
/**
* Creates constructor finder with specified array of parameter types.
*