Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions compile-java-code.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set JAVA_VERSION=1.7

set OUTFILE="%TMP%\findJavaHome.txt"
node findJavaHome.js > %OUTFILE%
set /p JAVA_HOME=<%OUTFILE%

set JAVAC_OPTS=-source %JAVA_VERSION% -target %JAVA_VERSION% -bootclasspath "%JAVA_HOME%\jre\lib\rt.jar"

cd test
"%JAVA_HOME%\bin\javac" %JAVAC_OPTS% *.java

cd ..\src-java\node
"%JAVA_HOME%\bin\javac" %JAVAC_OPTS% *.java

cd ..\..\
"%JAVA_HOME%\bin\javah" -classpath src-java -d .\src node.NodeDynamicProxyClass
8 changes: 8 additions & 0 deletions compile-java8-code.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set JAVA_VERSION=1.8

set OUTFILE="%TMP%\findJavaHome.txt"
node findJavaHome.js > %OUTFILE%
set /p JAVA_HOME=<%OUTFILE%

cd test8
"%JAVA_HOME%\bin\javac" -source %JAVA_VERSION% *.java
2 changes: 1 addition & 1 deletion src/java.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ NAN_METHOD(Java::newProxy) {
jclass objectClazz = env->FindClass("java/lang/Object");
jobjectArray methodArgs = env->NewObjectArray(2, objectClazz, NULL);
env->SetObjectArrayElement(methodArgs, 0, v8ToJava(env, Nan::New<v8::String>(s_nativeBindingLocation.c_str()).ToLocalChecked()));
env->SetObjectArrayElement(methodArgs, 1, longToJavaLongObj(env, (long)dynamicProxyData));
env->SetObjectArrayElement(methodArgs, 1, longToJavaLongObj(env, (jlong)dynamicProxyData));
jobject method = javaFindConstructor(env, clazz, methodArgs);
if(method == NULL) {
std::ostringstream errStr;
Expand Down
Binary file added test/ListenerInterface.class
Binary file not shown.
3 changes: 3 additions & 0 deletions test/ListenerInterface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public interface ListenerInterface {
void onEvent(java.util.ArrayList<String> list, java.lang.Runtime runtime);
}
Binary file added test/ListenerTester.class
Binary file not shown.
19 changes: 19 additions & 0 deletions test/ListenerTester.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
public class ListenerTester {
private ListenerInterface _listener;

public void setListener(ListenerInterface listener) {
this._listener = listener;
}

public void raiseEvent() {
if(this._listener == null)
return;

java.util.ArrayList<String> list = new java.util.ArrayList<String>();
list.add("hello");
list.add("from");
list.add("Java");

this._listener.onEvent(list, java.lang.Runtime.getRuntime());
}
}
18 changes: 18 additions & 0 deletions test/dynamicProxy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ exports['Dynamic Proxy'] = nodeunit.testCase({
test.done();
},

"Listener test": function (test) {
var runData = '';

var myProxy = java.newProxy('ListenerInterface', {
onEvent: function (list, runtime) {
runData = 'onEvent';
}
});

var listenerTester = java.newInstanceSync("ListenerTester");
listenerTester.setListenerSync(myProxy);
listenerTester.raiseEventSync();

test.equals(runData, 'onEvent');

test.done();
},

"thread": function (test) {
var callCount = 0;

Expand Down
5 changes: 4 additions & 1 deletion testRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ var tests = glob.sync(path.join('testAsyncOptions', '*.js'));
tests.unshift('test test8'); // Arrange to run the primary tests first, in a single process

function runTest(testArgs, done) {
var cmd = 'node_modules/.bin/nodeunit ' + testArgs;
var cmd = 'node_modules/.bin/nodeunit ';
if(process.platform == "win32")
cmd = 'node_modules\\.bin\\nodeunit ';
cmd += testArgs;
childProcess.exec(cmd, function (error, stdout, stderr) {
// It appears that nodeunit merges error output into the stdout
// so these three lines are probably useless.
Expand Down