< prev index next >

src/hotspot/share/prims/jvmtiEnv.cpp

Print this page

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

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

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

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