Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20756#discussion_r172864835
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
 ---
    @@ -1261,8 +1261,24 @@ case class InitializeJavaBean(beanInstance: 
Expression, setters: Map[String, Exp
       override def children: Seq[Expression] = beanInstance +: 
setters.values.toSeq
       override def dataType: DataType = beanInstance.dataType
     
    -  override def eval(input: InternalRow): Any =
    -    throw new UnsupportedOperationException("Only code-generated 
evaluation is supported.")
    +  override def eval(input: InternalRow): Any = {
    +    val instance = beanInstance.eval(input).asInstanceOf[Object]
    +    if (instance != null) {
    +      setters.foreach { case (setterMethod, fieldExpr) =>
    --- End diff --
    
    `MethodType.methodType(classOf[Object], fieldClass))` does not work too. 
    
    Actually I am not sure if `MethodHandle` can find the `def add(x$1: Int): 
Boolean` of `java.util.LinkedList`.
    
    ```scala
    scala> lookup.findVirtual(classOf[java.util.LinkedList[Int]], "add", 
MethodType.methodType(classOf[Boolean], classOf[Int]))
    
    java.lang.NoSuchMethodException: no such method: 
java.util.LinkedList.add(int)boolean/invokeVirtual
    ```
    
    Am I missing something?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to