| var fs = require('fs'); | ||
| var java; | ||
| try { | ||
| console.log('trying [release]') | ||
| //RELEASE | ||
| java = require('../build/Release/ella.node'); //debug mode. | ||
| } catch (e) { | ||
| console.log('fail: trying [debug]') | ||
| //DEBUG | ||
| java = require('../build/Debug/ella.node'); //debug mode. | ||
| try { | ||
| java = require('ella'); | ||
| } catch (e) { | ||
| console.log('cant load library: ella'); | ||
| } | ||
| } | ||
| var vm = {}; | ||
| var strBuffer; | ||
| var pdf; | ||
| var str; | ||
| java.setClassPath(['../demo/lib', '../demo/PDFHtml/bin'], true); | ||
| java.start(function(_vm) { | ||
| vm = _vm; | ||
| pdf = vm.New('pdf.P2HService'); | ||
| var things = ['Rock', 'Paper', 'Scissor']; | ||
| var s = "", size =2100; | ||
| console.time("string class [concat]"); | ||
| for (var i = 0; i < size; i++) { | ||
| var thing = things[Math.floor(Math.random() * things.length)]; | ||
| s = pdf.concat(s, thing) | ||
| } | ||
| console.timeEnd("string class [concat]"); | ||
| console.log('str length: ', s.length, ' iterations: ',size ); | ||
| console.time("object allocation."); | ||
| size = 5000; | ||
| var pdfs = []; | ||
| for (var i = 0; i < size; i++) { | ||
| pdfs[i] = vm.New('pdf.P2HService'); | ||
| } | ||
| console.timeEnd("object allocation."); | ||
| console.log('objs number: ', pdfs.length, ' iterations: ',size ); | ||
| }); |
+72
| var fs = require('fs'); | ||
| var java; | ||
| try { | ||
| console.log('trying [release]') | ||
| //RELEASE | ||
| java = require('../build/Release/ella.node'); //debug mode. | ||
| } catch (e) { | ||
| console.log('fail: trying [debug]') | ||
| //DEBUG | ||
| java = require('../build/Debug/ella.node'); //debug mode. | ||
| } | ||
| var vm = {}; | ||
| var strBuffer; | ||
| var pdf; | ||
| var str; | ||
| java.setClassPath(['../demo/lib', '../demo/PDFHtml/bin'], true); | ||
| java.start(function(_vm) { | ||
| vm = _vm; | ||
| pdf = vm.New('pdf.P2HService'); | ||
| var things = ['Rock', 'Paper', 'Scissor']; | ||
| var s=""; | ||
| console.time("object allocation"); | ||
| for(var i =0; i<2000; i++){ | ||
| var thing = things[Math.floor(Math.random()*things.length)]; | ||
| s = pdf.concat(s, thing) | ||
| } | ||
| console.timeEnd("object allocation"); | ||
| console.log('str length->', s.length); | ||
| pdf.add(5000, 5000, function(s) { | ||
| console.log('s->', s); | ||
| }); | ||
| for (var i = 0; i < 10; i++) { | ||
| pdf.concatHeavy("hello", "world", 1000, function(s) { | ||
| console.log('s->', s); | ||
| }); | ||
| } | ||
| var pdfs = []; | ||
| console.time("object allocation"); | ||
| for (var i = 0; i < 5000; i++) { | ||
| pdfs.push(vm.New('pdf.P2HService')); | ||
| } | ||
| console.timeEnd("object allocation"); | ||
| }); |
+1
-1
| { | ||
| "name": "ella", | ||
| "version": "1.1.1", | ||
| "version": "1.1.2", | ||
| "description": "", | ||
@@ -5,0 +5,0 @@ "main": "ella.node", |
+2
-2
@@ -47,3 +47,3 @@ # Ella | ||
| path: path where to find the .jars/.class | ||
| path: array, paths where to find the .jars/.class | ||
@@ -57,3 +57,3 @@ recursive: true/false, if true look for jar/classes recursively. | ||
| var ella = require('ella'); | ||
| ella.setClassPath('/folder/with/.jars/.class', true); | ||
| ella.setClassPath(['/folder/with/.jars/.class', ...], true); | ||
| ``` | ||
@@ -60,0 +60,0 @@ |
@@ -62,3 +62,3 @@ #include "jvm_handler.h" | ||
| void* handle = dlopen("./linux/libjvm.so", RTLD_LAZY); | ||
| void* handle = dlopen("./jdk/libjvm.so", RTLD_LAZY); | ||
@@ -65,0 +65,0 @@ if (!handle) throw VMError{ "Fatal: Can't load dynamic library libjvm.so" }; |
@@ -114,3 +114,3 @@ // | ||
| // Calling V8 here is illegal | ||
| /* Calling V8 here is illegal */ | ||
| void Execute() { | ||
@@ -117,0 +117,0 @@ call(); |
@@ -48,3 +48,3 @@ // | ||
| //functions dedicated to transform from v8 -> LibJNI::BaseJavaValue in ella_functions. | ||
| //functions dedicated to transform from v8 -> LibJNI::BaseJavaValue in [ella_types.h]. | ||
| fnHandler.SetArguments(args, {GetString, GetNumber}); | ||
@@ -115,2 +115,4 @@ fnHandler.DetectAndGetCallback(args, GetFunctionCallback); | ||
| // easy replacement of call implementation. | ||
| supportedInvocations.Create<StringCall>(); | ||
@@ -146,6 +148,9 @@ supportedInvocations.Create<IntCall>(); | ||
| vm.SetClassPath( ClassPath::LocateLibraries(dirs, recursive) ); | ||
| if(!dirs.empty()) | ||
| vm.SetClassPath( ClassPath::LocateLibraries(dirs, recursive) ); | ||
| else | ||
| throw VMError{"Array needed: SetClassPath(Array, boolean)"}; | ||
| }catch(VMError& error){ | ||
| Nan::ThrowTypeError( error.errorMessage.c_str() ); | ||
| Nan::ThrowError( error.errorMessage.c_str() ); | ||
| } | ||
@@ -152,0 +157,0 @@ |
+21
-36
@@ -1,22 +0,30 @@ | ||
| var jvm = require('../../build/Debug/ella.node') || require('./build/Debug/ella.node'); //debug mode. | ||
| 'use strict'; | ||
| var fs = require('fs'); | ||
| <<<<<<< HEAD | ||
| var path = require('path'); | ||
| var jvm = {}; | ||
| try { | ||
| console.log('trying [release]') | ||
| //RELEASE | ||
| jvm = require('../../build/Debug/ella.node'); //debug mode. | ||
| } catch (e) { | ||
| console.log('fail: trying [debug]') | ||
| //DEBUG | ||
| try { | ||
| jvm = require('../build/Debug/ella.node'); //debug mode. | ||
| } catch (e) { | ||
| try { | ||
| jvm = require('ella'); | ||
| } catch (e) { | ||
| console.log('Ella not found!'); | ||
| } | ||
| } | ||
| } | ||
| // macosx location of jar. | ||
| jvm.setClassPath('-Djava.class.path=.:/Users/cvaldez/Desktop/NWR/java/lib/itext-5.5.8/itextpdf-5.5.8.jar:/Users/cvaldez/Desktop/NWR/java/lib/itext-5.5.8/xmlworker-5.5.8.jar:/Users/cvaldez/Desktop/NWR/java/lib/pdfbox/pdfbox-app-1.8.11.jar:/Users/cvaldez/Desktop/NWR/java/PDFHtml/bin/'); | ||
| /* | ||
| jvm.setClassPath('../demo/lib/itext-5.5.8/itextpdf-5.5.8.jar:../demo/PDFHtml/bin/:../demo/lib/itext-5.5.8/xmlworker-5.5.8.jar:../demo/lib/pdfbox-app-1.8.11.jar'); | ||
| */ | ||
| jvm.setClassPath(['../demo/lib/', '../demo/PDFHtml/'], true); | ||
| ======= | ||
| console.log(jvm.getClassPath()); | ||
| jvm.setClassPath('../demo/lib/pdfbox-app-1.8.11.jar'); | ||
| jvm.setClassPath('../demo/lib/itext-5.5.8/itextpdf-5.5.8.jar:../demo/PDFHtml/bin/:../demo/lib/itext-5.5.8/xmlworker-5.5.8.jar:../demo/lib/pdfbox-app-1.8.11.jar'); | ||
| >>>>>>> b92fa2e6b1b1e0fb1583a72e6c995731cec7ac63 | ||
| var PDF = function(cb) { | ||
@@ -36,15 +44,2 @@ | ||
| var stack = function() { | ||
| <<<<<<< HEAD | ||
| var pdf_name = items[i]; | ||
| console.log('sapik->', pdf_name, 'ext->', path.extname(pdf_name), ' ??->', path.extname(pdf_name) === '.pdf'); | ||
| if (path.extname(pdf_name) === '.pdf') { | ||
| console.log('loading pdf -> ', pdf_name); | ||
| javaObject.Strip("../pdfs/" + pdf_name, function(str) { | ||
| console.log('adding...'); | ||
| hash[pdf_name] = str; | ||
| cb(hash); | ||
| }); | ||
| } else | ||
| cb({}); | ||
| ======= | ||
| var k = items[i]; | ||
@@ -56,3 +51,2 @@ javaObject.Strip("../pdfs/" + items[i], function(str) { | ||
| }); | ||
| >>>>>>> b92fa2e6b1b1e0fb1583a72e6c995731cec7ac63 | ||
| }(); | ||
@@ -62,16 +56,7 @@ }); | ||
| <<<<<<< HEAD | ||
| previewPDF: function(pdfName, cb) { | ||
| javaObject.preview("../pdfs/" + pdfName, function(buffer) { | ||
| console.log('preview of:', pdfName); | ||
| cb(buffer.toString('base64')); | ||
| }); | ||
| ======= | ||
| previewPDF: function(pdfName, cb){ | ||
| javaObject.preview("../pdfs/" + pdfName, function(buffer) { | ||
| cb(buffer.toString('base64')); | ||
| }); | ||
| >>>>>>> b92fa2e6b1b1e0fb1583a72e6c995731cec7ac63 | ||
| } | ||
@@ -78,0 +63,0 @@ } |
| //var java = require('../build/Release/ella.node'); | ||
| var java = require('../build/Debug/ella.node'); //debug mode. | ||
| var java; | ||
| try { | ||
| console.log('trying [release]') | ||
| //RELEASE | ||
| java = require('./build/Debug/ella.node'); //debug mode. | ||
| } catch (e) { | ||
| console.log('fail: trying [debug]') | ||
| //DEBUG | ||
| java = require('../build/Debug/ella.node'); //debug mode. | ||
| } | ||
| var fs = require('fs'); | ||
@@ -16,6 +27,5 @@ var exec = require('child_process').exec; | ||
| // linux location of the jars. | ||
| java.setClassPath('../demo/lib/itext-5.5.8/itextpdf-5.5.8.jar:../demo/PDFHtml/bin/:../demo/lib/itext-5.5.8/xmlworker-5.5.8.jar'); | ||
| java.setClassPath(['../demo/lib/', '../demo/PDFHtml'], true); | ||
| console.log('classpath->', java.getClassPath()); | ||
| java.start(function(jvm) { | ||
@@ -26,3 +36,3 @@ | ||
| console.log('loading->') | ||
| var javaObject = jvm.New("pdf/P2HService"); | ||
| var javaObject = jvm.New("pdf.P2HService"); | ||
@@ -85,3 +95,2 @@ console.log('Calling PDF Generator method'); | ||
| } | ||
| console.log('generating pdf....'); | ||
@@ -88,0 +97,0 @@ }); |
+10
-8
@@ -31,5 +31,5 @@ var assert = require('chai').assert; | ||
| console.time('recursive search'); | ||
| java.setClassPath(['/Users/cvaldez/Desktop/NWR/java/lib', '/Users/cvaldez/Desktop/NWR/java/PDFHtml/bin'], true); | ||
| //java.setClassPath(['/Users/cvaldez/Desktop/NWR/java/lib', '/Users/cvaldez/Desktop/NWR/java/PDFHtml/bin'], true); | ||
| //java.setClassPath(['../demo/lib', '../demo/PDFHtml/bin'], true); | ||
| java.setClassPath(['../demo/lib', '../demo/PDFHtml/bin'], true); | ||
| console.timeEnd('recursive search'); | ||
@@ -47,5 +47,5 @@ | ||
| java.setClassPath(['/Users/cvaldez/Desktop/NWR/java/lib/', '/Users/cvaldez/Desktop/NWR/java/PDFHtml/bin/'], true); | ||
| //java.setClassPath(['/Users/cvaldez/Desktop/NWR/java/lib/', '/Users/cvaldez/Desktop/NWR/java/PDFHtml/bin/'], true); | ||
| //java.setClassPath(['../demo/lib', '../demo/PDFHtml/bin'], true); | ||
| java.setClassPath(['../demo/lib', '../demo/PDFHtml/bin'], true); | ||
| assert.notEqual(java.getClassPath(), '', 'should expect something here.'); | ||
@@ -62,2 +62,4 @@ //console.log('classpath ->' ,java.getClassPath()); | ||
| var strBuffer; | ||
@@ -109,3 +111,2 @@ var pdf; | ||
| /* | ||
| it('calling methods with Args(Int...)', function() { | ||
@@ -120,3 +121,2 @@ | ||
| it('calling methods with Args(Int...) [async]', function(done) { | ||
@@ -144,2 +144,3 @@ | ||
| /* | ||
| it('calling methods with Args(String...): Sleep Thread in Java side. [async]', function(done) { | ||
@@ -179,3 +180,4 @@ | ||
| it('calling methods with Args(float...) [async]', function(done) { | ||
| */ | ||
| it('calling methods with Args(doubles...) [async]', function(done) { | ||
@@ -193,2 +195,3 @@ assert.isObject(pdf, 'loading pdf'); | ||
| it('calling method byte[](*)(string) --> testing byte[] return_type [async]', function(done) { | ||
@@ -210,3 +213,2 @@ | ||
| */ | ||
@@ -213,0 +215,0 @@ |
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
560503
0.25%64
3.23%1385
6.13%16
14.29%