#1534 Build problem when using java native code and PathEnv

tonsky Tue 17 May 2011

When I use PathEnv for building pod with native sources (java), I encounter some problems:

>>> export FAN_ENV=util::PathEnv
>>> export FAN_ENV_PATH=/Users/prokopov/Dropbox/ws/xored/env/
>>> fan build.fan
compile [spectre]
  Compile [spectre]
    FindSourceFiles [49 files]
    WritePod [file:/Users/prokopov/Dropbox/ws/xored/env/lib/fan/spectre.pod]
  javaNative [spectre]
    Exec [/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/java -cp /Users/prokopov/java/fantom-1.0.58/lib/java/sys.jar -Dfan.home=/Users/prokopov/Dropbox/ws/xored/env fanx.tools.Jstub -d /Users/prokopov/Dropbox/ws/xored/spectre/src/temp-java spectre]
    Java Stub [spectre]
java.util.zip.ZipException: error in opening zip file
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(ZipFile.java:127)
	at java.util.zip.ZipFile.<init>(ZipFile.java:144)
	at fanx.fcode.FStore.makeZip(FStore.java:36)
	at fan.sys.Pod.readFPod(Pod.java:148)
	at fan.sys.Pod.doFind(Pod.java:65)
	at fan.sys.Sys.initSysPod(Sys.java:340)
	at fan.sys.Sys.<clinit>(Sys.java:47)
	at fan.sys.Pod.readFPod(Pod.java:140)
	at fan.sys.Pod.doFind(Pod.java:65)
	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)
ERROR: cannot init Sys.sysPod
fan.sys.UnknownPodErr: sys
	at fan.sys.UnknownPodErr.<init>(UnknownPodErr.java:39)
	at fan.sys.UnknownPodErr.make(UnknownPodErr.java:25)
	at fan.sys.Pod.doFind(Pod.java:102)
	at fan.sys.Sys.initSysPod(Sys.java:340)
	at fan.sys.Sys.<clinit>(Sys.java:47)
	at fan.sys.Pod.readFPod(Pod.java:140)
	at fan.sys.Pod.doFind(Pod.java:65)
	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)
Exception in thread "main" java.lang.ExceptionInInitializerError
	at fan.sys.Pod.readFPod(Pod.java:140)
	at fan.sys.Pod.doFind(Pod.java:65)
	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)
Caused by: java.lang.RuntimeException: Cannot boot fan: fan.sys.UnknownPodErr: sys
	at fan.sys.Sys.initFail(Sys.java:521)
	at fan.sys.Sys.initSysPod(Sys.java:344)
	at fan.sys.Sys.<clinit>(Sys.java:47)
	... 6 more
ERR: Exec failed [/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/java -cp /Users/prokopov/java/fantom-1.0.58/lib/java/sys.jar -Dfan.home=/Users/prokopov/Dropbox/ws/xored/env fanx.tools.Jstub -d /Users/prokopov/Dropbox/ws/xored/spectre/src/temp-java spectre]

As you can see, BuildScript tries to pass my $FAN_ENV_PATH as fan.home to fanx.tools.Jstub, but $FAN_ENV_PATH is not a full-blown fantom installation, it’s a folder where some additional libs (local env) are stored. That’s why it cannot find sys.pod here.

