< prev index next >

src/hotspot/share/prims/jvmtiEnv.cpp

Print this page

 650   //
 651 
 652 // segment - pre-checked for null
 653 jvmtiError
 654 JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) {
 655   jvmtiPhase phase = get_phase();
 656   if (phase == JVMTI_PHASE_ONLOAD) {
 657     Arguments::append_sysclasspath(segment);
 658     return JVMTI_ERROR_NONE;
 659   } else if (use_version_1_0_semantics()) {
 660     // This JvmtiEnv requested version 1.0 semantics and this function
 661     // is only allowed in the ONLOAD phase in version 1.0 so we need to
 662     // return an error here.
 663     return JVMTI_ERROR_WRONG_PHASE;
 664   } else if (phase == JVMTI_PHASE_LIVE) {
 665     // The phase is checked by the wrapper that called this function,
 666     // but this thread could be racing with the thread that is
 667     // terminating the VM so we check one more time.
 668 
 669     // create the zip entry
 670     ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment, true);
 671     if (zip_entry == nullptr) {
 672       return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 673     }
 674 
 675     // add the jar file to the bootclasspath
 676     log_info(class, load)("opened: %s", zip_entry->name());
 677 #if INCLUDE_CDS
 678     ClassLoaderExt::append_boot_classpath(zip_entry);
 679 #else
 680     ClassLoader::add_to_boot_append_entries(zip_entry);
 681 #endif
 682     return JVMTI_ERROR_NONE;
 683   } else {
 684     return JVMTI_ERROR_WRONG_PHASE;
 685   }
 686 
 687 } /* end AddToBootstrapClassLoaderSearch */
 688 
 689 
 690 // segment - pre-checked for null

 692 JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
 693   jvmtiPhase phase = get_phase();
 694 
 695   if (phase == JVMTI_PHASE_ONLOAD) {
 696     for (SystemProperty* p = Arguments::system_properties(); p != nullptr; p = p->next()) {
 697       if (strcmp("java.class.path", p->key()) == 0) {
 698         p->append_value(segment);
 699         break;
 700       }
 701     }
 702     return JVMTI_ERROR_NONE;
 703   } else if (phase == JVMTI_PHASE_LIVE) {
 704     // The phase is checked by the wrapper that called this function,
 705     // but this thread could be racing with the thread that is
 706     // terminating the VM so we check one more time.
 707     JavaThread* THREAD = JavaThread::current(); // For exception macros.
 708     HandleMark hm(THREAD);
 709 
 710     // create the zip entry (which will open the zip file and hence
 711     // check that the segment is indeed a zip file).
 712     ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment, false);
 713     if (zip_entry == nullptr) {
 714       return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 715     }
 716     delete zip_entry;   // no longer needed
 717 
 718     Handle loader(THREAD, SystemDictionary::java_system_loader());
 719 
 720     // need the path as java.lang.String
 721     Handle path = java_lang_String::create_from_platform_dependent_str(segment, THREAD);
 722     if (HAS_PENDING_EXCEPTION) {
 723       CLEAR_PENDING_EXCEPTION;
 724       return JVMTI_ERROR_INTERNAL;
 725     }
 726 
 727     // Invoke the appendToClassPathForInstrumentation method - if the method
 728     // is not found it means the loader doesn't support adding to the class path
 729     // in the live phase.
 730     {
 731       JavaValue res(T_VOID);
 732       JavaCalls::call_special(&res,

 650   //
 651 
 652 // segment - pre-checked for null
 653 jvmtiError
 654 JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) {
 655   jvmtiPhase phase = get_phase();
 656   if (phase == JVMTI_PHASE_ONLOAD) {
 657     Arguments::append_sysclasspath(segment);
 658     return JVMTI_ERROR_NONE;
 659   } else if (use_version_1_0_semantics()) {
 660     // This JvmtiEnv requested version 1.0 semantics and this function
 661     // is only allowed in the ONLOAD phase in version 1.0 so we need to
 662     // return an error here.
 663     return JVMTI_ERROR_WRONG_PHASE;
 664   } else if (phase == JVMTI_PHASE_LIVE) {
 665     // The phase is checked by the wrapper that called this function,
 666     // but this thread could be racing with the thread that is
 667     // terminating the VM so we check one more time.
 668 
 669     // create the zip entry
 670     ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment);
 671     if (zip_entry == nullptr) {
 672       return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 673     }
 674 
 675     // add the jar file to the bootclasspath
 676     log_info(class, load)("opened: %s", zip_entry->name());
 677 #if INCLUDE_CDS
 678     ClassLoaderExt::append_boot_classpath(zip_entry);
 679 #else
 680     ClassLoader::add_to_boot_append_entries(zip_entry);
 681 #endif
 682     return JVMTI_ERROR_NONE;
 683   } else {
 684     return JVMTI_ERROR_WRONG_PHASE;
 685   }
 686 
 687 } /* end AddToBootstrapClassLoaderSearch */
 688 
 689 
 690 // segment - pre-checked for null

 692 JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
 693   jvmtiPhase phase = get_phase();
 694 
 695   if (phase == JVMTI_PHASE_ONLOAD) {
 696     for (SystemProperty* p = Arguments::system_properties(); p != nullptr; p = p->next()) {
 697       if (strcmp("java.class.path", p->key()) == 0) {
 698         p->append_value(segment);
 699         break;
 700       }
 701     }
 702     return JVMTI_ERROR_NONE;
 703   } else if (phase == JVMTI_PHASE_LIVE) {
 704     // The phase is checked by the wrapper that called this function,
 705     // but this thread could be racing with the thread that is
 706     // terminating the VM so we check one more time.
 707     JavaThread* THREAD = JavaThread::current(); // For exception macros.
 708     HandleMark hm(THREAD);
 709 
 710     // create the zip entry (which will open the zip file and hence
 711     // check that the segment is indeed a zip file).
 712     ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment);
 713     if (zip_entry == nullptr) {
 714       return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 715     }
 716     delete zip_entry;   // no longer needed
 717 
 718     Handle loader(THREAD, SystemDictionary::java_system_loader());
 719 
 720     // need the path as java.lang.String
 721     Handle path = java_lang_String::create_from_platform_dependent_str(segment, THREAD);
 722     if (HAS_PENDING_EXCEPTION) {
 723       CLEAR_PENDING_EXCEPTION;
 724       return JVMTI_ERROR_INTERNAL;
 725     }
 726 
 727     // Invoke the appendToClassPathForInstrumentation method - if the method
 728     // is not found it means the loader doesn't support adding to the class path
 729     // in the live phase.
 730     {
 731       JavaValue res(T_VOID);
 732       JavaCalls::call_special(&res,
< prev index next >