wmingjian / jav8 Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/jav8
Automatically exported from code.google.com/p/jav8
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 [email protected]
on 13 Mar 2013 at 5:44
Attachments:
Hi,
I've installed the jav8 as a maven dependency and tried the exemple.
I get the following error. I suppose that I do not have the gooed V8 version,
but what is the supported version.
Best.
Exception in thread "main" java.lang.UnsupportedClassVersionError:
lu/flier/script/V8ScriptEngineFactory : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
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 jab8Test.Main.main(Main.java:9)
Original issue reported on code.google.com by [email protected]
on 4 Aug 2013 at 10:07
I try to build jav8 pour windows x64.
I get jav8.dll : fatal error LNK1120: 94 unresolved externals
I'm not used to C, so I imagine this must come from a difference of version of
v8 lib.
Which version of v8 have you used to successfully compile jav8 ?
Thanks
P.S. some more details from my error :
1>jav8.obj : error LNK2001: unresolved external symbol "public: bool __cdecl
v8::TryCatch::HasCaught(void)const " (?HasCaught@TryCatch@v8@@QEBA_NXZ)
1>jav8.obj : error LNK2001: unresolved external symbol "public: __cdecl
v8::TryCatch::~TryCatch(void)" (??1TryCatch@v8@@QEAA@XZ)
etc...
Original issue reported on code.google.com by [email protected]
on 15 Jul 2012 at 8:52
What steps will reproduce the problem?
1. Run "new V8ScriptEngineFactory().getEngineVersion()"
What is the expected output? What do you see instead?
I expect 3.19.18 (according to
https://code.google.com/p/v8/source/browse/trunk/src/version.cc#35). Instead I
see 1.8.5.
What version of the product are you using? On what operating system?
This one:
https://code.google.com/p/jav8/downloads/detail?name=jav8-jsr223-linux-amd64-0.6
.jar&can=2&q=
Original issue reported on code.google.com by [email protected]
on 24 Jun 2013 at 4:54
Hi i'am trying to use jav8 on android. After a few issues i was able to get it
running on android.
Now I have one major issue. If I expose some java code to javascript, after
many call to a java method from JavaScript (max is arround 500 calls) my app
crash with a "ReferenceTable overflow"
I found that some ref wasn't deleted in Wrapper.cpp CJavaFunction::Caller (for
exemple params var, and arguments passed to SetObjectArrayElement). After
fixing it, I was able to make more call to java method, but I still get a
ReferenceTable overflow.
I think there still a "leak" in Utils.cpp Cache::GetMember() when calling
GetObjectClass()
members_t::iterator iter = CacheMembers(env->GetObjectClass(obj));
If i replace this with :
jclass foo = env->GetObjectClass(obj);
members_t::iterator iter = CacheMembers(foo);
env->DeleteLocalRef(foo);
I no longer have a ReferenceTable overflow but my code crash randomly. Any idea
on how to fix this?
The easiest way to reproduce this bug is :
1) Create a java class with a method and expose it to javascript
2) In your JavaScript code :
for (var i = 0; i < 1024; i++) {
//Call java method here
}
3) Wait for crash
I'am using jav8-03.
Thanks.
Original issue reported on code.google.com by [email protected]
on 30 Nov 2011 at 7:03
What steps will reproduce the problem?
1. Copied over the example code from the projects' page
2. Created a simple App, included the jar dependency
3. Built and executed the app with: java -cp
"target/classes:target/classes/jav8-jsr223-Darwin-amd64-0.4.jar"
com.mycompany.jav8test.App
What is the expected output? What do you see instead?
Here is the full error log:
ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory:
Provider lu.flier.script.V8ScriptEngineFactory could not be instantiated:
java.lang.UnsatisfiedLinkError: /tmp/libjav83438421088985770011.so:
/tmp/libjav83438421088985770011.so: invalid ELF header (Possible cause:
endianness mismatch)
Exception in thread "main" java.lang.NullPointerException
at com.mycompany.jav8test.App.main(App.java:18)
What version of the product are you using? On what operating system?
OS: Ubuntu 12.04, 64 bit
Java: "1.6.0_27"
Original issue reported on code.google.com by [email protected]
on 7 Apr 2013 at 8:08
What steps will reproduce the problem?
1. Build v8 for win32
1. Try to build the current source code, call "ant" on the jav8 folder
---> change build.xml to point to visual studio v8 output directory:
<property name="libv8.path" value="${env.V8_HOME}/build/Release/lib"/>
What is the expected output? What do you see instead?
Expected a Succesfull build.
But got an Link error, because of missing return values in the jav8.cpp.
What version of the product are you using? On what operating system?
Subversion Revision 68
Operationsystem Win7x64 but build for Win32.
JNI Header of jdk1.6.0_29_x32.
Please provide any additional information below.
This is the ant output:
Buildfile: c:\data\coding\Own\jav8\build.xml
prepare:
compile:
jni:
[echo] Generating JNI header ...
[echo] Building JNI library with release mode ...
[cc] Starting dependency analysis for 3 files.
[cc] 3 files are up to date.
[cc] 0 files to be recompiled from dependency analysis.
[cc] 0 total files to be compiled.
[cc] Starting link
[cc] LINK : warning LNK4224: /INCREMENTAL:YES is no longer supported; ignored
[cc] jav8.obj : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
[cc] LINK : warning LNK4224: /INCREMENTAL:YES is no longer supported; ignored
[cc] LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
[cc] Creating library jav8.lib and object jav8.exp
[cc] Generating code
[cc] c:\data\coding\own\jav8\jni\jav8.cpp(1041) : error C4716: 'Java_lu_flier_script_V8Array_internalToBooleanArray' : must return a value
[cc] c:\data\coding\own\jav8\jni\jav8.cpp(1023) : error C4716: 'Java_lu_flier_script_V8Array_internalToFloatArray' : must return a value
[cc] c:\data\coding\own\jav8\jni\jav8.cpp(1003) : error C4716: 'Java_lu_flier_script_V8Array_internalToDoubleArray' : must return a value
[cc] c:\data\coding\own\jav8\jni\jav8.cpp(983) : error C4716: 'Java_lu_flier_script_V8Array_internalToShortArray' : must return a value
[cc] c:\data\coding\own\jav8\jni\jav8.cpp(963) : error C4716: 'Java_lu_flier_script_V8Array_internalToLongArray' : must return a value
[cc] c:\data\coding\own\jav8\jni\jav8.cpp(943) : error C4716: 'Java_lu_flier_script_V8Array_internalToIntArray' : must return a value
[cc] c:\data\coding\own\jav8\jni\jav8.cpp(1059) : error C4716: 'Java_lu_flier_script_V8Array_internalToStringArray' : must return a value
[cc] c:\data\coding\own\jav8\jni\jav8.cpp(1076) : error C4716: 'Java_lu_flier_script_V8Array_internalToDateArray' : must return a value
[cc] c:\data\coding\own\jav8\jni\jav8.cpp(546) : error C4716: 'Java_lu_flier_script_V8Array_internalSet' : must return a value
[cc] LINK : fatal error LNK1257: code generation failed
Original issue reported on code.google.com by [email protected]
on 11 Feb 2013 at 10:27
I downloaded and built the latest v8 on Fedora 20, using "make native". First,
the jav8 build failed because it couldn't find the "x64.release" directory... I
linked it to the "native" directory, and it seemed happy. (I mention this in
case you think this is really the cause of my problem.)
When building, a long stream of somewhat similar errors appears. Here is the
just the first few:
[echo] linking V8 static library v8_base.x64,v8_snapshot at /home/cmjanicki/tmp/v8/out/x64.release/obj.target/tools/gyp/
[cc] 3 total files to be compiled.
[cc] In file included from /home/cmjanicki/jav8/jni/jav8.cpp:7:0:
[cc] /home/cmjanicki/tmp/v8/include/v8.h: In constructor ‘jni::V8Env::V8Env(JNIEnv*)’:
[cc] /home/cmjanicki/tmp/v8/include/v8.h:838:13: error: ‘v8::HandleScope::HandleScope()’ is private
[cc] V8_INLINE HandleScope() {}
[cc] ^
[cc] In file included from /home/cmjanicki/jav8/jni/jav8.cpp:16:0:
[cc] /home/cmjanicki/jav8/jni/Utils.h:273:31: error: within this context
[cc] V8Env(JNIEnv *env) : Env(env)
[cc] ^
[cc] /home/cmjanicki/jav8/jni/Utils.h: In member function ‘v8::Local<T> jni::V8Env::Close(v8::Handle<T>)’:
[cc] /home/cmjanicki/jav8/jni/Utils.h:291:84: error: ‘class v8::HandleScope’ has no member named ‘Close’
[cc] template <class T> v8::Local<T> Close(v8::Handle<T> value) { return handle_scope.Close(value); }
Original issue reported on code.google.com by [email protected]
on 14 Jan 2014 at 7:24
What steps will reproduce the problem?
1. Download jav8-jsr223-win-amd64-0.6.jar
2. Cannot run it with java 1.6
3. Windows version is compiled with Java 1.7, but the Linux version is compiled
with 1.6.
I would ask this in newsgroup, but I didn't find it, so I wonder if I can file
a issue on it. Thanks.
Original issue reported on code.google.com by [email protected]
on 27 Jun 2013 at 6:54
What steps will reproduce the problem?
1. Compile svn trunk v8 with make android_arm.release i18nsupport=off
component=static_library -j8
2. Copy the libraries to jni/armeabi
3. Compile jav8
4. Add as apklib dependency to an android app
5. Try to get ScriptEngine:
ScriptEngineManager factory = new ScriptEngineManager();
// workaround for META-INF not included in APK, added convenience method
factory.addSpi("lu.flier.script.V8ScriptEngineFactory");
js = factory.getEngineByName("jav8");
What is the expected output? What do you see instead?
Expected to get an instance of jav8 ScriptEngine but app crashes as shown below.
What version of the product are you using? On what operating system?
Android 4.4.2, latest checkouts of both jav8 and v8
Please provide any additional information below.
I/System.out(13150): Trying to load resource:
META-INF/services/javax.script.ScriptEngineFactory
I/System.out(13150): Iterating thru resources
I/System.out(13150): Adding SPI: lu.flier.script.V8ScriptEngineFactory
D/dalvikvm(13150): Trying to load lib /data/app-lib/test-2/libjav8.so 0x41e3f800
D/dalvikvm(13150): Added shared lib /data/app-lib/test-2/libjav8.so 0x41e3f800
F/libc (13150): Fatal signal 11 (SIGSEGV) at 0x00001b88 (code=1), thread
13150 (.test)
I/DEBUG ( 351): *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
***
I/DEBUG ( 351): Build fingerprint:
'lge/w5_global_com/w5:4.4.2/KOT49I.A1394126896/1394126896:user/release-keys'
I/DEBUG ( 351): Revision: '6'
I/DEBUG ( 351): pid: 13150, tid: 13150, name: .test >>> test <<<
I/DEBUG ( 351): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr
00001b88
I/DEBUG ( 351): r0 00000000 r1 00000000 r2 00001b88 r3 00001b80
I/DEBUG ( 351): r4 00000000 r5 bec24350 r6 00000003 r7 56900019
I/DEBUG ( 351): r8 bec243b0 r9 5772ab84 sl 416dfa80 fp bec243c4
I/DEBUG ( 351): ip 60fa5f10 sp bec24338 lr 60b659b4 pc 60b659c4 cpsr
600b0010
I/DEBUG ( 351): d0 0000000000000000 d1 0000000000000000
I/DEBUG ( 351): d2 0000000000000000 d3 0000000000000000
I/DEBUG ( 351): d4 0000000500000000 d5 ffffffff00000000
I/DEBUG ( 351): d6 ffffffff12000008 d7 4000000000000003
I/DEBUG ( 351): d8 0000000000000000 d9 0000000000000000
I/DEBUG ( 351): d10 0000000000000000 d11 0000000000000000
I/DEBUG ( 351): d12 0000000000000000 d13 0000000000000000
I/DEBUG ( 351): d14 0000000000000000 d15 0000000000000000
I/DEBUG ( 351): d16 7265696c662f756c d17 2f7470697263732f
I/DEBUG ( 351): d18 5773119857731160 d19 57731208577311d0
I/DEBUG ( 351): d20 5773127857731240 d21 57ab6700577312b0
I/DEBUG ( 351): d22 57ab677057ab6738 d23 57ab67e057ab67a8
I/DEBUG ( 351): d24 3fc74721cad6b0ed d25 3fc2f112df3e5244
I/DEBUG ( 351): d26 40026bb1bbb55516 d27 4000000000000000
I/DEBUG ( 351): d28 40008df2d49d41f1 d29 3fb0f4a31edab38b
I/DEBUG ( 351): d30 3ff0000000000000 d31 3f4de16b9c24a98f
I/DEBUG ( 351): scr 80000010
I/DEBUG ( 351):
I/DEBUG ( 351): backtrace:
I/DEBUG ( 351): #00 pc 001d09c4 /data/app-lib/test-2/libjav8.so
(v8::HandleScope::Initialize(v8::Isolate*)+32)
I/DEBUG ( 351): #01 pc 001d0a24 /data/app-lib/test-2/libjav8.so
(v8::HandleScope::HandleScope(v8::Isolate*)+8)
I/DEBUG ( 351): #02 pc 001c278d /data/app-lib/test-2/libjav8.so
(Java_lu_flier_script_V8Context_internalCreate+20)
I/DEBUG ( 351):
Original issue reported on code.google.com by [email protected]
on 22 May 2014 at 8:38
see code below:
engine.eval("var obj = {name : 'tom'}");
engine.eval("obj.test = function() { out.println(this.name)}");
engine.eval("obj.test()");
((Invocable)engine).invokeMethod(engine.eval("obj"), "test");
i have resolve this problem as below:
src/lu/flier/script/V8Function.java : LN 24 append new function
public Object invoke(long thizObj, Object... args) {
Object result = internalInvoke(this.obj, thizObj, args);
return result == null ? null : this.ctxt.bind(result);
}
/src/lu/flier/script/V8ScriptEngine.java : LN 171 replace with :
V8Function fun = ((V8Function) ((V8Object) thiz).get(name));
return fun.invoke(((V8Object)thiz).obj, args);
now it's work fine, i am not sure this is the best way, hope your official new
version.
Original issue reported on code.google.com by [email protected]
on 17 Oct 2013 at 10:20
Hi,
I have a problem while using the jav8 lib in a multithreaded environment. I describe the problem below.
Best regards and thanks in advance for your help,
Marco Vaz
What steps will reproduce the problem?
1. create a pool of threads
2. create a script engine with the following instructions (from the main thread
or a thread from the pool):
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("jav8");
3. from a thread from the pool call engine.eval("javascript:file.js");
What is the expected output? What do you see instead?
I expect that the javascript file is correctly evaluated by V8 engine. It is
produced a fatal error. I attach the error trace.
What version of the product are you using? On what operating system?
I tested with the version 0.3 that I downloaded from the "Downloads" section
and with a version compiled by myself. I tested it in a linux machine (RHEL
6.3).
Original issue reported on code.google.com by [email protected]
on 13 Apr 2013 at 7:27
Attachments:
What steps will reproduce the problem?
1. Built v8 as mentioned in the wiki. Ran "d8" to verify.
2. Tried to use the pre-packaged JAR (jav8-jsr223-linux-amd64-0.6.jar) but
encountering "ELF file OS ABI invalid"
3. Tried to build Jav8 code as mentioned in the wiki. Getting a lot of errors,
it might be possible that the code has not been updated with the latest V8.
What is the expected output? What do you see instead?
Reported above.
What version of the product are you using? On what operating system?
jav8 on Linux RHEL 5.5
# uname -r
2.6.18-194.el5
# uname -i
x86_64
Please provide any additional information below.
Need urgent help. If there is a new source, please forward the same. I observed
that others have been able to use the pre-packaged JAR as-it-is. any pointers
will be helpful.
Original issue reported on code.google.com by [email protected]
on 10 Oct 2013 at 11:27
What steps will reproduce the problem?
1. Create instance of JS engine using prebuilt JAR for windows XP
2.
3.
What is the expected output? What do you see instead?
Expected output is a simple script execution, instead I get an
EXCEPTION_ACCESS_VIOLATION
What version of the product are you using? On what operating system?
0.3 on Win x86
Please provide any additional information below.
frame: C [jav8.dll+0x5ed8]
Original issue reported on code.google.com by [email protected]
on 8 Dec 2011 at 3:21
What steps will reproduce the problem?
1. Get a V8Array object from the ScriptEngine
2. Call the toIntArray(int[], int) function with an existing array containing
data other than all zeros
What is the expected output?
The java array passed in should contain a complete copy of the V8Array contents
What do you see instead?
Any index in the V8Array which is set to 0 does not get set in the existing
array, therefore the arrays don't match after the operation.
What version of the product are you using? On what operating system?
The June 2013 version posted in the downloads section
Please provide any additional information below.
All of the V8Array.to...Array([], length) functions exhibit this problem. The
CPP code in jav8.cpp has the following condition which is causing the issue:
if (value != 0) {
data[i] = value;
}
This is fine if the Java array being used is initialized to all zeros, but
unexpected otherwise.
The workaround for now is to use Arrays.fill(myarray, 0) just before calling
v8array.toIntArray(myarray, myarray.length).
Original issue reported on code.google.com by [email protected]
on 25 Oct 2014 at 3:40
What steps will reproduce the problem?
Simplified Test case:
ScriptEngine eng = new ScriptEngineManager().getEngineByName("jav8");
MyObject myObj = new MyObject(); // Some object with a function, f(), to expose
eng.put("myObj", myObj); // Expose myObj to javascript.
eng.eval("myObj.f()"); // This line works as expected.
eng.eval("var f = myObj.f;"); // This line runs silently.
eng.eval("f()"); // This line errors.
What is the expected output? What do you see instead?
Expected the same result as if eng.eval("myObj.f()"); was run.
Instead get the stack trace:
Exception in thread "main" javax.script.ScriptException:
javax.script.ScriptException: java.lang.NullPointerException
at lu.flier.script.V8ScriptEngine.eval(Unknown Source)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at page.freddie.melonheads.Test.main(Test.java:14)
Caused by: javax.script.ScriptException: java.lang.NullPointerException
at lu.flier.script.V8CompiledScript.eval(Unknown Source)
... 3 more
Caused by: java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at lu.flier.script.V8CompiledScript.internalExecute(Native Method)
... 4 more
What version of the product are you using? On what operating system?
Using jav8-0.3 on Ubuntu 12.04 64bit compiled from source for amd64.
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 22 Aug 2012 at 8:48
Apache JMeter does not run with jav8 currently.
There are several issues preventing jav8 working with JMeter
1. jav8 Bindings does not follow JSR 223 spec
2. jav8 does not have multi-threaded support
The use case is that we often want to use client side javascript code for load
testing. Since Rhino is slow, limited in script size (no more than 64k
functions or 64k per function) and does not actually run any browser using v8
would be ideal to solve these problems.
Installing jav8 to JMeter is simple. Just copy the jar into the lib directory
and create a JSR223 Element with a jav8 type. Unfortunately things go downhill
from there.
Bindings
--------
The JSR223 Bindings passed by JMeter's JSR223TestElement.java are not passed to
the V8 environment. This is because v8 assumes that calls are like
...
Bindings g = this.eng.getBindings(ScriptContext.ENGINE_SCOPE);
g.put("array", array2);
...
whereas JMeter JSR223TestElement.java sets up bindings with
...
if (bindings == null) {
bindings = scriptEngine.createBindings();
}
populateBindings(bindings);
...
protected void populateBindings(Bindings bindings) {
...
final Logger logger = LoggingManager.getLoggerForShortName(getClass().getName());
bindings.put("log", logger);
...
then call the bindings with
...
return compiledScript.eval(bindings);
...
A hack/patch is to update V8CompiledScript.java eval method to have
...
@Override
public Object eval(ScriptContext context) throws ScriptException
{
try {
// Messy hack to import in from context
for (Map.Entry<String,Object> entry : context.getBindings(ScriptContext.ENGINE_SCOPE).entrySet())
{
this.engine.put(entry.getKey(),entry.getValue());
}
return this.engine.getV8Context().bind(this.internalExecute(this.data, context));
} catch (Exception e) {
throw new ScriptException(e);
}
}
...
However there is probably a cleaner solution.
Multithreading
--------------
The two cases that need to be supported are compiled scripts and eval'ed
javascript. JMeter blows up immediately using compiled scripts and runs with
memory leaks and eventual blow ups when running eval'ed code.
* Need to use Locker
Unfortunately I'm not a C++ person so I haven't been able to get this to work.
Original issue reported on code.google.com by [email protected]
on 20 Jun 2013 at 3:54
TLS is not supported by NDK. The following code in Utils.h freezes application:
static __thread caches_t *s_caches;
I removed __thread and it started working, but I can not assess the impact of
this hack.
Original issue reported on code.google.com by novikov
on 20 Mar 2012 at 3:10
What steps will reproduce the problem?
1. Download jar jav8-jsr223-win-x86-0.3.jar
2. Download unit test from
http://code.google.com/p/jav8/source/browse/trunk/test/lu/flier/script/V8ScriptE
ngineTest.java revision 66
3. Create a java project and add unit jar to class path.
4. Create unit tests
What is the expected output? What do you see instead?
The unit test should compile but getting several errors. FOr example: Undefined
functions: eng.createFunction & voidFunc.invokeVoid(); & arr.setElements
What version of the product are you using? On what operating system?
Win xp
Original issue reported on code.google.com by [email protected]
on 9 Dec 2012 at 6:44
What steps will reproduce the problem?
I downloaded and built V8 engine (with -fPIC -O1 -fno-strict-aliasing as this
was proven to be useful when I did other JNI projects)
I built jav8 with that engine I had to modify the build.xml slightly because of
filename mismatches
What is the expected output? What do you see instead?
I expected the tests to run and succeed.
I got JVM crashes sometimes 4-5 stack deep in the native V8 code (segfaults
mostly). If i recompiled with different compilers (clang, g++) or with
different flags it crashed at different places. I can show you stacktraces and
crashreports but I guess something just changes inside V8 and jav8 is compiling
against an older one.
What version of the product are you using? On what operating system?
I used the trunk of jav8 and V8. I built it on mac (maverick) and ubuntu. Both
are x64 bit systems.
Please provide any additional information below.
Can you please tell me what is the V8 version compatible with the current jav8
code?
I had to recompile jav8 because the prebuilt package is not handling
typedarrays in javascript. I would be happy to provide prebuilt packages to Mac
and Linux if I will be able to figure it out.
Original issue reported on code.google.com by [email protected]
on 15 Jun 2014 at 4:09
Unhandled exception
Type=Segmentation error vmState=0x00000000
J9Generic_Signal_Number=00000004 ExceptionCode=c0000005
ExceptionAddress=5C5D922A ContextFlags=0001003f
Handler1=01C5A0C0 Handler2=0033C000 InaccessibleAddress=00000013
EDI=54F1A028 ESI=050CE021 EAX=00000001 EBX=54E467CD
ECX=54E73DB0 EDX=00000000
EIP=5C5D922A ESP=5FEDFC08 EBP=5FEDFC44 EFLAGS=00010202
GS=002B FS=0053 ES=002B DS=002B
Module=c:\yourlibpath\jav8.dll
Module_base_address=5C5B0000 Offset_in_DLL=0002922a
Target=2_40_20110203_074623 (Windows 7 6.1 build 7600)
CPU=x86 (4 logical CPUs) (0xf7d9d000 RAM)
----------- Stack Backtrace -----------
_JNI_OnUnload@8+0xd90a (0x5C5D922A [jav8+0x2922a])
_JNI_OnUnload@8+0x17c44 (0x5C5E3564 [jav8+0x33564])
_JNI_OnUnload@8+0x16f3f (0x5C5E285F [jav8+0x3285f])
_JNI_OnUnload@8+0x9d0e6 (0x5C668A06 [jav8+0xb8a06])
_JNI_OnUnload@8+0x12670 (0x5C5DDF90 [jav8+0x2df90])
_Java_lu_flier_script_V8Function_internalInvoke@28+0x16796 (0x5C5C9036
[jav8+0x19036])
setTagSumCheck+0x10 (j9memtag.c:60, 0x00334100 [J9PRT24+0x4100])
wrapBlockAndSetTags+0x65 (j9memtag.c:90, 0x00334175 [J9PRT24+0x4175])
j9mem_allocate_memory+0x87 (j9memtag.c:165, 0x003342B7 [J9PRT24+0x42b7])
J9HookDispatch+0x8a (hookable.c:175, 0x001910BA [J9HOOKABLE24+0x10ba])
j9sig_protect+0x41 (j9signal.c:144, 0x0033C161 [J9PRT24+0xc161])
(0x001D8450)
(0x13C516A0)
(0x13C52020)
1. Create a sample web project
2. Use jav8 jar download from this site to process less files
3. Jvm crashed
Same jar works fine in Mac and some of linux OS
Please let use know what's the root cause of this issue.
Thanks,
Yong
Original issue reported on code.google.com by [email protected]
on 20 Aug 2012 at 8:34
I link both .jar files. But when i try this:
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("jav8");
The "engine" is null. What is wrong ?
Original issue reported on code.google.com by [email protected]
on 8 Feb 2013 at 12:29
I copy the example you have on the home page and set the library
jav8-jsr223-linux-i386-0.3.jar.
When I run the the program.
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class test
{
public static void main(String[] arg)
{
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("jav8");
try {
engine.eval("print('Hello, world!')");
} catch (ScriptException ex) {
ex.printStackTrace();
}
}
}
I got the next exception
Exception in thread "main" java.lang.ExceptionInInitializerError
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:9)
Caused by: java.lang.NullPointerException
at lu.flier.script.V8ScriptEngineFactory.loadLibrary(Unknown Source)
at lu.flier.script.V8ScriptEngineFactory.<clinit>(Unknown Source)
... 10 more
Do I missing something?
Thanks for your help.
Original issue reported on code.google.com by [email protected]
on 5 Apr 2012 at 1:55
http://code.google.com/p/jav8/source/browse/trunk/jni/Utils.cpp#798
Missing DeleteLocalRef after GetObjectArrayElement
Original issue reported on code.google.com by novikov
on 3 Apr 2012 at 7:40
test case :
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("jav8");
Invocable invocable = (Invocable) engine;
engine.eval(
"function Person(me) { this.me = me };"+
"Person.prototype.say = function (you) {" +
" return this.me + ' say, hello ' + you; "+
"}; "+
"var me = new Person('Flier'); "
);
V8Context ctxt = ((V8ScriptEngine) engine).getV8Context();
V8Object me = (V8Object) ctxt.getGlobal().get("me");
String result = ( (String) invocable.invokeMethod(me, "say", "francois"));
///[object Object] say, hello francois
Original issue reported on code.google.com by [email protected]
on 22 Jul 2013 at 8:29
who can tell me where i an get the document of jav8?
thanks
Original issue reported on code.google.com by [email protected]
on 5 Jul 2012 at 2:23
Test case:
@Test
public void testThreads() throws java.lang.InterruptedException, ScriptException {
new ScriptEngineManager().getEngineByName("jav8");
System.gc();
new Thread(new Runnable() {
public void run() {
new ScriptEngineManager().getEngineByName("jav8");
}
}).start();
Thread.sleep(1000);
}
Produces output:
[junit] Invalid memory access of location 0x10 rip=0x10dd18cbe
I've traced it back to line 178 of jav8.cpp, the call to
jni::V8Env env(pEnv);
Inside of
jlong JNICALL Java_lu_flier_script_V8Context_internalCreate(JNIEnv *pEnv,
jobject pObj)
Thanks for your help!
Original issue reported on code.google.com by [email protected]
on 23 Feb 2012 at 10:44
What steps will reproduce the problem?
1. compile v8-3.20.12 with ia32.release library=shared strictaliasing=off
2. compile jav8 (downloaded from trunk)
What is the expected output? What do you see instead?
I expected that jav8 compiles successfully and instead it returns the following:
Buildfile: (...)/build.xml
prepare:
[mkdir] Created dir: (...)/jav8-read-only/build/classes
[mkdir] Created dir: (...)/jav8-read-only/build/bin/release
compile:
[javac] Compiling 26 source files to (...)/jav8-read-only/build/classes
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[copy] Copying 1 file to (...)/jav8-read-only/build/classes/META-INF
jni:
[echo] Generating JNI header ...
[echo] Building JNI library with release mode ...
[echo] linking V8 static library v8_base.ia32,v8_snapshot at (...)/v8-3.20.12//out/ia32.release/obj.target/tools/gyp/
[cc] 3 total files to be compiled.
[cc] In file included from (...)/jav8-read-only/jni/Wrapper.cpp:1:
[cc] (...)/jav8-read-only/jni/Wrapper.h: In static member function ‘static v8::Handle<v8::Object> jni::CBaseJavaObject<T>::InternalWrap(T*)’:
[cc] (...)/jav8-read-only/jni/Wrapper.h:199: error: request for member ‘Reset’ in ‘s_template’, which is of non-class type ‘v8::ObjectTemplate*’
[cc] In file included from (...)/jav8-read-only/jni/Utils.cpp:19:
[cc] (...)/jav8-read-only/jni/Wrapper.h: In static member function ‘static v8::Handle<v8::Object> jni::CBaseJavaObject<T>::InternalWrap(T*)’:
[cc] (...)/jav8-read-only/jni/Wrapper.h:199: error: request for member ‘Reset’ in ‘s_template’, which is of non-class type ‘v8::ObjectTemplate*’
[cc] (...)/v8-3.20.12/include/v8.h: In static member function ‘static v8::Handle<v8::Object> jni::CBaseJavaObject<T>::InternalWrap(T*) [with T = jni::CJavaContext]’:
[cc] (...)/jav8-read-only/jni/Wrapper.h:222: instantiated from ‘static v8::Handle<v8::Object> jni::CBaseJavaObject<T>::Wrap(JNIEnv*, _jobject*) [with T = jni::CJavaContext]’
[cc] (...)/jav8-read-only/jni/Utils.cpp:773: instantiated from here
[cc] (...)/v8-3.20.12/include/v8.h:5614: error: ‘static v8::Local<T> v8::Local<T>::New(v8::Isolate*, T*) [with T = v8::ObjectTemplate]’ is private
[cc] (...)/jav8-read-only/jni/Wrapper.h:203: error: within this context
[cc] (...)/v8-3.20.12/include/v8.h: In static member function ‘static v8::Handle<v8::Object> jni::CBaseJavaObject<T>::InternalWrap(T*) [with T = jni::CJavaArray]’:
[cc] (...)/jav8-read-only/jni/Wrapper.h:222: instantiated from ‘static v8::Handle<v8::Object> jni::CBaseJavaObject<T>::Wrap(JNIEnv*, _jobject*) [with T = jni::CJavaArray]’
[cc] (...)/jav8-read-only/jni/Utils.cpp:809: instantiated from here
[cc] (...)/v8-3.20.12/include/v8.h:5614: error: ‘static v8::Local<T> v8::Local<T>::New(v8::Isolate*, T*) [with T = v8::ObjectTemplate]’ is private
[cc] (...)/jav8-read-only/jni/Wrapper.h:203: error: within this context
[cc] (...)/v8-3.20.12/include/v8.h: In static member function ‘static v8::Handle<v8::Object> jni::CBaseJavaObject<T>::InternalWrap(T*) [with T = jni::CJavaObject]’:
[cc] (...)/jav8-read-only/jni/Wrapper.h:222: instantiated from ‘static v8::Handle<v8::Object> jni::CBaseJavaObject<T>::Wrap(JNIEnv*, _jobject*) [with T = jni::CJavaObject]’
[cc] (...)/jav8-read-only/jni/Utils.cpp:812: instantiated from here
[cc] (...)/v8-3.20.12/include/v8.h:5614: error: ‘static v8::Local<T> v8::Local<T>::New(v8::Isolate*, T*) [with T = v8::ObjectTemplate]’ is private
[cc] (...)/jav8-read-only/jni/Wrapper.h:203: error: within this context
BUILD FAILED
(...)/jav8-read-only/build.xml:182: gcc failed with return code 1
What version of the product are you using? On what operating system?
V8 version: 3.20.12.
JAV8 version: trunk.
OS: RHEL6
GCC: 4.4.6
Please provide any additional information below.
I was able to compile JAV8 using the same environment in a windows machine.
Original issue reported on code.google.com by [email protected]
on 3 Dec 2013 at 5:11
What steps will reproduce the problem?
1. Compiler warning about uninitialized args var in NewObject routine
What is the expected output? What do you see instead?
No warning, correct code
What version of the product are you using? On what operating system?
Latest code from SVN as of 11/3/2014
Please provide any additional information below.
The NewObject routine needs to pass it's variable arguments to the JNI
NewObjectV function.
Here is the current code. Note that the args variable is never initialized.
jobject Env::NewObject(const char *name, const char *sig, ...)
{
jclass clazz = FindClass(name);
jmethodID cid = GetMethodID(clazz, "<init>", sig);
va_list args;
return m_env->NewObjectV(clazz, cid, args);
}
To properly pass the var args to another function I think you need to do the
following:
jobject Env::NewObject(const char *name, const char *sig, ...)
{
jclass clazz = FindClass(name);
jmethodID cid = GetMethodID(clazz, "<init>", sig);
va_list args;
jobject result;
va_start(args, sig);
result = m_env->NewObjectV(clazz, cid, args);
va_end(args);
return result;
}
Original issue reported on code.google.com by [email protected]
on 3 Nov 2014 at 6:52
There is detailed information on how to do it in
https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage
+Guide.
Original issue reported on code.google.com by [email protected]
on 31 Jul 2013 at 12:23
Hi flier,
I tell me if it should be possible for you to provide a JAR jav8 for win32?
Many thank's for your help.
Regards Angelo
Original issue reported on code.google.com by [email protected]
on 21 Oct 2013 at 1:38
A build of project has been failed with the following error:
[junit] Testcase: testV8ScriptEngineFactory took 0.04 sec
[junit] Caused an ERROR
[junit] /media/work/distrib/tmp/libjav830410477471826359.so: /media/work/distrib/tmp/libjav830410477471826359.so: undefined symbol: _ZN2v88internal7Isolate12isolate_key_E
[junit] java.lang.UnsatisfiedLinkError: /media/work/distrib/tmp/libjav830410477471826359.so: /media/work/distrib/tmp/libjav830410477471826359.so: undefined symbol: _ZN2v88internal7Isolate12isolate_key_E
[junit] at java.lang.ClassLoader$NativeLibrary.load(Native Method)
[junit] at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
[junit] at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
[junit] at java.lang.Runtime.load0(Runtime.java:770)
[junit] at java.lang.System.load(System.java:1003)
[junit] at lu.flier.script.V8ScriptEngineFactory.loadLibrary(Unknown Source)
[junit] at lu.flier.script.V8ScriptEngineFactory.<clinit>(Unknown Source)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:247)
[junit] at sun.misc.Service$LazyIterator.next(Service.java:271)
[junit] at javax.script.ScriptEngineManager.initEngines(ScriptEngineManager.java:109)
[junit] at javax.script.ScriptEngineManager.access$000(ScriptEngineManager.java:37)
[junit] at javax.script.ScriptEngineManager$1.run(ScriptEngineManager.java:80)
[junit] at java.security.AccessController.doPrivileged(Native Method)
[junit] at javax.script.ScriptEngineManager.init(ScriptEngineManager.java:78)
[junit] at javax.script.ScriptEngineManager.<init>(ScriptEngineManager.java:51)
[junit] at lu.flier.script.V8ScriptEngineTest.createScriptEngine(Unknown Source)
[junit] at lu.flier.script.V8ScriptEngineTest.setUp(Unknown Source)
V8 build has been completed successfull with no errors.
Original issue reported on code.google.com by [email protected]
on 17 May 2012 at 2:41
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.