类java.lang.reflect.GenericDeclaration源码实例Demo

下面列出了怎么用java.lang.reflect.GenericDeclaration的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: j2objc   文件: GenericSignatureParser.java
/**
 * Parses the generic signature of a class and creates the data structure
 * representing the signature.
 *
 * @param genericDecl the GenericDeclaration calling this method
 * @param signature the generic signature of the class
 */
public void parseForClass(GenericDeclaration genericDecl, String signature) {
    setInput(genericDecl, signature);
    if (!eof) {
        parseClassSignature();
    } else {
        if(genericDecl instanceof Class) {
            Class c = (Class) genericDecl;
            this.formalTypeParameters = EmptyArray.TYPE_VARIABLE;
            this.superclassType = c.getSuperclass();
            Class<?>[] interfaces = c.getInterfaces();
            if (interfaces.length == 0) {
                this.interfaceTypes = ListOfTypes.EMPTY;
            } else {
                this.interfaceTypes = new ListOfTypes(interfaces);
            }
        } else {
            this.formalTypeParameters = EmptyArray.TYPE_VARIABLE;
            this.superclassType = Object.class;
            this.interfaceTypes = ListOfTypes.EMPTY;
        }
    }
}
 
源代码2 项目: BIMserver   文件: SServicesMap.java
public Class<?> getGenericType(Method method) {
	Type genericReturnType = method.getGenericReturnType();
	if (method.getGenericReturnType() instanceof ParameterizedType) {
		ParameterizedType parameterizedTypeImpl = (ParameterizedType)genericReturnType;
		Type first = parameterizedTypeImpl.getActualTypeArguments()[0];
		if (first instanceof WildcardType) {
			return null;
		} else if (first instanceof ParameterizedType) {
			return null;
		} else if (first instanceof TypeVariable) {
			TypeVariable<?> typeVariableImpl = (TypeVariable<?>)first;
			GenericDeclaration genericDeclaration = typeVariableImpl.getGenericDeclaration();
			if (genericDeclaration instanceof Class) {
				return (Class<?>) genericDeclaration;
			}
		} else {
			return (Class<?>) first;
		}
	}
	Type genericReturnType2 = method.getGenericReturnType();
	if (genericReturnType2 instanceof Class) {
		return (Class<?>)genericReturnType2;
	}
	return null;
}
 
源代码3 项目: vertx-codegen   文件: TypeParamInfo.java
public static TypeParamInfo create(java.lang.reflect.TypeVariable typeVariable) {
  GenericDeclaration decl = typeVariable.getGenericDeclaration();
  TypeVariable<?>[] typeParams = decl.getTypeParameters();
  for (int index = 0;index < typeParams.length;index++) {
    if (typeParams[index].equals(typeVariable)) {
      if (decl instanceof java.lang.Class) {
        java.lang.Class classDecl = (java.lang.Class) decl;
        return new Class(classDecl.getName(), index, typeVariable.getName());
      } else if (decl instanceof java.lang.reflect.Method) {
        java.lang.reflect.Method methodDecl = (java.lang.reflect.Method) decl;
        return new Method(methodDecl.getDeclaringClass().getName(), methodDecl.getName(), index, typeVariable.getName());
      } else {
        throw new UnsupportedOperationException();
      }
    }
  }
  throw new AssertionError();
}
 
源代码4 项目: Java-Coding-Problems   文件: Main.java
private static void printGenericsOfExceptions(Type genericType) {
    
    if (genericType instanceof TypeVariable) {

        TypeVariable typeVariable = (TypeVariable) genericType;
        GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration();

        System.out.println("Generic declaration: " + genericDeclaration);
            System.out.println("Bounds: ");
            for (Type type: typeVariable.getBounds()) {
                System.out.println(type);
            }
    }
}
 
源代码5 项目: framework   文件: $Gson$Types.java
/**
 * Returns the declaring class of {@code typeVariable}, or {@code null} if it was not declared by
 * a class.
 */
