#1930 Building a Pod containing Java & Fantom code

geo Wed 27 Jun 2012

I'd like to know how to build a Pod that contains Fantom and Java code, where the Fantom Code uses using [java] the Java code.

When I use a standard build script I get the following exception:

ERR: Internal compiler error sys::IOErr: java.io.FileNotFoundException: D:\fantom\workspaces\first\FantomFX\bin (Access is denied) java.io.FileInputStream.open (FileInputStream.java) java.io.FileInputStream.<init> (FileInputStream.java:138) fan.sys.LocalFile.in (LocalFile.java:419) fan.sys.File.in (File.java:360) compilerJava::JavaDasmLoader.load (JavaDasmLoader.fan:40) compilerJava::JavaType.load (JavaType.fan:169) compilerJava::JavaType.slots (JavaType.fan:79) compilerJava::JavaType.slot (JavaType.fan:83) compiler::CallResolver.findOn (CallResolver.fan:218) compiler::CallResolver.find (CallResolver.fan:163) compiler::CallResolver.resolve (CallResolver.fan:62) compiler::ResolveExpr.resolveCall (ResolveExpr.fan:490) compiler::ResolveExpr.resolveExpr (ResolveExpr.fan:164) compiler::ResolveExpr.visitExpr (ResolveExpr.fan:123) compiler::Expr.walk (Expr.fan:263) compiler::Stmt.walkExpr (Stmt.fan:61) compiler::ExprStmt.walkChildren (Stmt.fan:117) compiler::Stmt.walk (Stmt.fan:48) compiler::Block.walk (Block.fan:89) fan.sys.List.each (List.java:534)

The lack of access to the bin directory would seem to suggest that the Java code should be compiled first, so I overrode the compile() and swapped the order that compileFan and compileJava methods are called in so that the Java code is compiled first.

But this gives the exception:

Exception in thread "main" sys::UnknownPodErr: FantomFX at fan.sys.UnknownPodErr.make(UnknownPodErr.java:25) at fan.sys.UnknownPodErr.make(UnknownPodErr.java:22) at fan.sys.Pod.readFPod(Pod.java:161) at fan.sys.Pod.doFind(Pod.java:67) at fan.sys.Pod.find(Pod.java:46) at fanx.tools.Jstub.stub(Jstub.java:40) at fanx.tools.Jstub.run(Jstub.java:160) at fanx.tools.Jstub.main(Jstub.java:186)

And, an unknown Pod would seem to imply that the Pod needs to be present before the Java code can be called.

So, do we have a chicken and egg situation?

Just how do you compile a Pod that has Java code and Fantom code, where the Fantom code uses the Java code ?

brian Wed 27 Jun 2012

Java FFI does not current support accessing Java code within your own pod. You can compile native peer Java code in fan.<your pod> package. But Java FFI requires that the Java code be cleanly packaged up into its own pod with a dependency.

Login or Signup to reply.