jetma / jav8

Automatically exported from code.google.com/p/jav8
0 stars 0 forks source link

Supporting Mac JKD6 jnilib system library file extension #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Build jav8 trunk version as documented.
2. Run any stand-alone test program that loads the "jav8" ScriptEngine on JDK6. 
Here is a test program:

import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;

public class Test {

    public static void main(String [] args) {

        ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
        for (ScriptEngineFactory scriptEngineFactory : scriptEngineManager.getEngineFactories()) {
            System.out.println(">>>>> "+scriptEngineFactory.getEngineName());
        }
        ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("jav8");
        System.out.println(">>>>>>>>>>> engine: "+(scriptEngine != null));
    }
}

What is the expected output? What do you see instead?

One would expect the following output:

>>>>> AppleScriptEngine
>>>>> Google V8
>>>>> Mozilla Rhino
>>>>>>>>>>> engine: true

Instead, the following error is returned:

Exception in thread "main" java.lang.UnsatisfiedLinkError: missing JNI library 
- libjav8.jnilib
    at lu.flier.script.V8ScriptEngineFactory.<clinit>(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at sun.misc.Service$LazyIterator.next(Service.java:271)
    at javax.script.ScriptEngineManager.initEngines(ScriptEngineManager.java:109)
    at javax.script.ScriptEngineManager.access$000(ScriptEngineManager.java:37)
    at javax.script.ScriptEngineManager$1.run(ScriptEngineManager.java:80)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.script.ScriptEngineManager.init(ScriptEngineManager.java:78)
    at javax.script.ScriptEngineManager.<init>(ScriptEngineManager.java:51)
    at Test.main(Test.java:17)

The reason is that JDK6 on the mac returns this system library file extension: 
".jnilib". JDK7 on the mac returns: ".dylib". The current version of build.xml 
supports JDK7 by including libjav8.dylib in the jar artifact. JDK6 is not 
supported.

What version of the product are you using? On what operating system?

Trunk version, (69), of jav8.

JVM:
java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)

System: Darwin 501158-mac.local 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 
00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64

Please provide any additional information below.

Attached is a patch to build.xml that copies libjav8.dylib to libjav8.jnilib on 
the mac. This supports JDK6.

Original issue reported on code.google.com by rwat...@marketlive.com on 13 Mar 2013 at 5:44

Attachments:

GoogleCodeExporter commented 9 years ago
Great, please verify the patch with SVN trunk code after r70, thanks for your 
contribution

Original comment by flier...@gmail.com on 14 Mar 2013 at 4:15