private static Class<?> declaringClassOf(TypeVariable<?> typeVariable) {
  GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration();
  return genericDeclaration instanceof Class
      ? (Class<?>) genericDeclaration
      : null;
}
 
源代码6 项目: cxf   文件: InjectionUtils.java
public static Type getSuperType(Class<?> serviceClass, TypeVariable<?> var) {

        int pos = 0;
        GenericDeclaration genericDeclaration = var.getGenericDeclaration();
        TypeVariable<?>[] vars = genericDeclaration.getTypeParameters();
        for (; pos < vars.length; pos++) {
            if (vars[pos].getName().equals(var.getName())) {
                break;
            }
        }

        ParameterizedType genericSubtype = findGenericDeclaration(genericDeclaration, serviceClass);
        Type result = null;
        if (genericSubtype != null) {
            result = genericSubtype.getActualTypeArguments()[pos];
        }
        if (result instanceof TypeVariable) {
            result = getSuperType(serviceClass, (TypeVariable<?>) result);
        }

        if (result == null || result == Object.class) {
            for (Type bound : var.getBounds()) {
                if (bound != Object.class) {
                    result = bound;
                    break;
                }
            }
        }
        return result;
    }
 
源代码7 项目: j2objc   文件: TypeVariableImpl.java
static TypeVariable findFormalVar(GenericDeclaration layer, String name) {
    TypeVariable[] formalVars = layer.getTypeParameters();
    for (TypeVariable var : formalVars) {
        if (name.equals(var.getName())) {
            return var;
        }
    }
    // resolve() looks up the next level only, if null is returned
    return null;
}
 
源代码8 项目: j2objc   文件: GenericSignatureParser.java
/**
 * Parses the generic signature of a field and creates the data structure
 * representing the signature.
 *
 * @param genericDecl the GenericDeclaration calling this method
 * @param signature the generic signature of the class
 */
public void parseForField(GenericDeclaration genericDecl,
        String signature) {
    setInput(genericDecl, signature);
    if (!eof) {
        this.fieldType = parseFieldTypeSignature();
    }
}
 
源代码9 项目: baratine   文件: JavaWriter.java
/**
 * Prints the Java representation of the type
 */
@SuppressWarnings("unchecked")
public void printType(Type type)
  throws IOException
{
  if (type instanceof Class<?>) {
    printTypeClass((Class<?>) type);
  } 
  else if (type instanceof ParameterizedType) {
    ParameterizedType parameterizedType = (ParameterizedType) type;
    
    printParameterizedType(parameterizedType);
  }
  else if (type instanceof WildcardType) {
    WildcardType wildcardType = (WildcardType) type;
    
    printWildcardType(wildcardType);
  }
  else if (type instanceof TypeVariable<?>) {
    TypeVariable<? extends GenericDeclaration> typeVariable = (TypeVariable<? extends GenericDeclaration>) type;
    
    printTypeVariable(typeVariable);
  }
  else if (type instanceof GenericArrayType) {
    GenericArrayType genericArrayType = (GenericArrayType) type;

    printType(genericArrayType.getGenericComponentType());
    print("[]");
  }
  else {
    throw new UnsupportedOperationException(type.getClass().getName() + " "
        + String.valueOf(type));
  }
}
 
源代码10 项目: xtext-extras   文件: ReflectionTypeFactory.java
protected void enhanceGenericDeclaration(JvmExecutable result, GenericDeclaration declaration) {
	TypeVariable<?>[] typeParameters = declaration.getTypeParameters();
	if (typeParameters.length != 0) {
		InternalEList<JvmTypeParameter> jvmTypeParameters = (InternalEList<JvmTypeParameter>)result.getTypeParameters();
		for (TypeVariable<?> variable : typeParameters) {
			jvmTypeParameters.addUnique(createTypeParameter(variable, result));
		}
	}
}
 
