Returns an instatiator for the specified {@code clazz}.
167721
public static <T> Instantiator<T> newInstantiator(Class<T> clazz)
    {
        final Constructor<T> constructor = getConstructor(clazz);
        if(constructor == null)
        {
            // non-sun jre
            if(newInstanceFromObjectInputStream == null)
            {
                if(objectConstructorId == -1)
                    throw new RuntimeException("Could not resolve constructor for " + clazz);

                return new Android3Instantiator<T>(clazz);
            }
            
            return new Android2Instantiator<T>(clazz);
        }
        
        return new DefaultInstantiator<T>(constructor);
    }
605166
private SSMgr findStaticStateManager(Class<?> clazz) {
		try {
			Field stateManagerField = clazz.getField(Constants.fStaticFieldsName);
			if (stateManagerField == null) {
				throw new IllegalStateException("Cant find field accessor for type "
						+ typeDescriptor.getReloadableType().getName());
			}
			SSMgr stateManager = (SSMgr) stateManagerField.get(null);
			// Field should always have been initialized - it is done at the start of the top most reloadable type <clinit>
			if (stateManager == null) {
				throw new IllegalStateException("Instance of this class has no state manager: " + clazz.getName());
			}
			return stateManager;
		}
		catch (Exception e) {
			throw new IllegalStateException("Unexpectedly unable to find static state manager on class "
					+ clazz.getName(), e);
		}
	}
1217828
public static Class<?> getUserClass(Class<?> clazz) {
		if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
			Class<?> superClass = clazz.getSuperclass();
			if (superClass != null && !Object.class.equals(superClass)) {
				return superClass;
			}
		}
		return clazz;
	}
161472
public static <E extends SqlTypeAdapter<?, ?>> E getAdapter(Class<E> clazz) {
		@SuppressWarnings("unchecked")
		E adapter = (E) cache.get(clazz);

		if (adapter == null) {
			try {
				lock.lock();
				adapter = clazz.newInstance();
				cache.put(clazz, adapter);
			} catch(Throwable e) {
				throw(new KriptonRuntimeException(e));
			} finally {
				lock.unlock();
			}
		}

		return adapter;
	}
261689
public Annotator getAnnotator(Class<? extends Annotator> clazz) {

        if (!Annotator.class.isAssignableFrom(clazz)) {
            throw new IllegalArgumentException("The class name given as a custom annotator (" + clazz.getName() + ") does not refer to a class that implements " + Annotator.class.getName());
        }

        try {
            try {
                Constructor<? extends Annotator> constructor = clazz.getConstructor(GenerationConfig.class);
                return constructor.newInstance(generationConfig);
            } catch (NoSuchMethodException e) {
                return clazz.newInstance();
            }
        } catch (InvocationTargetException | InstantiationException e) {
            throw new IllegalArgumentException("Failed to create a custom annotator from the given class. An exception was thrown on trying to create a new instance.", e.getCause());
        } catch (IllegalAccessException e) {
            throw new IllegalArgumentException("Failed to create a custom annotator from the given class. It appears that we do not have access to this class - is both the class and its no-arg constructor marked public?", e);
        }

    }
1081977
@SuppressWarnings("unchecked")
	public static <T> T get(Class<T> clazz, Object... params) {
		T obj = (T) pool.get(clazz);

		if (null == obj) {
			synchronized (Singleton.class) {
				obj = (T) pool.get(clazz);
				if (null == obj) {
					obj = ReflectUtil.newInstance(clazz, params);
					pool.put(clazz, obj);
				}
			}
		}

		return obj;
	}
