#1077 VerifyError when Safe Invoke is used to call java method returning int

alex_panchenko Fri 16 Apr 2010

Launching this

using [java] java.util::List
class Main 
{
  Obj? test(List? list)
  {
    return list?.size()
  }
  
  public static Void main(Str[] args)
  {
    echo("it runs")
  }
}

Results in

java.lang.VerifyError: (class: fan/Main_0/Main, 
method: test signature: (Ljava/util/List;)Ljava/lang/Object;) Mismatched stack types
	at java.lang.Class.getDeclaredFields0(Native Method)
	at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
	at java.lang.Class.getDeclaredFields(Class.java:1743)
	at fan.sys.ClassType.finishSlots(ClassType.java:562)
	at fan.sys.ClassType.finish(ClassType.java:525)
	at fan.sys.Method$MethodFunc.isStatic(Method.java:459)
	at fan.sys.Method$MethodFunc.callList(Method.java:175)
	at fan.sys.Method.callList(Method.java:147)
	at fanx.tools.Fan.callMain(Fan.java:135)
	at fanx.tools.Fan.executeFile(Fan.java:88)
	at fanx.tools.Fan.execute(Fan.java:34)
	at fanx.tools.Fan.run(Fan.java:236)
	at fanx.tools.Fan.main(Fan.java:274)

If I change ?. to . then it compiles successfully.

brian Fri 16 Apr 2010

Promoted to ticket #1077 and assigned to brian

brian Tue 11 May 2010

Ticket resolved in 1.0.53

This problem uncovered a number of issues:

  1. CodeAsm was using the incorrect type for the Pop of the nullable target in a safe invoke call
  2. the Java primitive types were not correctly reporting themselves as value types
  3. I fixed the Java primitive type conversion to nullable types to match the standard Fantom nullable types Bool?, Int? and Float?
  4. FFI coercion must occur after safe invoke coercion

changeset

Login or Signup to reply.