源代码11 项目: jdk8u60   文件: TestPlainArrayNotGeneric.java
private static void check2(Type t, String what) {
    if (t instanceof ParameterizedType) {
        ParameterizedType pt = (ParameterizedType) t;
        check(pt.getActualTypeArguments(), "type argument", what);
    } else if (t instanceof TypeVariable) {
        TypeVariable<?> tv = (TypeVariable<?>) t;
        check(tv.getBounds(), "bound", what);
        GenericDeclaration gd = tv.getGenericDeclaration();
        if (gd instanceof Type)
            check((Type) gd, "declaration containing " + what);
    } else if (t instanceof WildcardType) {
        WildcardType wt = (WildcardType) t;
        check(wt.getLowerBounds(), "lower bound", "wildcard type in " + what);
        check(wt.getUpperBounds(), "upper bound", "wildcard type in " + what);
    } else if (t instanceof Class<?>) {
        Class<?> c = (Class<?>) t;
        check(c.getGenericInterfaces(), "superinterface", c.toString());
        check(c.getGenericSuperclass(), "superclass of " + c);
        check(c.getTypeParameters(), "type parameter", c.toString());
    } else if (t instanceof GenericArrayType) {
        GenericArrayType gat = (GenericArrayType) t;
        Type comp = gat.getGenericComponentType();
        if (comp instanceof Class) {
            fail("Type " + t + " uses GenericArrayType when plain " +
                    "array would do, in " + what);
        } else
            check(comp, "component type of " + what);
    } else {
        fail("TEST BUG: mutant Type " + t + " (a " + t.getClass().getName() + ")");
    }
}
 
源代码12 项目: google-http-java-client   文件: Types.java
/**
 * Resolves the actual type of the given type variable that comes from a field type based on the
 * given context list.
 *
 * <p>In case the type variable can be resolved partially, it will return the partially resolved
 * type variable.
 *
 * @param context context list, ordering from least specific to most specific type context, for
 *     example container class and then its field
 * @param typeVariable type variable
 * @return resolved or partially resolved actual type (type variable, class, parameterized type,
 *     or generic array type, but not wildcard type) or {@code null} if unable to resolve at all
 */
public static Type resolveTypeVariable(List<Type> context, TypeVariable<?> typeVariable) {
  // determine where the type variable was declared
  GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration();
  if (genericDeclaration instanceof Class<?>) {
    Class<?> rawGenericDeclaration = (Class<?>) genericDeclaration;
    // check if the context extends that declaration
    int contextIndex = context.size();
    ParameterizedType parameterizedType = null;
    while (parameterizedType == null && --contextIndex >= 0) {
      parameterizedType =
          getSuperParameterizedType(context.get(contextIndex), rawGenericDeclaration);
    }
    if (parameterizedType != null) {
      // find the type variable's index in the declaration's type parameters
      TypeVariable<?>[] typeParameters = genericDeclaration.getTypeParameters();
      int index = 0;
      for (; index < typeParameters.length; index++) {
        TypeVariable<?> typeParameter = typeParameters[index];
        if (typeParameter.equals(typeVariable)) {
          break;
        }
      }
      // use that index to get the actual type argument
      Type result = parameterizedType.getActualTypeArguments()[index];
      if (result instanceof TypeVariable<?>) {
        // attempt to resolve type variable
        Type resolve = resolveTypeVariable(context, (TypeVariable<?>) result);
        if (resolve != null) {
          return resolve;
        }
        // partially resolved type variable is okay
      }
      return result;
    }
  }
  return null;
}
 
