Back to index

lightning-sunbird  0.9+nobinonly
SetStaticObjectField_4.cpp File Reference
#include "JNIEnvTests.h"
#include "AccessingStaticFields.h"

Go to the source code of this file.


 JNI_OJIAPITest (JNIEnv_SetStaticObjectField_4)

Function Documentation

JNI_OJIAPITest ( JNIEnv_SetStaticObjectField_4  )

Definition at line 40 of file SetStaticObjectField_4.cpp.


  IMPLEMENT_GetStaticFieldID_METHOD("Test1", "static_name_string", "Ljava/lang/String;");
  jchar str_chars1[]={'a', 's', 'd', 'f'};

  jstring str = env->NewString(str_chars1, 4); 
  env->SetStaticObjectField(clazz, NULL, str);
  jstring value = (jstring)env->GetStaticObjectField(clazz, fieldID);

  jboolean isCopy = TRUE;
  char* str_chars = (char *) env->GetStringUTFChars(value, &isCopy);
  printf("The GetStringUTFChars returned : %s\n\n", str_chars);

  jsize len = env->GetStringLength(value);
  if((str_chars != NULL) && ((int)len == 3)){
     printf("Value is correct!!\n\nIt's correct!\n");
     return TestResult::PASS("SetStaticObjectField(fieldID == NULL) return correct value");
     return TestResult::FAIL("SetStaticObjectField(fieldID == NULL) return incorrect value!!!!");


Here is the call graph for this function: