Mercurial > hg > truffle
comparison src/share/vm/prims/jvmtiEnv.cpp @ 1122:dcb15a6f342d
Merge
author | dcubed |
---|---|
date | Mon, 14 Dec 2009 13:26:29 -0700 |
parents | ea20d7ce26b0 98cd9901c161 |
children | 9b9c1ee9b3f6 75bd253e25dd |
comparison
equal
deleted
inserted
replaced
1119:547f81740344 | 1122:dcb15a6f342d |
---|---|
1 /* | 1 /* |
2 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
30 #define FIXLATER 0 // REMOVE this when completed. | 30 #define FIXLATER 0 // REMOVE this when completed. |
31 | 31 |
32 // FIXLATER: hook into JvmtiTrace | 32 // FIXLATER: hook into JvmtiTrace |
33 #define TraceJVMTICalls false | 33 #define TraceJVMTICalls false |
34 | 34 |
35 JvmtiEnv::JvmtiEnv() : JvmtiEnvBase() { | 35 JvmtiEnv::JvmtiEnv(jint version) : JvmtiEnvBase(version) { |
36 } | 36 } |
37 | 37 |
38 JvmtiEnv::~JvmtiEnv() { | 38 JvmtiEnv::~JvmtiEnv() { |
39 } | 39 } |
40 | 40 |
41 JvmtiEnv* | 41 JvmtiEnv* |
42 JvmtiEnv::create_a_jvmti() { | 42 JvmtiEnv::create_a_jvmti(jint version) { |
43 return new JvmtiEnv(); | 43 return new JvmtiEnv(version); |
44 } | 44 } |
45 | 45 |
46 // VM operation class to copy jni function table at safepoint. | 46 // VM operation class to copy jni function table at safepoint. |
47 // More than one java threads or jvmti agents may be reading/ | 47 // More than one java threads or jvmti agents may be reading/ |
48 // modifying jni function tables. To reduce the risk of bad | 48 // modifying jni function tables. To reduce the risk of bad |
409 JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) { | 409 JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) { |
410 jvmtiPhase phase = get_phase(); | 410 jvmtiPhase phase = get_phase(); |
411 if (phase == JVMTI_PHASE_ONLOAD) { | 411 if (phase == JVMTI_PHASE_ONLOAD) { |
412 Arguments::append_sysclasspath(segment); | 412 Arguments::append_sysclasspath(segment); |
413 return JVMTI_ERROR_NONE; | 413 return JVMTI_ERROR_NONE; |
414 } else { | 414 } else if (use_version_1_0_semantics()) { |
415 assert(phase == JVMTI_PHASE_LIVE, "sanity check"); | 415 // This JvmtiEnv requested version 1.0 semantics and this function |
416 // is only allowed in the ONLOAD phase in version 1.0 so we need to | |
417 // return an error here. | |
418 return JVMTI_ERROR_WRONG_PHASE; | |
419 } else if (phase == JVMTI_PHASE_LIVE) { | |
420 // The phase is checked by the wrapper that called this function, | |
421 // but this thread could be racing with the thread that is | |
422 // terminating the VM so we check one more time. | |
416 | 423 |
417 // create the zip entry | 424 // create the zip entry |
418 ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment); | 425 ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment); |
419 if (zip_entry == NULL) { | 426 if (zip_entry == NULL) { |
420 return JVMTI_ERROR_ILLEGAL_ARGUMENT; | 427 return JVMTI_ERROR_ILLEGAL_ARGUMENT; |
431 if (TraceClassLoading) { | 438 if (TraceClassLoading) { |
432 tty->print_cr("[Opened %s]", zip_entry->name()); | 439 tty->print_cr("[Opened %s]", zip_entry->name()); |
433 } | 440 } |
434 ClassLoader::add_to_list(zip_entry); | 441 ClassLoader::add_to_list(zip_entry); |
435 return JVMTI_ERROR_NONE; | 442 return JVMTI_ERROR_NONE; |
443 } else { | |
444 return JVMTI_ERROR_WRONG_PHASE; | |
436 } | 445 } |
437 | 446 |
438 } /* end AddToBootstrapClassLoaderSearch */ | 447 } /* end AddToBootstrapClassLoaderSearch */ |
439 | 448 |
440 | 449 |
449 p->append_value(segment); | 458 p->append_value(segment); |
450 break; | 459 break; |
451 } | 460 } |
452 } | 461 } |
453 return JVMTI_ERROR_NONE; | 462 return JVMTI_ERROR_NONE; |
454 } else { | 463 } else if (phase == JVMTI_PHASE_LIVE) { |
464 // The phase is checked by the wrapper that called this function, | |
465 // but this thread could be racing with the thread that is | |
466 // terminating the VM so we check one more time. | |
455 HandleMark hm; | 467 HandleMark hm; |
456 | |
457 assert(phase == JVMTI_PHASE_LIVE, "sanity check"); | |
458 | 468 |
459 // create the zip entry (which will open the zip file and hence | 469 // create the zip entry (which will open the zip file and hence |
460 // check that the segment is indeed a zip file). | 470 // check that the segment is indeed a zip file). |
461 ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment); | 471 ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment); |
462 if (zip_entry == NULL) { | 472 if (zip_entry == NULL) { |
502 } | 512 } |
503 } | 513 } |
504 } | 514 } |
505 | 515 |
506 return JVMTI_ERROR_NONE; | 516 return JVMTI_ERROR_NONE; |
517 } else { | |
518 return JVMTI_ERROR_WRONG_PHASE; | |
507 } | 519 } |
508 } /* end AddToSystemClassLoaderSearch */ | 520 } /* end AddToSystemClassLoaderSearch */ |
509 | 521 |
510 // | 522 // |
511 // General functions | 523 // General functions |
2861 | 2873 |
2862 // method_oop - pre-checked for validity, but may be NULL meaning obsolete method | 2874 // method_oop - pre-checked for validity, but may be NULL meaning obsolete method |
2863 // is_obsolete_ptr - pre-checked for NULL | 2875 // is_obsolete_ptr - pre-checked for NULL |
2864 jvmtiError | 2876 jvmtiError |
2865 JvmtiEnv::IsMethodObsolete(methodOop method_oop, jboolean* is_obsolete_ptr) { | 2877 JvmtiEnv::IsMethodObsolete(methodOop method_oop, jboolean* is_obsolete_ptr) { |
2878 if (use_version_1_0_semantics() && | |
2879 get_capabilities()->can_redefine_classes == 0) { | |
2880 // This JvmtiEnv requested version 1.0 semantics and this function | |
2881 // requires the can_redefine_classes capability in version 1.0 so | |
2882 // we need to return an error here. | |
2883 return JVMTI_ERROR_MUST_POSSESS_CAPABILITY; | |
2884 } | |
2885 | |
2866 if (method_oop == NULL || method_oop->is_obsolete()) { | 2886 if (method_oop == NULL || method_oop->is_obsolete()) { |
2867 *is_obsolete_ptr = true; | 2887 *is_obsolete_ptr = true; |
2868 } else { | 2888 } else { |
2869 *is_obsolete_ptr = false; | 2889 *is_obsolete_ptr = false; |
2870 } | 2890 } |