源代码13 项目: baratine   文件: TypeRefBase.java
private static TypeRef visitParameterizedType(TypeVisitor visitor,
                                              Type rawType,
                                              Type []typeArguments,
                                              Map<String,? extends Type> parentMap)
{
  if (rawType instanceof GenericDeclaration) {
    GenericDeclaration decl = (GenericDeclaration) rawType;
    
    TypeVariable<?> []vars = decl.getTypeParameters();
    
    Map<String,Type> varMap = new LinkedHashMap<>();
    
    for (int i = 0; i < vars.length; i++) {
      Type typeArg = typeArguments[i];
      
      if (typeArg instanceof TypeVariable) {
        TypeVariable<?> typeVar = (TypeVariable<?>) typeArg;
        
        Type parentType = parentMap.get(typeVar.getName());
        
        if (parentType != null) {
          varMap.put(vars[i].getName(), parentType);
        }
        else {
          varMap.put(vars[i].getName(), typeVar.getBounds()[0]);
        }
      }
      else {
        varMap.put(vars[i].getName(), typeArg);
      }
    }
    
    return visit(visitor, rawType, varMap);
  }
  else {
    System.out.println("UNKNOWN2: " + rawType);
    return null;
  }
}
 
源代码14 项目: jdk8u-jdk   文件: TestPlainArrayNotGeneric.java
private static void check2(Type t, String what) {
    if (t instanceof ParameterizedType) {
        ParameterizedType pt = (ParameterizedType) t;
        check(pt.getActualTypeArguments(), "type argument", what);
    } else if (t instanceof TypeVariable) {
        TypeVariable<?> tv = (TypeVariable<?>) t;
        check(tv.getBounds(), "bound", what);
        GenericDeclaration gd = tv.getGenericDeclaration();
        if (gd instanceof Type)
            check((Type) gd, "declaration containing " + what);
    } else if (t instanceof WildcardType) {
        WildcardType wt = (WildcardType) t;
        check(wt.getLowerBounds(), "lower bound", "wildcard type in " + what);
        check(wt.getUpperBounds(), "upper bound", "wildcard type in " + what);
    } else if (t instanceof Class<?>) {
        Class<?> c = (Class<?>) t;
        check(c.getGenericInterfaces(), "superinterface", c.toString());
        check(c.getGenericSuperclass(), "superclass of " + c);
        check(c.getTypeParameters(), "type parameter", c.toString());
    } else if (t instanceof GenericArrayType) {
        GenericArrayType gat = (GenericArrayType) t;
        Type comp = gat.getGenericComponentType();
        if (comp instanceof Class) {
            fail("Type " + t + " uses GenericArrayType when plain " +
                    "array would do, in " + what);
        } else
            check(comp, "component type of " + what);
    } else {
        fail("TEST BUG: mutant Type " + t + " (a " + t.getClass().getName() + ")");
    }
}
 
源代码15 项目: GVGAI_GYM   文件: $Gson$Types.java
/**
 * Returns the declaring class of {@code typeVariable}, or {@code null} if it was not declared by
 * a class.
 */
private static Class<?> declaringClassOf(TypeVariable<?> typeVariable) {
  GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration();
  return genericDeclaration instanceof Class
      ? (Class<?>) genericDeclaration
      : null;
}
 
源代码16 项目: xtext-extras   文件: ReflectionTypeFactory.java
protected boolean isLocal(Type parameterType, GenericDeclaration member) {
	if (parameterType instanceof TypeVariable<?>) {
		return member.equals(((TypeVariable<?>) parameterType).getGenericDeclaration());
	} else if (parameterType instanceof GenericArrayType) {
		return isLocal(((GenericArrayType) parameterType).getGenericComponentType(), member);
	}
	return false;
}
 
源代码17 项目: openjdk-jdk8u   文件: TypeVariableImpl.java
@Override
public boolean equals(Object o) {
    if (o instanceof TypeVariable &&
            o.getClass() == TypeVariableImpl.class) {
        TypeVariable<?> that = (TypeVariable<?>) o;

        GenericDeclaration thatDecl = that.getGenericDeclaration();
        String thatName = that.getName();

        return Objects.equals(genericDeclaration, thatDecl) &&
            Objects.equals(name, thatName);

    } else
        return false;
}
 
