class jfieldIDWorkaround: AllStatic { // This workaround is because JVMTI doesn't have distinct entry points // for methods that use static jfieldIDs and instance jfieldIDs. // The workaround is to steal a low-order bit: // a 1 means the jfieldID is an instance jfieldID, // and the rest of the word is the offset of the field. // a 0 means the jfieldID is a static jfieldID, // and the rest of the word is the JNIid*. // // Another low-order bit is used to mark if an instance field // is accompanied by an indication of which class it applies to. // // Bit-format of a jfieldID (most significant first): // address:30 instance=0:1 checked=0:1 // offset:30 instance=1:1 checked=0:1 // klass:23 offset:7 instance=1:1 checked=1:1 // // If the offset does not fit in 7 bits, or if the fieldID is // not checked, then the checked bit is zero and the rest of // the word (30 bits) contains only the offset. // private:
enum {
checked_bits = 1,
instance_bits = 1,
address_bits = BitsPerWord - checked_bits - instance_bits,
static jfieldID to_instance_jfieldID(Klass* k, int offset) {
intptr_t as_uint = ((offset & large_offset_mask) << offset_shift) | instance_mask_in_place;
if (VerifyJNIFields) {
as_uint |= encode_klass_hash(k, offset);
}
jfieldID result = (jfieldID) as_uint; #ifndef ASSERT // always verify in debug mode; switchable in anything else
if (VerifyJNIFields) #endif// ASSERT
{
verify_instance_jfieldID(k, result);
}
assert(raw_instance_offset(result) == (offset & large_offset_mask), "extract right offset"); return result;
}
static intptr_t from_instance_jfieldID(Klass* k, jfieldID id) { #ifndef ASSERT // always verify in debug mode; switchable in anything else
if (VerifyJNIFields) #endif// ASSERT
{
verify_instance_jfieldID(k, id);
} return raw_instance_offset(id);
}
static jfieldID to_static_jfieldID(JNIid* id) {
assert(id->is_static_field_id(), "from_JNIid, but not static field id");
jfieldID result = (jfieldID) id;
assert(from_static_jfieldID(result) == id, "must produce the same static id"); return result;
}
static JNIid* from_static_jfieldID(jfieldID id) {
assert(jfieldIDWorkaround::is_static_jfieldID(id), "to_JNIid, but not static jfieldID");
JNIid* result = (JNIid*) id;
assert(result->is_static_field_id(), "to_JNIid, but not static field id"); return result;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.