#1271 Java FFI mixin routers with primitives

DanielFathThu 28 Oct 2010

Anyway here is the thing. I have a class MigPane : Pane once I change it to MigPane : Pane, MigContainer ('MigContainer' is a mixin that extends MigComponent and implements ComponentWrapper from Java FFI) I get below exception. I thought FFI could extend/implement interface regardless the level.

java.lang.IllegalStateException: F
at fanx.emit.FCodeEmit.returnOp(FCodeEmit.java:848)
at fanx.emit.FCodeEmit.returnOp(FCodeEmit.java:836)
at fanx.emit.FCodeEmit.returnOp(FCodeEmit.java:834)
at fanx.emit.FCodeEmit.emitInstructions(FCodeEmit.java:125)
at fanx.emit.FCodeEmit.emit(FCodeEmit.java:59)
at fanx.emit.FMethodEmit.doEmit(FMethodEmit.java:400)
at fanx.emit.FMethodEmit.emitMixinBody(FMethodEmit.java:277)
at fanx.emit.FMixinBodyEmit.emit(FMixinBodyEmit.java:74)
at fanx.emit.FMixinBodyEmit.emit(FMixinBodyEmit.java:41)
at fanx.emit.FTypeEmit.emit(FTypeEmit.java:40)
at fan.sys.BootEnv.loadTypeClasses(BootEnv.java:215)
at fan.sys.ClassType.emit(ClassType.java:466)
at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:164)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at fan.sys.FanClassLoader.findPendingClass(FanClassLoader.java:118)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:88)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at fan.sys.FanClassLoader.loadFan(FanClassLoader.java:57)
at fan.sys.BootEnv.loadTypeClasses(BootEnv.java:220)
at fan.sys.ClassType.emit(ClassType.java:466)
at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:164)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at fan.sys.FanClassLoader.findPendingClass(FanClassLoader.java:118)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:88)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at fan.sys.FanClassLoader.loadFan(FanClassLoader.java:57)
at fan.sys.BootEnv.loadTypeClasses(BootEnv.java:220)
at fan.sys.ClassType.emit(ClassType.java:466)
at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:164)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at fan.mig.Main.main(Main.fan:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fan.sys.Method.invoke(Method.java:536)
at fan.sys.Method$MethodFunc.callList(Method.java:182)
at fan.sys.Method.callList(Method.java:147)
at fanx.tools.Fan.callMain(Fan.java:135)
at fanx.tools.Fan.executeType(Fan.java:102)
at fanx.tools.Fan.execute(Fan.java:38)
at fanx.tools.Fan.run(Fan.java:236)
at fanx.tools.Fan.main(Fan.java:274)
java.lang.RuntimeException: java.lang.IllegalStateException: F
at fan.sys.BootEnv.loadTypeClasses(BootEnv.java:227)
at fan.sys.ClassType.emit(ClassType.java:466)
at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:164)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at fan.sys.FanClassLoader.findPendingClass(FanClassLoader.java:118)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:88)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at fan.sys.FanClassLoader.loadFan(FanClassLoader.java:57)
at fan.sys.BootEnv.loadTypeClasses(BootEnv.java:220)
at fan.sys.ClassType.emit(ClassType.java:466)
at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:164)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at fan.sys.FanClassLoader.findPendingClass(FanClassLoader.java:118)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:88)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at fan.sys.FanClassLoader.loadFan(FanClassLoader.java:57)
at fan.sys.BootEnv.loadTypeClasses(BootEnv.java:220)
at fan.sys.ClassType.emit(ClassType.java:466)
at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:164)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at fan.mig.Main.main(Main.fan:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fan.sys.Method.invoke(Method.java:536)
at fan.sys.Method$MethodFunc.callList(Method.java:182)
at fan.sys.Method.callList(Method.java:147)
at fanx.tools.Fan.callMain(Fan.java:135)
at fanx.tools.Fan.executeType(Fan.java:102)
at fanx.tools.Fan.execute(Fan.java:38)
at fanx.tools.Fan.run(Fan.java:236)
at fanx.tools.Fan.main(Fan.java:274)
sys::Err: Cannot emit: mig::MigComponent
at fan.sys.Err.make(Err.java:78)
at fan.sys.Err.make(Err.java:68)
at fan.sys.ClassType.emit(ClassType.java:474)
at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:164)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at fan.sys.FanClassLoader.findPendingClass(FanClassLoader.java:118)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:88)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at fan.sys.FanClassLoader.loadFan(FanClassLoader.java:57)
at fan.sys.BootEnv.loadTypeClasses(BootEnv.java:220)
at fan.sys.ClassType.emit(ClassType.java:466)
at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:164)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at fan.sys.FanClassLoader.findPendingClass(FanClassLoader.java:118)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:88)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at fan.sys.FanClassLoader.loadFan(FanClassLoader.java:57)
at fan.sys.BootEnv.loadTypeClasses(BootEnv.java:220)
at fan.sys.ClassType.emit(ClassType.java:466)
at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:164)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at fan.mig.Main.main(Main.fan:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fan.sys.Method.invoke(Method.java:536)
at fan.sys.Method$MethodFunc.callList(Method.java:182)
at fan.sys.Method.callList(Method.java:147)
at fanx.tools.Fan.callMain(Fan.java:135)
at fanx.tools.Fan.executeType(Fan.java:102)
at fanx.tools.Fan.execute(Fan.java:38)
at fanx.tools.Fan.run(Fan.java:236)
at fanx.tools.Fan.main(Fan.java:274)
java.lang.RuntimeException: sys::Err: Cannot emit: mig::MigComponent
at fan.sys.BootEnv.loadTypeClasses(BootEnv.java:227)
at fan.sys.ClassType.emit(ClassType.java:466)
at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:164)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at fan.sys.FanClassLoader.findPendingClass(FanClassLoader.java:118)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:88)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at fan.sys.FanClassLoader.loadFan(FanClassLoader.java:57)
at fan.sys.BootEnv.loadTypeClasses(BootEnv.java:220)
at fan.sys.ClassType.emit(ClassType.java:466)
at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:164)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at fan.mig.Main.main(Main.fan:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fan.sys.Method.invoke(Method.java:536)
at fan.sys.Method$MethodFunc.callList(Method.java:182)
at fan.sys.Method.callList(Method.java:147)
at fanx.tools.Fan.callMain(Fan.java:135)
at fanx.tools.Fan.executeType(Fan.java:102)
at fanx.tools.Fan.execute(Fan.java:38)
at fanx.tools.Fan.run(Fan.java:236)
at fanx.tools.Fan.main(Fan.java:274)
sys::Err: Cannot emit: mig::MigContainer
at fan.sys.Err.make(Err.java:78)
at fan.sys.Err.make(Err.java:68)
at fan.sys.ClassType.emit(ClassType.java:474)
at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:164)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at fan.sys.FanClassLoader.findPendingClass(FanClassLoader.java:118)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:88)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at fan.sys.FanClassLoader.loadFan(FanClassLoader.java:57)
at fan.sys.BootEnv.loadTypeClasses(BootEnv.java:220)
at fan.sys.ClassType.emit(ClassType.java:466)
at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:164)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at fan.mig.Main.main(Main.fan:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fan.sys.Method.invoke(Method.java:536)
at fan.sys.Method$MethodFunc.callList(Method.java:182)
at fan.sys.Method.callList(Method.java:147)
at fanx.tools.Fan.callMain(Fan.java:135)
at fanx.tools.Fan.executeType(Fan.java:102)
at fanx.tools.Fan.execute(Fan.java:38)
at fanx.tools.Fan.run(Fan.java:236)
at fanx.tools.Fan.main(Fan.java:274)
java.lang.RuntimeException: sys::Err: Cannot emit: mig::MigContainer
at fan.sys.BootEnv.loadTypeClasses(BootEnv.java:227)
at fan.sys.ClassType.emit(ClassType.java:466)
at fan.sys.FanClassLoader.findFanClass(FanClassLoader.java:164)
at fan.sys.FanClassLoader.findClass(FanClassLoader.java:92)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at fan.mig.Main.main(Main.fan:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fan.sys.Method.invoke(Method.java:536)
at fan.sys.Method$MethodFunc.callList(Method.java:182)
at fan.sys.Method.callList(Method.java:147)
at fanx.tools.Fan.callMain(Fan.java:135)
at fanx.tools.Fan.executeType(Fan.java:102)
at fanx.tools.Fan.execute(Fan.java:38)
at fanx.tools.Fan.run(Fan.java:236)
at fanx.tools.Fan.main(Fan.java:274)

brianSat 30 Oct 2010

However, the more worrying thing is that you have code path to cause that I don't have in my test suite.

If that patch doesn't work can you email me your test case so we can work on the issue? Thanks.

DanielFathSat 30 Oct 2010

Actually that's not the test case causing problems, it's simple class instantation. I still haven't made test for the components because I'm a bit busy atm (also I have a bad habit of making tests post-festum) with exams. Maybe this can be of any help (note: you require one of MigLayout jars in lib/java/ext).

Seems the generated .class file is inconsistent. Any luck making tests for this brian?

brianThu 4 Nov 2010

No doubt there is a bug there, but I really need some simple test case to really dig into it.

DanielFathThu 4 Nov 2010

How simple is simple? I was able to replicate the bug by copying the interface and I have a pretty good idea where the bug lies, so I might reduce it down a bit.

EDIT: Scratch that, from what I can tell I'll might need a lot of time to diagnose the first fault, but so far the only thing causing problems is abstract float getPreferredHeight() which I overriden with Float getPreferredHeight().

EDIT2: How fine grained you want this Mixin override tests (One big interface that tests all or a huge ass number of small test that test each java construct)?

DanielFathThu 4 Nov 2010

Brian I finished the work on the test case and lucky as I was I detected several other faults. It seems most basic type ( byte, char, float, short) cause my test case to break.

Do you want it (it is java interface jar + test classes)? And if so how do you want it distributed?

brianThu 4 Nov 2010

If you have a stand alone test case, please just email me directly

DanielFathThu 4 Nov 2010

EDIT: Nvm found it.

DanielFathThu 4 Nov 2010

BTW brian, is there a way to make Map<ContainerWrapper,CC> (in Java) in Fantom?

brianFri 5 Nov 2010

BTW brian, is there a way to make Map<ContainerWrapper,CC> (in Java) in Fantom?

Not sure I fully follow that question, but since generics are erased it would just be java.util.Map in Fantom side. Fantom doesn't do anything with Java's generic system.

DanielFathFri 5 Nov 2010

Ah, ok I thought it had some special syntax for generics.

brianFri 5 Nov 2010

Renamed from Possible problems with FFI to Java FFI mixin routers with primitives