源代码18 项目: hottub   文件: TypeVariableImpl.java
/**
 * Factory method.
 * @param decl - the reflective object that declared the type variable
 * that this method should create
 * @param name - the name of the type variable to be returned
 * @param bs - an array of ASTs representing the bounds for the type
 * variable to be created
 * @param f - a factory that can be used to manufacture reflective
 * objects that represent the bounds of this type variable
 * @return A type variable with name, bounds, declaration and factory
 * specified
 */
public static <T extends GenericDeclaration>
                         TypeVariableImpl<T> make(T decl, String name,
                                                  FieldTypeSignature[] bs,
                                                  GenericsFactory f) {

    if (!((decl instanceof Class) ||
            (decl instanceof Method) ||
            (decl instanceof Constructor))) {
        throw new AssertionError("Unexpected kind of GenericDeclaration" +
                decl.getClass().toString());
    }
    return new TypeVariableImpl<T>(decl, name, bs, f);
}
 
private static void check2(Type t, String what) {
    if (t instanceof ParameterizedType) {
        ParameterizedType pt = (ParameterizedType) t;
        check(pt.getActualTypeArguments(), "type argument", what);
    } else if (t instanceof TypeVariable) {
        TypeVariable<?> tv = (TypeVariable<?>) t;
        check(tv.getBounds(), "bound", what);
        GenericDeclaration gd = tv.getGenericDeclaration();
        if (gd instanceof Type)
            check((Type) gd, "declaration containing " + what);
    } else if (t instanceof WildcardType) {
        WildcardType wt = (WildcardType) t;
        check(wt.getLowerBounds(), "lower bound", "wildcard type in " + what);
        check(wt.getUpperBounds(), "upper bound", "wildcard type in " + what);
    } else if (t instanceof Class<?>) {
        Class<?> c = (Class<?>) t;
        check(c.getGenericInterfaces(), "superinterface", c.toString());
        check(c.getGenericSuperclass(), "superclass of " + c);
        check(c.getTypeParameters(), "type parameter", c.toString());
    } else if (t instanceof GenericArrayType) {
        GenericArrayType gat = (GenericArrayType) t;
        Type comp = gat.getGenericComponentType();
        if (comp instanceof Class) {
            fail("Type " + t + " uses GenericArrayType when plain " +
                    "array would do, in " + what);
        } else
            check(comp, "component type of " + what);
    } else {
        fail("TEST BUG: mutant Type " + t + " (a " + t.getClass().getName() + ")");
    }
}
 
源代码20 项目: jade-plugin-sql   文件: OperationMapper.java
protected Class<?> resolveParameterType(Type type) {
	if(type instanceof Class) {
		return (Class<?>) type;
	} else if(type instanceof ParameterizedType
			&& ((ParameterizedType) type).getRawType() instanceof Class
			&& Collection.class.isAssignableFrom((Class<?>) ((ParameterizedType) type).getRawType())) {
		
		// GenericDAO中的集合泛型参数
		return resolveParameterType(((ParameterizedType) type).getActualTypeArguments()[0]);
	} else if(type instanceof TypeVariable) {
		
		// GenericDAO中的非集合泛型参数,或许是主键或许是实体。
		GenericDeclaration genericDeclaration = ((TypeVariable<?>) type).getGenericDeclaration();
		if(genericDeclaration == GenericDAO.class) {
			Type[] bounds = ((TypeVariable<?>) type).getBounds();
			
			if(bounds[0] == Object.class) {
				String name = ((TypeVariable<?>) type).getName();
				if("E".equals(name)) {
					return entityType;
				} else if("ID".equals(name)) {
					return primaryKeyType;
				} else {
					throw new MappingException("Unknown type variable \"" + type + "\".");
				}
			} else {
				return resolveParameterType(bounds[0]);
			}
		} else {
			throw new MappingException("Unsupported generic declaration \"" + genericDeclaration + "\".");
		}
	}
	throw new MappingException("Unknown type \"" + type + "\".");
}
 
源代码21 项目: vertx-codegen   文件: Helper.java
/**
 * Return the type of a type parameter element of a given type element when that type parameter
 * element is parameterized by a sub type, directly or indirectly. When the type parameter cannot
 * be resolve, null is returned.
 *
 * @param type the sub type for which the type parameter is parameterized
 * @param typeParam the type parameter to resolve
 * @return the type parameterizing the type parameter
 */
public static <T> Type resolveTypeParameter(Type type, java.lang.reflect.TypeVariable<java.lang.Class<T>> typeParam) {
  if (type instanceof Class<?>) {
    Class<?> classType = (Class<?>) type;
    if (Stream.of(classType.getTypeParameters()).filter(tp -> tp.equals(typeParam)).findFirst().isPresent()) {
      return typeParam;
    }
    List<Type> superTypes = new ArrayList<>();
    if (classType.getGenericSuperclass() != null) {
      superTypes.add(classType.getGenericSuperclass());
    }
    Collections.addAll(superTypes, classType.getGenericInterfaces());
    for (Type superType : superTypes) {
      Type resolved = resolveTypeParameter(superType, typeParam);
      if (resolved != null) {
        return resolved;
      }
    }
  } else if (type instanceof ParameterizedType) {
    ParameterizedType parameterizedType = (ParameterizedType) type;
    Type rawType = parameterizedType.getRawType();
    Type resolvedType = resolveTypeParameter(rawType, typeParam);
    if (resolvedType instanceof java.lang.reflect.TypeVariable<?>) {
      GenericDeclaration owner = ((java.lang.reflect.TypeVariable) resolvedType).getGenericDeclaration();
      if (owner.equals(rawType)) {
        java.lang.reflect.TypeVariable<?>[] typeParams = owner.getTypeParameters();
        for (int i = 0;i < typeParams.length;i++) {
          if (typeParams[i].equals(resolvedType)) {
            return parameterizedType.getActualTypeArguments()[i];
          }
        }
      }
    }
  } else {
    throw new UnsupportedOperationException("Todo " + type.getTypeName() + " " + type.getClass().getName());
  }
  return null;
}
 
private UnknownGenericException(final Class<?> contextType,
                                final String genericName, final GenericDeclaration genericSource,
                                final Throwable cause) {
    super(String.format("Generic '%s'%s is not declared %s",
            genericName, formatSource(genericSource),
            contextType == null ? "" : "on type " + contextType.getName()), cause);
    this.contextType = contextType;
    this.genericName = genericName;
    this.genericSource = genericSource;
}
 
源代码23 项目: Bytecoder   文件: TypeVariableImpl.java
@Override
public boolean equals(Object o) {
    if (o instanceof TypeVariable &&
            o.getClass() == TypeVariableImpl.class) {
        TypeVariable<?> that = (TypeVariable<?>) o;

        GenericDeclaration thatDecl = that.getGenericDeclaration();
        String thatName = that.getName();

        return Objects.equals(genericDeclaration, thatDecl) &&
            Objects.equals(name, thatName);

    } else
        return false;
}
 
