Back to index

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

Go to the source code of this file.


 JNI_OJIAPITest (JNIEnv_GetStaticObjectField_5)

Function Documentation

JNI_OJIAPITest ( JNIEnv_GetStaticObjectField_5  )

Definition at line 40 of file GetStaticObjectField_5.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, 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 == 4)){
     printf("Value is \"asdf\"!!\n\nIt's correct!\n");
     return TestResult::PASS("GetStaticObjectField(all right) return correct value");
     return TestResult::FAIL("GetStaticObjectField(all right) return incorrect value!!!!");


Here is the call graph for this function: