Comparing version 0.4.1 to 0.4.2
@@ -28,2 +28,4 @@ 'use strict'; | ||
result.class = clazz; | ||
// copy static fields | ||
@@ -30,0 +32,0 @@ var fields = clazz.getDeclaredFieldsSync(); |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"engines": { | ||
@@ -13,0 +13,0 @@ "node": ">=0.8.0" |
@@ -141,2 +141,3 @@ [![Build Status](https://travis-ci.org/joeferner/node-java.png)](https://travis-ci.org/joeferner/node-java) | ||
* [callStaticMethod](#javaCallStaticMethod) | ||
* [callMethod](#javaCallMethod) | ||
* [getStaticFieldValue](#javaGetStaticFieldValue) | ||
@@ -256,3 +257,3 @@ * [setStaticFieldValue](#javaSetStaticFieldValue) | ||
* className - The name of the class to call the method on. For subclasses seperate using a '$' (eg. com.nearinfinty.MyClass$SubClass) | ||
* methodName - The name of the method to call. | ||
* methodName - The name of the method to call. The method name can include the full signature (see [Getting the full method signature](#getFullMethodSignature)). | ||
* callback(err, item) - Callback to be called when the class is created. | ||
@@ -269,2 +270,27 @@ | ||
<a name="javaCallMethod" /> | ||
**java.callMethod(instance, methodName, [args...], callback)** | ||
**java.callMethodSync(instance, methodName, [args...]) : result** | ||
Calls a method on the specified instance. If you are using the sync method an exception will be throw if an error occures, | ||
otherwise it will be the first argument in the callback. | ||
__Arguments__ | ||
* instance - An instance of the class from newInstance. | ||
* methodName - The name of the method to call. The method name can include the full signature (see [Getting the full method signature](#getFullMethodSignature)). | ||
* callback(err, item) - Callback to be called when the class is created. | ||
__Example__ | ||
var instance = java.newInstanceSync("com.nearinfinty.MyClass"); | ||
var result = java.callMethodSync("com.nearinfinty.MyClass", "doSomething", 42, "test"); | ||
java.callMethodSync(instance, "doSomething", 42, "test", function(err, results) { | ||
if(err) { console.error(err); return; } | ||
// results from doSomething | ||
}); | ||
<a name="javaGetStaticFieldValue" /> | ||
@@ -454,2 +480,16 @@ **java.getStaticFieldValue(className, fieldName)** | ||
<a name="getFullMethodSignature" /> | ||
# Getting the Full Method Signature | ||
Run `javap -s -classpath <your-class-path> <your-class-name>`. Find the method name you are looking for. For example: | ||
``` | ||
public int methodAmbiguous(java.lang.Double); | ||
Signature: (Ljava/lang/Double;)I | ||
``` | ||
The full method signature would be `methodAmbiguous(Ljava/lang/Double;)I`. | ||
If you have grep, a shortcut is `javap -s -classpath . my.company.MyClass | grep -A1 myMethodName`. | ||
# Signal Handling | ||
@@ -456,0 +496,0 @@ |
@@ -15,2 +15,8 @@ var java = require("../testHelpers").java; | ||
"callStaticMethod without a callback": function(test) { | ||
var result = java.callStaticMethod("Test", "staticMethod"); | ||
console.log("callStaticMethod without a callback result message", result); | ||
test.done(); | ||
}, | ||
"callStaticMethodSync": function(test) { | ||
@@ -17,0 +23,0 @@ var result = java.callStaticMethodSync("Test", "staticMethod"); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2298420
64
1155
566