1 |
14 |
jlechner |
#include "MethodTester.h"
|
2 |
|
|
#include <jnilink.h>
|
3 |
|
|
#include <jcl.h>
|
4 |
|
|
|
5 |
|
|
static linkPtr t1_1=NULL;
|
6 |
|
|
static linkPtr t1_2=NULL;
|
7 |
|
|
static linkPtr t2=NULL;
|
8 |
|
|
static linkPtr t3=NULL;
|
9 |
|
|
static linkPtr t4=NULL;
|
10 |
|
|
static linkPtr t5=NULL;
|
11 |
|
|
static linkPtr t6=NULL;
|
12 |
|
|
|
13 |
|
|
/*
|
14 |
|
|
* Class: MethodTester
|
15 |
|
|
* Method: test1
|
16 |
|
|
* Signature: (LData1;LData2;)Z
|
17 |
|
|
*/
|
18 |
|
|
JNIEXPORT jboolean JNICALL Java_MethodTester_test1
|
19 |
|
|
(JNIEnv * env, jobject thisObj, jobject d1, jobject d2) {
|
20 |
|
|
if(LINK_LinkClass(env,&t1_1,"Data1") == NULL || LINK_LinkClass(env,&t1_2,"Data2") == NULL)
|
21 |
|
|
return JNI_FALSE;
|
22 |
|
|
if(!(*env)->IsAssignableFrom(env, LINK_ResolveClass(env,t1_1), LINK_ResolveClass(env,t1_2))
|
23 |
|
|
&& (*env)->IsAssignableFrom(env, LINK_ResolveClass(env,t1_2), LINK_ResolveClass(env,t1_1))) {
|
24 |
|
|
return JNI_TRUE;
|
25 |
|
|
} else {
|
26 |
|
|
return JNI_FALSE;
|
27 |
|
|
}
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
/*
|
31 |
|
|
* Class: MethodTester
|
32 |
|
|
* Method: test2
|
33 |
|
|
* Signature: (LData1;LData2;)Z
|
34 |
|
|
*/
|
35 |
|
|
JNIEXPORT jboolean JNICALL Java_MethodTester_test2
|
36 |
|
|
(JNIEnv * env, jobject thisObj, jobject d1, jobject d2) {
|
37 |
|
|
jclass c1 = (*env)->GetObjectClass(env,d1);
|
38 |
|
|
jclass c2 = (*env)->GetObjectClass(env,d2);
|
39 |
|
|
if(LINK_LinkField(env,&t2,c1,"instanceVar","Z") == NULL)
|
40 |
|
|
return JNI_FALSE;
|
41 |
|
|
return (*env)->GetBooleanField(env,d1,LINK_ResolveField(env,t2))
|
42 |
|
|
&& (*env)->GetBooleanField(env,d2,LINK_ResolveField(env,t2));
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
/*
|
46 |
|
|
* Class: MethodTester
|
47 |
|
|
* Method: test3
|
48 |
|
|
* Signature: (LData1;LData2;)Z
|
49 |
|
|
*/
|
50 |
|
|
JNIEXPORT jboolean JNICALL Java_MethodTester_test3
|
51 |
|
|
(JNIEnv * env, jobject thisObj, jobject d1, jobject d2) {
|
52 |
|
|
jclass c1 = (*env)->GetObjectClass(env,d1);
|
53 |
|
|
jclass c2 = (*env)->GetObjectClass(env,d2);
|
54 |
|
|
if(LINK_LinkStaticField(env,&t3,c1,"staticVar","Z") == NULL)
|
55 |
|
|
return JNI_FALSE;
|
56 |
|
|
return (*env)->GetStaticBooleanField(env,d1,LINK_ResolveStaticField(env,t3))
|
57 |
|
|
&& (*env)->GetStaticBooleanField(env,d2,LINK_ResolveStaticField(env,t3));
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
/*
|
61 |
|
|
* Class: MethodTester
|
62 |
|
|
* Method: test4
|
63 |
|
|
* Signature: (LData1;LData2;)Z
|
64 |
|
|
*/
|
65 |
|
|
JNIEXPORT jboolean JNICALL Java_MethodTester_test4
|
66 |
|
|
(JNIEnv * env, jobject thisObj, jobject d1, jobject d2) {
|
67 |
|
|
jclass c1 = (*env)->GetObjectClass(env,d1);
|
68 |
|
|
jclass c2 = (*env)->GetObjectClass(env,d2);
|
69 |
|
|
jmethodID m1;
|
70 |
|
|
jmethodID m2;
|
71 |
|
|
if(LINK_LinkMethod(env,&t4,c1,"instanceMethod","()Z") == NULL)
|
72 |
|
|
return JNI_FALSE;
|
73 |
|
|
m1 = LINK_ResolveMethod(env,t4);
|
74 |
|
|
m2 = LINK_ResolveMethod(env,t4);
|
75 |
|
|
return (*env)->CallBooleanMethod(env,d1,m1)
|
76 |
|
|
&& !(*env)->CallBooleanMethod(env,d2,m2);
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
/*
|
81 |
|
|
* Class: MethodTester
|
82 |
|
|
* Method: test5
|
83 |
|
|
* Signature: (LData1;LData2;)Z
|
84 |
|
|
*/
|
85 |
|
|
JNIEXPORT jboolean JNICALL Java_MethodTester_test5
|
86 |
|
|
(JNIEnv * env, jobject thisObj, jobject d1, jobject d2) {
|
87 |
|
|
jclass c1 = (*env)->GetObjectClass(env,d1);
|
88 |
|
|
jclass c2 = (*env)->GetObjectClass(env,d2);
|
89 |
|
|
if(LINK_LinkStaticMethod(env,&t5,c1,"staticMethod","()Z") == NULL)
|
90 |
|
|
return JNI_FALSE;
|
91 |
|
|
return (*env)->CallStaticBooleanMethod(env,c1,LINK_ResolveStaticMethod(env,t5))
|
92 |
|
|
&& (*env)->CallStaticBooleanMethod(env,c2,LINK_ResolveStaticMethod(env,t5));
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
/*
|
97 |
|
|
* Class: MethodTester
|
98 |
|
|
* Method: test6
|
99 |
|
|
* Signature: (LData1;LData2;)Z
|
100 |
|
|
*/
|
101 |
|
|
JNIEXPORT jboolean JNICALL Java_MethodTester_test6
|
102 |
|
|
(JNIEnv * env, jobject thisObj, jobject d1, jobject d2) {
|
103 |
|
|
jclass c1 = (*env)->GetObjectClass(env,d1);
|
104 |
|
|
jclass c2 = (*env)->GetObjectClass(env,d2);
|
105 |
|
|
if(LINK_LinkMethod(env,&t6,c1,"finalMethod","()Z") == NULL)
|
106 |
|
|
return JNI_FALSE;
|
107 |
|
|
return (*env)->CallBooleanMethod(env,d1,LINK_ResolveMethod(env,t6))
|
108 |
|
|
&& !(*env)->CallBooleanMethod(env,d2,LINK_ResolveMethod(env,t6));
|
109 |
|
|
}
|
110 |
|
|
|