resolveTypeParameter() — netty Function Reference
Architecture documentation for the resolveTypeParameter() function in ReflectionUtil.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD a5bea1aa_8419_848e_9649_5391157d2623["resolveTypeParameter()"] 256133bf_a518_6230_b946_c6d646a25eb5["ReflectionUtil"] a5bea1aa_8419_848e_9649_5391157d2623 -->|defined in| 256133bf_a518_6230_b946_c6d646a25eb5 d3ba72cb_b3af_6669_8eb0_62d09acd9ab8["fail()"] a5bea1aa_8419_848e_9649_5391157d2623 -->|calls| d3ba72cb_b3af_6669_8eb0_62d09acd9ab8 style a5bea1aa_8419_848e_9649_5391157d2623 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/main/java/io/netty/util/internal/ReflectionUtil.java lines 71–138
public static Class<?> resolveTypeParameter(final Object object,
Class<?> parametrizedSuperclass,
String typeParamName) {
final Class<?> thisClass = object.getClass();
Class<?> currentClass = thisClass;
for (;;) {
if (currentClass.getSuperclass() == parametrizedSuperclass) {
int typeParamIndex = -1;
TypeVariable<?>[] typeParams = currentClass.getSuperclass().getTypeParameters();
for (int i = 0; i < typeParams.length; i ++) {
if (typeParamName.equals(typeParams[i].getName())) {
typeParamIndex = i;
break;
}
}
if (typeParamIndex < 0) {
throw new IllegalStateException(
"unknown type parameter '" + typeParamName + "': " + parametrizedSuperclass);
}
Type genericSuperType = currentClass.getGenericSuperclass();
if (!(genericSuperType instanceof ParameterizedType)) {
return Object.class;
}
Type[] actualTypeParams = ((ParameterizedType) genericSuperType).getActualTypeArguments();
Type actualTypeParam = actualTypeParams[typeParamIndex];
if (actualTypeParam instanceof ParameterizedType) {
actualTypeParam = ((ParameterizedType) actualTypeParam).getRawType();
}
if (actualTypeParam instanceof Class) {
return (Class<?>) actualTypeParam;
}
if (actualTypeParam instanceof GenericArrayType) {
Type componentType = ((GenericArrayType) actualTypeParam).getGenericComponentType();
if (componentType instanceof ParameterizedType) {
componentType = ((ParameterizedType) componentType).getRawType();
}
if (componentType instanceof Class) {
return Array.newInstance((Class<?>) componentType, 0).getClass();
}
}
if (actualTypeParam instanceof TypeVariable) {
// Resolved type parameter points to another type parameter.
TypeVariable<?> v = (TypeVariable<?>) actualTypeParam;
if (!(v.getGenericDeclaration() instanceof Class)) {
return Object.class;
}
currentClass = thisClass;
parametrizedSuperclass = (Class<?>) v.getGenericDeclaration();
typeParamName = v.getName();
if (parametrizedSuperclass.isAssignableFrom(thisClass)) {
continue;
}
return Object.class;
}
return fail(thisClass, typeParamName);
}
currentClass = currentClass.getSuperclass();
if (currentClass == null) {
return fail(thisClass, typeParamName);
}
}
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does resolveTypeParameter() do?
resolveTypeParameter() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/internal/ReflectionUtil.java.
Where is resolveTypeParameter() defined?
resolveTypeParameter() is defined in common/src/main/java/io/netty/util/internal/ReflectionUtil.java at line 71.
What does resolveTypeParameter() call?
resolveTypeParameter() calls 1 function(s): fail.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free