So, I’ve copied fantom-1.0.58/lib/** and fantom-1.0.58/etc/** to get it run.

>>> cp -R ~/java/fantom-1.0.58/lib/** $FAN_ENV_PATH/lib
>>> mkdir $FAN_ENV_PATH/etc
>>> cp -R ~/java/fantom-1.0.58/etc/** $FAN_ENV_PATH/etc
>>> fan build.fan
compile [spectre]
  Compile [spectre]
    FindSourceFiles [49 files]
    WritePod [file:/Users/prokopov/Dropbox/ws/xored/env/lib/fan/spectre.pod]
  javaNative [spectre]
    Exec [/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/java -cp /Users/prokopov/java/fantom-1.0.58/lib/java/sys.jar -Dfan.home=/Users/prokopov/Dropbox/ws/xored/env fanx.tools.Jstub -d /Users/prokopov/Dropbox/ws/xored/spectre/src/temp-java spectre]
    Java Stub [spectre]
    CompileJava
Note: /Users/prokopov/Dropbox/ws/xored/spectre/src/java/asyncio/SelActorPeer.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
    Exec [/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/jar -xf /Users/prokopov/Dropbox/ws/xored/spectre/src/temp-java/spectre.jar]
    Delete [file:/Users/prokopov/Dropbox/ws/xored/spectre/src/temp-java/spectre.jar]
    Delete [file:/Users/prokopov/Dropbox/ws/xored/spectre/src/temp-java/meta-inf/]
    Exec [/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/jar -fu /Users/prokopov/java/fantom-1.0.58/lib/fan/spectre.pod -C /Users/prokopov/Dropbox/ws/xored/spectre/src/temp-java .]
java.io.FileNotFoundException: /Users/prokopov/java/fantom-1.0.58/lib/fan/spectre.pod (No such file or directory)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(FileInputStream.java:106)
	at sun.tools.jar.Main.run(Main.java:192)
	at sun.tools.jar.Main.main(Main.java:1149)
ERR: Exec failed [/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/jar -fu /Users/prokopov/java/fantom-1.0.58/lib/fan/spectre.pod -C /Users/prokopov/Dropbox/ws/xored/spectre/src/temp-java .]
BUILD FAILED [6881ms]!

As you can see, it now tries to update pod file after java compilation but uses wrong location based on $FAN_HOME.

What was expected?

  1. Using util::PathEnv, pods should be looked up first in $FAN_ENV_PATH, then in $FAN_HOME even when compiling java sources.
  2. Output pod file should be correctly written and updated at first $FAN_ENV_PATH path (as specified in Fantom docs).

Does it make any sense or am I doing something wrong here?

tonsky Tue 17 May 2011

BTW, you can add

div.fandoc pre { white-space: pre-wrap; }

to fix long code lines overflow.

andy Tue 17 May 2011

Thanks @tonksy - they will actually get an overflow:auto when this site gets the new version of sidewalk (so we don't get unintentional line-breaks).

brian Tue 17 May 2011

Promoted to ticket #1534 and assigned to brian

I will take a look.

If you have patch you want to email me, that would be great.

tonsky Wed 18 May 2011

That works for me (I’ve even tried it with two different paths in PathEnv simultaneously):

diff -r da7d9660e082 src/build/fan/BuildPod.fan
--- a/src/build/fan/BuildPod.fan	Tue May 17 08:33:39 2011 -0400
+++ b/src/build/fan/BuildPod.fan	Wed May 18 17:45:02 2011 +0700
@@ -249,7 +249,7 @@
     jarExe   := jdk.jarExe
     sysJar   := devHomeDir + `lib/java/sys.jar`
     libFan   := devHomeDir + `lib/fan/`
-    curPod   := devHomeDir + `lib/fan/${podName}.pod`
+    curPod   := outPodDir.toFile + `${podName}.pod`
     depends  := (Depend[])this.depends.map |s->Depend| { Depend(s) }

     // stub the pods fan classes into Java classfiles
@@ -257,7 +257,7 @@
     jtemp.create
     Exec(this, [javaExe,
                 "-cp", sysJar.osPath,
-                "-Dfan.home=$Env.cur.workDir.osPath",
+                "-Dfan.home=$devHomeDir",
                 "fanx.tools.Jstub",
                 "-d", jtemp.osPath,
                 podName]).run

brian Thu 19 May 2011

Ticket resolved in 1.0.59

I pushed your patch - http://hg.fantom.org/fan-1.0/rev/43933779f877

thanks!

Login or Signup to reply.