< prev index next >

src/hotspot/share/prims/jniCheck.cpp

Print this page
*** 254,11 ***
  
    /* check for proper field type */
    if (!id->find_local_field(&fd))
      ReportJNIFatalError(thr, fatal_static_field_not_found);
    if ((fd.field_type() != ftype) &&
!       !(fd.field_type() == T_ARRAY && ftype == T_OBJECT)) {
      ReportJNIFatalError(thr, fatal_static_field_mismatch);
    }
  }
  
  static inline void
--- 254,12 ---
  
    /* check for proper field type */
    if (!id->find_local_field(&fd))
      ReportJNIFatalError(thr, fatal_static_field_not_found);
    if ((fd.field_type() != ftype) &&
!       !(fd.field_type() == T_ARRAY && ftype == T_OBJECT) &&
+       !(fd.field_type() == T_PRIMITIVE_OBJECT && ftype == T_OBJECT)) {
      ReportJNIFatalError(thr, fatal_static_field_mismatch);
    }
  }
  
  static inline void

*** 291,11 ***
    if (!InstanceKlass::cast(k_oop)->find_field_from_offset(offset,
                                                                false, &fd))
      ReportJNIFatalError(thr, fatal_instance_field_not_found);
  
    if ((fd.field_type() != ftype) &&
!       !(fd.field_type() == T_ARRAY && ftype == T_OBJECT)) {
      ReportJNIFatalError(thr, fatal_instance_field_mismatch);
    }
  }
  
  static inline void
--- 292,12 ---
    if (!InstanceKlass::cast(k_oop)->find_field_from_offset(offset,
                                                                false, &fd))
      ReportJNIFatalError(thr, fatal_instance_field_not_found);
  
    if ((fd.field_type() != ftype) &&
!       !(fd.field_type() == T_ARRAY && ftype == T_OBJECT) &&
+       !(fd.field_type() == T_PRIMITIVE_OBJECT && ftype == T_OBJECT)) {
      ReportJNIFatalError(thr, fatal_instance_field_mismatch);
    }
  }
  
  static inline void

*** 342,13 ***
      ReportJNIFatalError(thr, fatal_element_type_mismatch);
    }
  }
  
  static inline void
! check_is_obj_array(JavaThread* thr, jarray jArray) {
    arrayOop aOop = check_is_array(thr, jArray);
!   if (!aOop->is_objArray()) {
      ReportJNIFatalError(thr, fatal_object_array_expected);
    }
  }
  
  /*
--- 344,13 ---
      ReportJNIFatalError(thr, fatal_element_type_mismatch);
    }
  }
  
  static inline void
! check_is_obj_or_inline_array(JavaThread* thr, jarray jArray) {
    arrayOop aOop = check_is_array(thr, jArray);
!   if (!aOop->is_objArray() && !aOop->is_flatArray()) {
      ReportJNIFatalError(thr, fatal_object_array_expected);
    }
  }
  
  /*

*** 464,11 ***
    if (name == nullptr) return;  // implementation accepts null so just return
  
    size_t len = strlen(name);
  
    if (len >= 2 &&
!       name[0] == JVM_SIGNATURE_CLASS &&            // 'L'
        name[len-1] == JVM_SIGNATURE_ENDCLASS ) {    // ';'
      char msg[JVM_MAXPATHLEN];
      jio_snprintf(msg, JVM_MAXPATHLEN, "%s%s%s",
                   warn_bad_class_descriptor1, name, warn_bad_class_descriptor2);
      ReportJNIWarning(thr, msg);
--- 466,11 ---
    if (name == nullptr) return;  // implementation accepts null so just return
  
    size_t len = strlen(name);
  
    if (len >= 2 &&
!       (name[0] == JVM_SIGNATURE_CLASS || name[0] == JVM_SIGNATURE_PRIMITIVE_OBJECT) && // 'L' or 'Q'
        name[len-1] == JVM_SIGNATURE_ENDCLASS ) {    // ';'
      char msg[JVM_MAXPATHLEN];
      jio_snprintf(msg, JVM_MAXPATHLEN, "%s%s%s",
                   warn_bad_class_descriptor1, name, warn_bad_class_descriptor2);
      ReportJNIWarning(thr, msg);

*** 1604,11 ***
    checked_jni_GetObjectArrayElement(JNIEnv *env,
                                      jobjectArray array,
                                      jsize index))
      functionEnter(thr);
      IN_VM(
!       check_is_obj_array(thr, array);
      )
      jobject result = UNCHECKED()->GetObjectArrayElement(env,array,index);
      functionExit(thr);
      return result;
  JNI_END
--- 1606,11 ---
    checked_jni_GetObjectArrayElement(JNIEnv *env,
                                      jobjectArray array,
                                      jsize index))
      functionEnter(thr);
      IN_VM(
!       check_is_obj_or_inline_array(thr, array);
      )
      jobject result = UNCHECKED()->GetObjectArrayElement(env,array,index);
      functionExit(thr);
      return result;
  JNI_END

*** 1618,11 ***
                                      jobjectArray array,
                                      jsize index,
                                      jobject val))
      functionEnter(thr);
      IN_VM(
!       check_is_obj_array(thr, array);
      )
      UNCHECKED()->SetObjectArrayElement(env,array,index,val);
      functionExit(thr);
  JNI_END
  
--- 1620,11 ---
                                      jobjectArray array,
                                      jsize index,
                                      jobject val))
      functionEnter(thr);
      IN_VM(
!       check_is_obj_or_inline_array(thr, array);
      )
      UNCHECKED()->SetObjectArrayElement(env,array,index,val);
      functionExit(thr);
  JNI_END
  
< prev index next >