1135425
public static final Class<?> getPrimitiveClass(Class<?> clazz)
    {
        Class<?> retValue = clazz;
        if (clazz == java.lang.Long.class)
        {
            retValue = Long.TYPE;
        } else if (clazz == java.lang.Integer.class)
        {
            retValue = Integer.TYPE;
        } else if (clazz == java.lang.Boolean.class)
        {
            retValue = Boolean.TYPE;
        } else if (clazz == java.lang.Short.class)
        {
            retValue = Short.TYPE;
        } else if (clazz == java.lang.Byte.class)
        {
            retValue = Byte.TYPE;
        } else if (clazz == java.lang.Character.class)
        {
            retValue = Character.TYPE;
        } else if (clazz == java.lang.Double.class)
        {
            retValue = Double.TYPE;
        } else if (clazz == java.lang.Float.class)
        {
            retValue = Float.TYPE;
        }
        return retValue;
    }
679418
public static Method getMethod(Class<?> clazz, String name, boolean withParameters) {
        if (clazz == Object.class || clazz == null) {
            return null;
        }

        try {
            // first try without parameters
            Method method = clazz.getDeclaredMethod(name);
            return method;
        } catch (SecurityException e) {
            throw new IllegalStateException(e);
        } catch (NoSuchMethodException e) {
            if (withParameters) {
                Method[] methods = getMethods(clazz);
                for (Method method : methods) {
                    if (name.equals(method.getName())) {
                        return method;
                    }
                }
                return null;
            }
            return getMethod(clazz.getSuperclass(), name, withParameters);
        }
    }
444904
public static ClassLoader getDefaultClassLoader(Class<?> clazz) {
		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
		if (classLoader == null) {
			classLoader = clazz.getClassLoader();
		}
		return classLoader;
	}
69867
public static <A extends Annotation> A getAnnotation(final Class<?> clazz, Class<A> annoClazz) {
        if (clazz == null || annoClazz == null) {
            return null;
        }

        return clazz.getAnnotation(annoClazz);
    }
334676
@SuppressWarnings("unchecked")
    public <C extends Client> Optional<C> findClient(final Class<C> clazz) {
        CommonHelper.assertNotNull("clazz", clazz);
        init();
        if (clazz != null) {
            for (final Client client : getClients()) {
                if (clazz.isAssignableFrom(client.getClass())) {
                    return Optional.of((C) client);
                }
            }
        }
        LOGGER.debug("No client found for class: {}", clazz);
        return Optional.empty();
    }
963334
public static <T> T nullable(Class<T> clazz) {
        AdditionalMatchers.or(isNull(), isA(clazz));
        return  (T) Primitives.defaultValue(clazz);
    }
923268
public static PropertyDescriptor getProperty(Class<?> clazz, String propertyName) {
        if (clazz == null || propertyName == null) {
            return null;
        }

        try {
            return BeanUtils.getPropertyDescriptor(clazz, propertyName);
        }
        catch (Exception e) {
            // if there are any errors in instantiating just return null for the moment
            return null;
        }
    }
43977
protected Constructor<?> getConstructor(Class<?> clazz, Class<?> paramClass) {
        for (Constructor<?> c : clazz.getConstructors()) {
            Class<?>[] paramTypes = c.getParameterTypes();
            if (paramTypes.length != 1) {
                continue;
            }
            if (paramTypes[0].equals(paramClass)) {
                return c;
            }
        }
        return null;
    }
668261
public static ClassLoader getClassLoader(Class<?> clazz) {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        if (loader != null) {
            return loader;
        }
        if (clazz != null) {
            loader = clazz.getClassLoader();
            if (loader != null) {
                return loader;
            }
        }
        return ClassLoader.getSystemClassLoader();
    }
733491
public static Class convertPrimitiveToWrapper(Class clazz) {
		if (clazz == null || !clazz.isPrimitive())
			return clazz;

		return (Class) primativeToWrapperMap.get(clazz);
	}
952226
public static ClassLoader getClassLoader(final Class<?> clazz) {
        // Context class loader can be null
        final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        if (contextClassLoader != null) {
            return contextClassLoader;
        }
        if (clazz != null) {
            // The class loader for a specific class can also be null
            final ClassLoader clazzClassLoader = clazz.getClassLoader();
            if (clazzClassLoader != null) {
                return clazzClassLoader;
            }
        }
        // The only class loader we can rely on for not being null is the system
        // one
        return ClassLoader.getSystemClassLoader();
    }