if (annotation == annotation2) {
result = JNI_TRUE;
goto exit;
}
if (annotation != NULL && annotation2 != NULL) {
// get annotationType
annotationType = (*env)->GetObjectClass(env, annotation);
ValidateNotNull(env, annotationType, "Annotation %s with null annotationType()", annotation);
annotationType2 = (*env)->GetObjectClass(env, annotation2);
ValidateNotNull(env, annotationType2, "Annotation %s with null annotationType()", annotation2);
// compare annotationType
if (!(*env)->IsSameObject(env, annotationType, annotationType2)) {
result = JNI_FALSE;
goto exit;
}
// get declared methods
getDeclaredMethods = (*env)->GetMethodID(env, annotationType, "getDeclaredMethods", "()[Ljava/lang/reflect/Method;");
methodsArray = (jobjectArray)(*env)->CallObjectMethod(env, annotationType, getDeclaredMethods);
arrayLength = (*env)->GetArrayLength(env, methodsArray);
// iterate methods and compare
for (i = 0; i < arrayLength; i++) {
jobject method = (*env)->GetObjectArrayElement(env, methodsArray, i);
// get param type length
jmethodID getParameterTypes = (*env)->GetMethodID(env, method, "getParameterTypes", "()[Ljava/lang/Class;");
jobjectArray parameterTypesArray = (jobjectArray)(*env)->CallObjectMethod(env, method, getParameterTypes);
jsize parameterTypesLength = (*env)->GetArrayLength(env, parameterTypesArray);
// compare return type
getReturnType = (*env)->GetMethodID(env, method, "getReturnType", "()Ljava/lang/Class;");
returnType = (*env)->CallObjectMethod(env, method, getReturnType);
if (parameterTypesLength == 0 && isValidAnnotationMemberType(env, returnType)) {
// call method to get return values
invoke = (*env)->GetMethodID(env, method, "invoke", "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;");
jobject returnValue1 = (*env)->CallObjectMethod(env, method, invoke, annotation, NULL);
jobject returnValue2 = (*env)->CallObjectMethod(env, method, invoke, annotation2, NULL);
// compare return values
if (!memberEquals(env, returnType, returnValue1, returnValue2, &memberEqualsResult)) {
// call failed
result = JNI_FALSE;
goto exit;
}
else {
// compare failed
if (memberEqualsResult == JNI_FALSE) {
result = JNI_FALSE;
goto exit;
}
}
}
}
result = JNI_TRUE;
}