Compare commits
No commits in common. "34026c7e22d080f69473390c6ced352364061bfe" and "014cd5c7c4c016f4ef6215b6e4a04dc9e7e05938" have entirely different histories.
34026c7e22
...
014cd5c7c4
1
gojni.h
1
gojni.h
|
@ -23,7 +23,6 @@ __attribute__ ((visibility ("hidden"))) void _jni_DeleteGlobalRef(JNIEnv *env, j
|
||||||
__attribute__ ((visibility ("hidden"))) jobject _jni_NewLocalRef(JNIEnv *env, jobject obj);
|
__attribute__ ((visibility ("hidden"))) jobject _jni_NewLocalRef(JNIEnv *env, jobject obj);
|
||||||
__attribute__ ((visibility ("hidden"))) void _jni_DeleteLocalRef(JNIEnv *env, jobject obj);
|
__attribute__ ((visibility ("hidden"))) void _jni_DeleteLocalRef(JNIEnv *env, jobject obj);
|
||||||
__attribute__ ((visibility ("hidden"))) jint _jni_CallStaticIntMethodA(JNIEnv *env, jclass cls, jmethodID method, jvalue *args);
|
__attribute__ ((visibility ("hidden"))) jint _jni_CallStaticIntMethodA(JNIEnv *env, jclass cls, jmethodID method, jvalue *args);
|
||||||
__attribute__ ((visibility ("hidden"))) jboolean _jni_CallStaticBooleanMethodA(JNIEnv *env, jclass cls, jmethodID method, jvalue *args);
|
|
||||||
__attribute__ ((visibility ("hidden"))) jobject _jni_CallStaticObjectMethodA(JNIEnv *env, jclass cls, jmethodID method, jvalue *args);
|
__attribute__ ((visibility ("hidden"))) jobject _jni_CallStaticObjectMethodA(JNIEnv *env, jclass cls, jmethodID method, jvalue *args);
|
||||||
__attribute__ ((visibility ("hidden"))) jobject _jni_NewObjectA(JNIEnv *env, jclass cls, jmethodID method, jvalue *args);
|
__attribute__ ((visibility ("hidden"))) jobject _jni_NewObjectA(JNIEnv *env, jclass cls, jmethodID method, jvalue *args);
|
||||||
__attribute__ ((visibility ("hidden"))) void _jni_CallStaticVoidMethodA(JNIEnv *env, jclass cls, jmethodID method, jvalue *args);
|
__attribute__ ((visibility ("hidden"))) void _jni_CallStaticVoidMethodA(JNIEnv *env, jclass cls, jmethodID method, jvalue *args);
|
||||||
|
|
4
jni.c
4
jni.c
|
@ -118,10 +118,6 @@ jint _jni_CallStaticIntMethodA(JNIEnv *env, jclass cls, jmethodID method, jvalue
|
||||||
return (*env)->CallStaticIntMethodA(env, cls, method, args);
|
return (*env)->CallStaticIntMethodA(env, cls, method, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
jboolean _jni_CallStaticBooleanMethodA(JNIEnv *env, jclass cls, jmethodID method, jvalue *args) {
|
|
||||||
return (*env)->CallStaticBooleanMethodA(env, cls, method, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
jobject _jni_CallStaticObjectMethodA(JNIEnv *env, jclass cls, jmethodID method, jvalue *args) {
|
jobject _jni_CallStaticObjectMethodA(JNIEnv *env, jclass cls, jmethodID method, jvalue *args) {
|
||||||
return (*env)->CallStaticObjectMethodA(env, cls, method, args);
|
return (*env)->CallStaticObjectMethodA(env, cls, method, args);
|
||||||
}
|
}
|
||||||
|
|
6
jni.go
6
jni.go
|
@ -104,12 +104,6 @@ func CallStaticIntMethod(e Env, cls Class, method MethodID, args ...Value) (int,
|
||||||
return int(res), exception(e)
|
return int(res), exception(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CallStaticBooleanMethod calls a static method on a Java class, returning an int.
|
|
||||||
func CallStaticBooleanMethod(e Env, cls Class, method MethodID, args ...Value) (bool, error) {
|
|
||||||
res := C._jni_CallStaticBooleanMethodA(e.env, C.jclass(cls), C.jmethodID(method), varArgs(args))
|
|
||||||
return res == TRUE, exception(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FindClass returns a reference to a Java class with a given name, using the
|
// FindClass returns a reference to a Java class with a given name, using the
|
||||||
// JVM's default class loader. Any exceptions caused by the underlying JNI call
|
// JVM's default class loader. Any exceptions caused by the underlying JNI call
|
||||||
// (for example if the class is not found) will result in a panic.
|
// (for example if the class is not found) will result in a panic.
|
||||||
|
|
38
jni_test.go
38
jni_test.go
|
@ -198,44 +198,6 @@ func TestStaticObjectMethod(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStaticBooleanMethod(t *testing.T) {
|
|
||||||
err := Do(vm, func(env Env) error {
|
|
||||||
cls := FindClass(env, "test/AClass")
|
|
||||||
mid := GetStaticMethodID(env, cls, "GetStaticBoolean", "()Z")
|
|
||||||
if mid == nil {
|
|
||||||
t.Errorf("MethodID is nil")
|
|
||||||
}
|
|
||||||
setterMid := GetStaticMethodID(env, cls, "SetStaticBoolean", "(Z)V")
|
|
||||||
if setterMid == nil {
|
|
||||||
t.Errorf("Setter MethodID is nil")
|
|
||||||
}
|
|
||||||
res, err := CallStaticBooleanMethod(env, cls, mid)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Method invocation failed")
|
|
||||||
}
|
|
||||||
if !res {
|
|
||||||
t.Errorf("Method returned %v, not expected value of %v.", res, true)
|
|
||||||
}
|
|
||||||
if err := CallStaticVoidMethod(env, cls, setterMid, FALSE); err != nil {
|
|
||||||
t.Errorf("Setter invocation failed")
|
|
||||||
}
|
|
||||||
res, err = CallStaticBooleanMethod(env, cls, mid)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Method invocation failed")
|
|
||||||
}
|
|
||||||
if res {
|
|
||||||
t.Errorf("Method returned %v, not expected value of %v.", res, false)
|
|
||||||
}
|
|
||||||
if err := CallStaticVoidMethod(env, cls, setterMid, TRUE); err != nil {
|
|
||||||
t.Errorf("Setter invocation failed")
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Error: %s", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMethod(t *testing.T) {
|
func TestMethod(t *testing.T) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r == nil {
|
if r := recover(); r == nil {
|
||||||
|
|
Binary file not shown.
|
@ -47,7 +47,7 @@ public class AClass {
|
||||||
private float pfl = (float)2.2;
|
private float pfl = (float)2.2;
|
||||||
private double pdb = 1001.1001;
|
private double pdb = 1001.1001;
|
||||||
|
|
||||||
public static boolean GetStaticBoolean() {
|
public static Boolean GetStaticBoolean() {
|
||||||
return staticbl;
|
return staticbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,10 +75,6 @@ public class AClass {
|
||||||
return staticobj;
|
return staticobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetStaticBoolean(boolean val) {
|
|
||||||
staticbl = val;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void IncInt() {
|
public void IncInt() {
|
||||||
in = in + 1;
|
in = in + 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user