Mercurial > hg > truffle
comparison src/share/vm/prims/jvmtiExport.cpp @ 1121:98cd9901c161
6849968: 3/2 JVMTI tests fails on jdk5.0 with hs14
Summary: If a JVMTI agent asks for version 1.0, then it should get version 1.0 semantics.
Reviewed-by: dholmes, ohair
author | dcubed |
---|---|
date | Mon, 14 Dec 2009 10:05:36 -0700 |
parents | 2b4230d1e589 |
children | dcb15a6f342d 7fbf850d87b7 |
comparison
equal
deleted
inserted
replaced
1120:9127aa69352e | 1121:98cd9901c161 |
---|---|
317 // Functions needed by java.lang.instrument for starting up javaagent. | 317 // Functions needed by java.lang.instrument for starting up javaagent. |
318 /////////////////////////////////////////////////////////////// | 318 /////////////////////////////////////////////////////////////// |
319 | 319 |
320 jint | 320 jint |
321 JvmtiExport::get_jvmti_interface(JavaVM *jvm, void **penv, jint version) { | 321 JvmtiExport::get_jvmti_interface(JavaVM *jvm, void **penv, jint version) { |
322 /* To Do: add version checks */ | 322 // The JVMTI_VERSION_INTERFACE_JVMTI part of the version number |
323 // has already been validated in JNI GetEnv(). | |
324 int major, minor, micro; | |
325 | |
326 // micro version doesn't matter here (yet?) | |
327 decode_version_values(version, &major, &minor, µ); | |
328 switch (major) { | |
329 case 1: | |
330 switch (minor) { | |
331 case 0: // version 1.0.<micro> is recognized | |
332 case 1: // version 1.1.<micro> is recognized | |
333 break; | |
334 | |
335 default: | |
336 return JNI_EVERSION; // unsupported minor version number | |
337 } | |
338 break; | |
339 | |
340 default: | |
341 return JNI_EVERSION; // unsupported major version number | |
342 } | |
323 | 343 |
324 if (JvmtiEnv::get_phase() == JVMTI_PHASE_LIVE) { | 344 if (JvmtiEnv::get_phase() == JVMTI_PHASE_LIVE) { |
325 JavaThread* current_thread = (JavaThread*) ThreadLocalStorage::thread(); | 345 JavaThread* current_thread = (JavaThread*) ThreadLocalStorage::thread(); |
326 // transition code: native to VM | 346 // transition code: native to VM |
327 ThreadInVMfromNative __tiv(current_thread); | 347 ThreadInVMfromNative __tiv(current_thread); |
328 __ENTRY(jvmtiEnv*, JvmtiExport::get_jvmti_interface, current_thread) | 348 __ENTRY(jvmtiEnv*, JvmtiExport::get_jvmti_interface, current_thread) |
329 debug_only(VMNativeEntryWrapper __vew;) | 349 debug_only(VMNativeEntryWrapper __vew;) |
330 | 350 |
331 JvmtiEnv *jvmti_env = JvmtiEnv::create_a_jvmti(); | 351 JvmtiEnv *jvmti_env = JvmtiEnv::create_a_jvmti(version); |
332 *penv = jvmti_env->jvmti_external(); // actual type is jvmtiEnv* -- not to be confused with JvmtiEnv* | 352 *penv = jvmti_env->jvmti_external(); // actual type is jvmtiEnv* -- not to be confused with JvmtiEnv* |
333 return JNI_OK; | 353 return JNI_OK; |
334 | 354 |
335 } else if (JvmtiEnv::get_phase() == JVMTI_PHASE_ONLOAD) { | 355 } else if (JvmtiEnv::get_phase() == JVMTI_PHASE_ONLOAD) { |
336 // not live, no thread to transition | 356 // not live, no thread to transition |
337 JvmtiEnv *jvmti_env = JvmtiEnv::create_a_jvmti(); | 357 JvmtiEnv *jvmti_env = JvmtiEnv::create_a_jvmti(version); |
338 *penv = jvmti_env->jvmti_external(); // actual type is jvmtiEnv* -- not to be confused with JvmtiEnv* | 358 *penv = jvmti_env->jvmti_external(); // actual type is jvmtiEnv* -- not to be confused with JvmtiEnv* |
339 return JNI_OK; | 359 return JNI_OK; |
340 | 360 |
341 } else { | 361 } else { |
342 // Called at the wrong time | 362 // Called at the wrong time |
343 *penv = NULL; | 363 *penv = NULL; |
344 return JNI_EDETACHED; | 364 return JNI_EDETACHED; |
345 } | 365 } |
366 } | |
367 | |
368 | |
369 void | |
370 JvmtiExport::decode_version_values(jint version, int * major, int * minor, | |
371 int * micro) { | |
372 *major = (version & JVMTI_VERSION_MASK_MAJOR) >> JVMTI_VERSION_SHIFT_MAJOR; | |
373 *minor = (version & JVMTI_VERSION_MASK_MINOR) >> JVMTI_VERSION_SHIFT_MINOR; | |
374 *micro = (version & JVMTI_VERSION_MASK_MICRO) >> JVMTI_VERSION_SHIFT_MICRO; | |
346 } | 375 } |
347 | 376 |
348 void JvmtiExport::enter_primordial_phase() { | 377 void JvmtiExport::enter_primordial_phase() { |
349 JvmtiEnvBase::set_phase(JVMTI_PHASE_PRIMORDIAL); | 378 JvmtiEnvBase::set_phase(JVMTI_PHASE_PRIMORDIAL); |
350 } | 379 } |