| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -470,6 +470,19 @@ v8::Handle<v8::Value> Java::createJVM(JavaVM** jvm, JNIEnv** env) { | |||
| 470 | 470 | } | |
| 471 | 471 | } | |
| 472 | 472 | ||
| 473 | + else if(strcmp(className.c_str(), "char") == 0) { | ||
| 474 | + results = env->NewCharArray(arrayObj->Length()); | ||
| 475 | + for(uint32_t i=0; i<arrayObj->Length(); i++) { | ||
| 476 | + v8::Local<v8::Value> item = arrayObj->Get(i); | ||
| 477 | + jobject val = v8ToJava(env, item); | ||
| 478 | + jclass stringClazz = env->FindClass("java/lang/String"); | ||
| 479 | + jmethodID string_charAt = env->GetMethodID(stringClazz, "charAt", "(I)C"); | ||
| 480 | + jchar itemValues[1]; | ||
| 481 | + itemValues[0] = env->CallCharMethod(val, string_charAt, 0); | ||
| 482 | + env->SetCharArrayRegion((jcharArray)results, i, 1, itemValues); | ||
| 483 | + } | ||
| 484 | + } | ||
| 485 | + | ||
| 473 | 486 | else | |
| 474 | 487 | { | |
| 475 | 488 | jclass clazz = javaFindClass(env, className); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,8 @@ public Test() {} | |||
| 24 | 24 | public static int staticMethodOverload(int a) { return 2; } | |
| 25 | 25 | public static int staticMethodOverload(SuperClass a) { return a.getVal(); } | |
| 26 | 26 | ||
| 27 | + public static String staticMethodCharArrayToString(char[] a) { return new String(a); } | ||
| 28 | + | ||
| 27 | 29 | public static class SuperClass { | |
| 28 | 30 | public int getVal() { return 3; } | |
| 29 | 31 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -127,5 +127,14 @@ exports['Java - Call Static Method'] = nodeunit.testCase({ | |||
| 127 | 127 | test.ok(err.toString().match(/my exception/)); | |
| 128 | 128 | } | |
| 129 | 129 | test.done(); | |
| 130 | + }, | ||
| 131 | + | ||
| 132 | + "char array": function(test) { | ||
| 133 | + var charArray = java.newArray("char", "hello world\n".split('')); | ||
| 134 | + java.callStaticMethod("Test", "staticMethodCharArrayToString", charArray, function(err, result) { | ||
| 135 | + test.ok(result); | ||
| 136 | + test.equal(result, "hello world\n"); | ||
| 137 | + test.done(); | ||
| 138 | + }); | ||
| 130 | 139 | } | |
| 131 | 140 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments