#1512 ffi 'override once' with array

vkuzkokov Thu 28 Apr 2011

So here I have a virtual method:

package some.test;

public interface Simple
  Object[] values();

That I want to implement though FFI:

using [java] some.test

class Sth : Simple
  override once Obj?[]? values() { [,] }
  Void main()

It compiles but doesn't actually work:

sys::CastErr: java.lang.ClassCastException: fan.sys.List cannot be cast to [Ljava.lang.Object;
  a_0::Sth.values (/C:/temp/a.fan:5)
  a_0::Sth.main (/C:/temp/a.fan:8)
  java.lang.reflect.Method.invoke (Unknown)
  fan.sys.Method.invoke (Method.java:552)
  fan.sys.Method$MethodFunc.callOn (Method.java:230)
  fan.sys.Method.callOn (Method.java:139)
  fanx.tools.Fan.callMain (Fan.java:137)
  fanx.tools.Fan.executeFile (Fan.java:88)
  fanx.tools.Fan.execute (Fan.java:34)
  fanx.tools.Fan.run (Fan.java:250)
  fanx.tools.Fan.main (Fan.java:288)

brian Thu 28 Apr 2011

Promoted to ticket #1512 and assigned to brian

sounds like maybe a problem with the implicit field that gets created

brian Wed 1 Jun 2011

Ticket resolved in 1.0.59

I messed around with lots of different solutions to this problem, but I don't think there is really a satisfactory solution without severely complicating the design or using a second field. Given the back and forth nature of Java array to/from Fantom List solutions, any non-trivial once solution would have misleading performance. So I decided to just disallow use of a FFI type with a once method. The work around is to manually write the caching code.

Login or Signup to reply.