源代码24 项目: openjdk-8   文件: TestPlainArrayNotGeneric.java
private static void check2(Type t, String what) {
    if (t instanceof ParameterizedType) {
        ParameterizedType pt = (ParameterizedType) t;
        check(pt.getActualTypeArguments(), "type argument", what);
    } else if (t instanceof TypeVariable) {
        TypeVariable<?> tv = (TypeVariable<?>) t;
        check(tv.getBounds(), "bound", what);
        GenericDeclaration gd = tv.getGenericDeclaration();
        if (gd instanceof Type)
            check((Type) gd, "declaration containing " + what);
    } else if (t instanceof WildcardType) {
        WildcardType wt = (WildcardType) t;
        check(wt.getLowerBounds(), "lower bound", "wildcard type in " + what);
        check(wt.getUpperBounds(), "upper bound", "wildcard type in " + what);
    } else if (t instanceof Class<?>) {
        Class<?> c = (Class<?>) t;
        check(c.getGenericInterfaces(), "superinterface", c.toString());
        check(c.getGenericSuperclass(), "superclass of " + c);
        check(c.getTypeParameters(), "type parameter", c.toString());
    } else if (t instanceof GenericArrayType) {
        GenericArrayType gat = (GenericArrayType) t;
        Type comp = gat.getGenericComponentType();
        if (comp instanceof Class) {
            fail("Type " + t + " uses GenericArrayType when plain " +
                    "array would do, in " + what);
        } else
            check(comp, "component type of " + what);
    } else {
        fail("TEST BUG: mutant Type " + t + " (a " + t.getClass().getName() + ")");
    }
}
 
源代码25 项目: openjdk-jdk9   文件: TestPlainArrayNotGeneric.java
private static void check2(Type t, String what) {
    if (t instanceof ParameterizedType) {
        ParameterizedType pt = (ParameterizedType) t;
        check(pt.getActualTypeArguments(), "type argument", what);
    } else if (t instanceof TypeVariable) {
        TypeVariable<?> tv = (TypeVariable<?>) t;
        check(tv.getBounds(), "bound", what);
        GenericDeclaration gd = tv.getGenericDeclaration();
        if (gd instanceof Type)
            check((Type) gd, "declaration containing " + what);
    } else if (t instanceof WildcardType) {
        WildcardType wt = (WildcardType) t;
        check(wt.getLowerBounds(), "lower bound", "wildcard type in " + what);
        check(wt.getUpperBounds(), "upper bound", "wildcard type in " + what);
    } else if (t instanceof Class<?>) {
        Class<?> c = (Class<?>) t;
        check(c.getGenericInterfaces(), "superinterface", c.toString());
        check(c.getGenericSuperclass(), "superclass of " + c);
        check(c.getTypeParameters(), "type parameter", c.toString());
    } else if (t instanceof GenericArrayType) {
        GenericArrayType gat = (GenericArrayType) t;
        Type comp = gat.getGenericComponentType();
        if (comp instanceof Class) {
            fail("Type " + t + " uses GenericArrayType when plain " +
                    "array would do, in " + what);
        } else
            check(comp, "component type of " + what);
    } else {
        fail("TEST BUG: mutant Type " + t + " (a " + t.getClass().getName() + ")");
    }
}
 
源代码26 项目: gson   文件: $Gson$Types.java
/**
 * Returns the declaring class of {@code typeVariable}, or {@code null} if it was not declared by
 * a class.
 */
private static Class<?> declaringClassOf(TypeVariable<?> typeVariable) {
  GenericDeclaration genericDeclaration = typeVariable.getGenericDeclaration();
  return genericDeclaration instanceof Class
      ? (Class<?>) genericDeclaration
      : null;
}
 
源代码27 项目: dragonwell8_jdk   文件: CoreReflectionFactory.java
private CoreReflectionFactory(GenericDeclaration d, Scope s) {
    decl = d;
    scope = s;
}
 
源代码28 项目: ldp4j   文件: ClassDescription.java
public GenericDeclarationWrapper(GenericDeclaration element) {
	super(element);
}
 
源代码29 项目: TencentKona-8   文件: ReflectionNavigator.java
public BinderArg(GenericDeclaration decl, Type[] args) {
    this(decl.getTypeParameters(), args);
}
 
源代码30 项目: jdk8u60   文件: CoreReflectionFactory.java
private CoreReflectionFactory(GenericDeclaration d, Scope s) {
    decl = d;
    scope = s;
}