本文整理汇总了Java中sun.reflect.generics.reflectiveObjects.GenericArrayTypeImpl.make方法的典型用法代码示例。如果您正苦于以下问题:Java GenericArrayTypeImpl.make方法的具体用法?Java GenericArrayTypeImpl.make怎么用?Java GenericArrayTypeImpl.make使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.reflect.generics.reflectiveObjects.GenericArrayTypeImpl
的用法示例。
在下文中一共展示了GenericArrayTypeImpl.make方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolve
import sun.reflect.generics.reflectiveObjects.GenericArrayTypeImpl; //导入方法依赖的package包/类
/**
* Replaces the given {@code formal} type
* with the type it stand for in this type resolver.
*
* @param formal the array of types to resolve
* @return a resolved type
*/
private Type resolve(Type formal) {
if (formal instanceof Class) {
return formal;
}
if (formal instanceof GenericArrayType) {
Type comp = ((GenericArrayType)formal).getGenericComponentType();
comp = resolve(comp);
return (comp instanceof Class)
? Array.newInstance((Class<?>)comp, 0).getClass()
: GenericArrayTypeImpl.make(comp);
}
if (formal instanceof ParameterizedType) {
ParameterizedType fpt = (ParameterizedType)formal;
Type[] actuals = resolve(fpt.getActualTypeArguments());
return ParameterizedTypeImpl.make(
(Class<?>)fpt.getRawType(), actuals, fpt.getOwnerType());
}
if (formal instanceof WildcardType) {
WildcardType fwt = (WildcardType)formal;
Type[] upper = resolve(fwt.getUpperBounds());
Type[] lower = resolve(fwt.getLowerBounds());
return new WildcardTypeImpl(upper, lower);
}
if (!(formal instanceof TypeVariable)) {
throw new IllegalArgumentException("Bad Type kind: " + formal.getClass());
}
Type actual = this.map.get((TypeVariable) formal);
if (actual == null || actual.equals(formal)) {
return formal;
}
actual = fixGenericArray(actual);
return resolve(actual);
// A variable can be bound to another variable that is itself bound
// to something. For example, given:
// class Super<T> {...}
// class Mid<X> extends Super<T> {...}
// class Sub extends Mid<String>
// the variable T is bound to X, which is in turn bound to String.
// So if we have to resolve T, we need the tail recursion here.
}