@Override public <T> Object create(Class<T> toLoad) { try { return ReflectionHelper.getInstance(toLoad); } catch (Exception e) { return null; } }
/** * Get the Class from the class name. * <p> * The context class loader will be utilized if accessible and non-null. * Otherwise the defining class loader of this class will * be utilized. * * @param name the class name. * @return the Class, otherwise null if the class cannot be found. */ public static Class classForName(String name) { return classForName(name, getContextClassLoader()); }
/** * Get the Class from the class name. * <p> * The context class loader will be utilized if accessible and non-null. * Otherwise the defining class loader of this class will * be utilized. * * @param name the class name. * @return the Class, otherwise null if the class cannot be found. * @throws ClassNotFoundException if the class cannot be found. */ public static Class classForNameWithException(String name) throws ClassNotFoundException { return classForNameWithException(name, getContextClassLoader()); }
/** * Find a type of the class given it's Superclass. * * @param inspectedClass Class whose type is searched for. * @param superClass Class relatively to which the search is performed. * @return type of the class. */ public static Class<?> getClassType(Class<?> inspectedClass, Class<?> superClass) { ReflectionHelper.DeclaringClassInterfacePair p = ReflectionHelper.getClass(inspectedClass, superClass); Class[] as = ReflectionHelper.getParameterizedClassArguments(p); if (as == null) { return null; } else { return as[0]; } }
Class engineProviderClazz; try { engineProviderClazz = ReflectionHelper.classForNameWithException(containerProviderClassName); } catch (ClassNotFoundException e) { collector.addException(e); this.container = (ClientContainer) ReflectionHelper.getInstance(engineProviderClazz, collector); if (!collector.isEmpty()) { throw new RuntimeException(collector.composeComprehensiveException());
(Class<HostnameVerifier>) ReflectionHelper.classForName(className); if (hostnameVerifierClass != null) { try { final HostnameVerifier hostnameVerifier = ReflectionHelper.getInstance(hostnameVerifierClass); sslEngineConfigurator.setHostnameVerifier(hostnameVerifier); } catch (IllegalAccessException | InstantiationException e) {
private static DeclaringClassInterfacePair getClass(Class concrete, Class iface, Class c) { Type[] gis = c.getGenericInterfaces(); DeclaringClassInterfacePair p = getType(concrete, iface, c, gis); if (p != null) { return p; } c = c.getSuperclass(); if (c == null || c == Object.class) { return null; } return getClass(concrete, iface, c); }
/** * Get privileged exception action to obtain Class from given class name. * If run using security manager, the returned privileged exception action * must be invoked within a doPrivileged block. * <p> * The actual context class loader will be utilized if accessible and non-null. * Otherwise the defining class loader of the calling class will be utilized. * * @param <T> class type. * @param name class name. * @return privileged exception action to obtain the Class. * The action could throw {@link ClassNotFoundException} or return {@code null} if the class cannot be found. * @throws ClassNotFoundException when provided string contains classname of unknown class. * @see AccessController#doPrivileged(java.security.PrivilegedExceptionAction) */ public static <T> PrivilegedExceptionAction<Class<T>> classForNameWithExceptionPEA(final String name) throws ClassNotFoundException { return classForNameWithExceptionPEA(name, getContextClassLoader()); }
c = (Class) t; try { return new ClassTypePair(getArrayClass(c)); } catch (Exception e) { return new ClassTypePair(getArrayClass(c), t); } catch (Exception e) { return null; return resolveTypeVariable(c, dc, tv, submap);
if (ignoreOnClassNotFound) { try { AccessController.doPrivileged(ReflectionHelper.classForNameWithExceptionPEA(nextName, loader)); } catch (ClassNotFoundException ex) { handleClassNotFoundException();
/** * Find the declaring class that implements or extends an interface. * * @param concrete the concrete class than directly or indirectly implements or extends an interface class. * @param iface the interface class. * @return the tuple of the declaring class and the generic interface type. */ public static DeclaringClassInterfacePair getClass(Class concrete, Class iface) { return getClass(concrete, iface, concrete); }
private static Class getClassOfType(Type type) { if (type instanceof Class) { return (Class) type; } else if (type instanceof GenericArrayType) { GenericArrayType arrayType = (GenericArrayType) type; Type t = arrayType.getGenericComponentType(); if (t instanceof Class) { return getArrayClass((Class) t); } } else if (type instanceof ParameterizedType) { ParameterizedType subType = (ParameterizedType) type; Type t = subType.getRawType(); if (t instanceof Class) { return (Class) t; } } return null; }
for (Method _m : c.getMethods()) { if (_m.getName().equals(m.getName()) && _m.getParameterTypes().length == m.getParameterTypes().length) { if (compareParameterTypes(m.getGenericParameterTypes(), _m.getGenericParameterTypes())) { return _m;
Class engineProviderClazz; try { engineProviderClazz = ReflectionHelper.classForNameWithException(containerProviderClassName); } catch (ClassNotFoundException e) { collector.addException(e); this.container = (ClientContainer) ReflectionHelper.getInstance(engineProviderClazz, collector); if (!collector.isEmpty()) { throw new RuntimeException(collector.composeComprehensiveException());
/** * Find a type of the class given it's Superclass. * * @param inspectedClass Class whose type is searched for. * @param superClass Class relatively to which the search is performed. * @return type of the class. */ public static Class<?> getClassType(Class<?> inspectedClass, Class<?> superClass) { ReflectionHelper.DeclaringClassInterfacePair p = ReflectionHelper.getClass(inspectedClass, superClass); Class[] as = ReflectionHelper.getParameterizedClassArguments(p); if (as == null) { return null; } else { return as[0]; } }
private static DeclaringClassInterfacePair getClass(Class concrete, Class iface, Class c) { Type[] gis = c.getGenericInterfaces(); DeclaringClassInterfacePair p = getType(concrete, iface, c, gis); if (p != null) { return p; } c = c.getSuperclass(); if (c == null || c == Object.class) { return null; } return getClass(concrete, iface, c); }
/** * Get privileged exception action to obtain Class from given class name. * If run using security manager, the returned privileged exception action * must be invoked within a doPrivileged block. * <p> * The actual context class loader will be utilized if accessible and non-null. * Otherwise the defining class loader of the calling class will be utilized. * * @param <T> class type. * @param name class name. * @return privileged exception action to obtain the Class. * The action could throw {@link ClassNotFoundException} or return {@code null} if the class cannot be found. * @throws ClassNotFoundException when provided string contains classname of unknown class. * @see AccessController#doPrivileged(java.security.PrivilegedExceptionAction) */ public static <T> PrivilegedExceptionAction<Class<T>> classForNameWithExceptionPEA(final String name) throws ClassNotFoundException { return classForNameWithExceptionPEA(name, getContextClassLoader()); }
c = (Class) t; try { return new ClassTypePair(getArrayClass(c)); } catch (Exception e) { return new ClassTypePair(getArrayClass(c), t); } catch (Exception e) { return null; return resolveTypeVariable(c, dc, tv, submap);
if (ignoreOnClassNotFound) { try { AccessController.doPrivileged(ReflectionHelper.classForNameWithExceptionPEA(nextName, loader)); } catch (ClassNotFoundException ex) { handleClassNotFoundException();
/** * Find the declaring class that implements or extends an interface. * * @param concrete the concrete class than directly or indirectly implements or extends an interface class. * @param iface the interface class. * @return the tuple of the declaring class and the generic interface type. */ public static DeclaringClassInterfacePair getClass(Class concrete, Class iface) { return getClass(concrete, iface, concrete); }