src/share/vm/prims/jvmtiEnvBase.cpp

changeset 1046
2f716c0acb64
parent 1044
ea20d7ce26b0
child 1253
b109e761e927
     1.1 --- a/src/share/vm/prims/jvmtiEnvBase.cpp	Mon Mar 02 14:03:03 2009 -0700
     1.2 +++ b/src/share/vm/prims/jvmtiEnvBase.cpp	Mon Mar 02 14:05:07 2009 -0700
     1.3 @@ -94,6 +94,35 @@
     1.4  }
     1.5  
     1.6  
     1.7 +bool
     1.8 +JvmtiEnvBase::is_valid() {
     1.9 +  jint value = 0;
    1.10 +
    1.11 +  // This object might not be a JvmtiEnvBase so we can't assume
    1.12 +  // the _magic field is properly aligned. Get the value in a safe
    1.13 +  // way and then check against JVMTI_MAGIC.
    1.14 +
    1.15 +  switch (sizeof(_magic)) {
    1.16 +  case 2:
    1.17 +    value = Bytes::get_native_u2((address)&_magic);
    1.18 +    break;
    1.19 +
    1.20 +  case 4:
    1.21 +    value = Bytes::get_native_u4((address)&_magic);
    1.22 +    break;
    1.23 +
    1.24 +  case 8:
    1.25 +    value = Bytes::get_native_u8((address)&_magic);
    1.26 +    break;
    1.27 +
    1.28 +  default:
    1.29 +    guarantee(false, "_magic field is an unexpected size");
    1.30 +  }
    1.31 +
    1.32 +  return value == JVMTI_MAGIC;
    1.33 +}
    1.34 +
    1.35 +
    1.36  JvmtiEnvBase::JvmtiEnvBase() : _env_event_enable() {
    1.37    _env_local_storage = NULL;
    1.38    _tag_map = NULL;

mercurial