comparison src/share/vm/prims/jni.cpp @ 3938:e6b1331a51d2

7086585: make Java field injection more flexible Reviewed-by: jrose, twisti, kvn, coleenp
author never
date Sat, 10 Sep 2011 17:29:02 -0700
parents 8a4fc2990229
children f08d439fab8c
comparison
equal deleted inserted replaced
3937:c565834fb592 3938:e6b1331a51d2
490 // Make sure class is initialized before handing id's out to fields 490 // Make sure class is initialized before handing id's out to fields
491 Klass::cast(k1())->initialize(CHECK_NULL); 491 Klass::cast(k1())->initialize(CHECK_NULL);
492 492
493 // First check if this is a static field 493 // First check if this is a static field
494 if (modifiers & JVM_ACC_STATIC) { 494 if (modifiers & JVM_ACC_STATIC) {
495 intptr_t offset = instanceKlass::cast(k1())->offset_from_fields( slot ); 495 intptr_t offset = instanceKlass::cast(k1())->field_offset( slot );
496 JNIid* id = instanceKlass::cast(k1())->jni_id_for(offset); 496 JNIid* id = instanceKlass::cast(k1())->jni_id_for(offset);
497 assert(id != NULL, "corrupt Field object"); 497 assert(id != NULL, "corrupt Field object");
498 debug_only(id->set_is_static_field_id();) 498 debug_only(id->set_is_static_field_id();)
499 // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the klassOop 499 // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the klassOop
500 ret = jfieldIDWorkaround::to_static_jfieldID(id); 500 ret = jfieldIDWorkaround::to_static_jfieldID(id);
502 } 502 }
503 503
504 // The slot is the index of the field description in the field-array 504 // The slot is the index of the field description in the field-array
505 // The jfieldID is the offset of the field within the object 505 // The jfieldID is the offset of the field within the object
506 // It may also have hash bits for k, if VerifyJNIFields is turned on. 506 // It may also have hash bits for k, if VerifyJNIFields is turned on.
507 intptr_t offset = instanceKlass::cast(k1())->offset_from_fields( slot ); 507 intptr_t offset = instanceKlass::cast(k1())->field_offset( slot );
508 assert(instanceKlass::cast(k1())->contains_field_offset(offset), "stay within object"); 508 assert(instanceKlass::cast(k1())->contains_field_offset(offset), "stay within object");
509 ret = jfieldIDWorkaround::to_instance_jfieldID(k1(), offset); 509 ret = jfieldIDWorkaround::to_instance_jfieldID(k1(), offset);
510 return ret; 510 return ret;
511 JNI_END 511 JNI_END
512 512