[
https://issues.apache.org/jira/browse/FLINK-1799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14502897#comment-14502897
]
ASF GitHub Bot commented on FLINK-1799:
---------------------------------------
Github user StephanEwen commented on a diff in the pull request:
https://github.com/apache/flink/pull/582#discussion_r28691764
--- Diff:
flink-java/src/main/java/org/apache/flink/api/java/typeutils/ObjectArrayTypeInfo.java
---
@@ -143,6 +143,18 @@ else if (type instanceof Class<?> && ((Class<?>)
type).isArray()
throw new InvalidTypesException("The given type is not a valid
object array.");
}
+ /**
+ * Creates a new {@link
org.apache.flink.api.java.typeutils.ObjectArrayTypeInfo} from a
+ * {@link TypeInformation} for the component type.
+ *
+ * <p>
+ * This must be used in cases where the complete type of the array is
not available as a
+ * {@link java.lang.reflect.Type} or {@link java.lang.Class}.
+ */
+ public static <T, C> ObjectArrayTypeInfo<T, C>
getInfoFor(TypeInformation<C> componentInfo) {
+ return new ObjectArrayTypeInfo<T, C>(Object[].class,
componentInfo.getTypeClass(), componentInfo);
--- End diff --
Is `Object[].class` actually correct? Why not give the class of the real
array type? There are a few ways to get that, for example
`Array.newInstance(clazz, 0).getClass();`
> Scala API does not support generic arrays
> -----------------------------------------
>
> Key: FLINK-1799
> URL: https://issues.apache.org/jira/browse/FLINK-1799
> Project: Flink
> Issue Type: Bug
> Reporter: Till Rohrmann
> Assignee: Aljoscha Krettek
>
> The Scala API does not support generic arrays at the moment. It throws a
> rather unhelpful error message ```InvalidTypesException: The given type is
> not a valid object array```.
> Code to reproduce the problem is given below:
> {code}
> def main(args: Array[String]) {
> foobar[Double]
> }
> def foobar[T: ClassTag: TypeInformation]: DataSet[Block[T]] = {
> val tpe = createTypeInformation[Array[T]]
> null
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)