Skip to content

Commit

Permalink
HV-1313 Support GenericArrayType in ReflectionHelper.getClassFromType()
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet authored and gunnarmorling committed May 11, 2017
1 parent b9d6e71 commit 5cd2b8f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Expand Up @@ -9,7 +9,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedArrayType;
import java.lang.reflect.AnnotatedType;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;

Expand Down Expand Up @@ -57,17 +56,12 @@ else if ( arrayElementType == char.class ) {
}

public ArrayElement(Type arrayType) {
if ( arrayType instanceof GenericArrayType ) {
this.containerClass = Object[].class;
Class<?> arrayClass = ReflectionHelper.getClassFromType( arrayType );
if ( arrayClass.getComponentType().isPrimitive() ) {
this.containerClass = arrayClass;
}
else {
Class<?> arrayClass = ReflectionHelper.getClassFromType( arrayType );
if ( arrayClass.getComponentType().isPrimitive() ) {
this.containerClass = arrayClass;
}
else {
this.containerClass = Object[].class;
}
this.containerClass = Object[].class;
}
}

Expand Down
Expand Up @@ -11,6 +11,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Executable;
import java.lang.reflect.Field;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -301,6 +302,9 @@ public static Class<?> getClassFromType(Type type) {
if ( type instanceof ParameterizedType ) {
return getClassFromType( ( (ParameterizedType) type ).getRawType() );
}
if ( type instanceof GenericArrayType ) {
return Object[].class;
}
throw log.getUnableToConvertTypeToClassException( type );
}

Expand Down

0 comments on commit 5cd2b8f

Please sign in to comment.