Back to index

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

Go to the source code of this file.


 JNI_OJIAPITest (JNIEnv_SetStaticObjectField_1)

Function Documentation

JNI_OJIAPITest ( JNIEnv_SetStaticObjectField_1  )

Definition at line 40 of file SetStaticObjectField_1.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(NULL, fieldID, 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(clazz == NULL) return correct value");
     return TestResult::FAIL("SetStaticObjectField(clazz == NULL) return incorrect value!!!!");


Here is the call graph for this function: