< prev index next >

src/share/vm/prims/jvmtiEnv.cpp

Print this page




 450     return JVMTI_ERROR_NONE;
 451   } else if (use_version_1_0_semantics()) {
 452     // This JvmtiEnv requested version 1.0 semantics and this function
 453     // is only allowed in the ONLOAD phase in version 1.0 so we need to
 454     // return an error here.
 455     return JVMTI_ERROR_WRONG_PHASE;
 456   } else if (phase == JVMTI_PHASE_LIVE) {
 457     // The phase is checked by the wrapper that called this function,
 458     // but this thread could be racing with the thread that is
 459     // terminating the VM so we check one more time.
 460 
 461     // create the zip entry
 462     ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment);
 463     if (zip_entry == NULL) {
 464       return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 465     }
 466 
 467     // lock the loader
 468     Thread* thread = Thread::current();
 469     HandleMark hm;
 470     Handle loader_lock = Handle(thread, SystemDictionary::system_loader_lock());
 471 
 472     ObjectLocker ol(loader_lock, thread);
 473 
 474     // add the jar file to the bootclasspath
 475     if (TraceClassLoading) {
 476       tty->print_cr("[Opened %s]", zip_entry->name());
 477     }
 478     ClassLoaderExt::append_boot_classpath(zip_entry);
 479     return JVMTI_ERROR_NONE;
 480   } else {
 481     return JVMTI_ERROR_WRONG_PHASE;
 482   }
 483 
 484 } /* end AddToBootstrapClassLoaderSearch */
 485 
 486 
 487 // segment - pre-checked for NULL
 488 jvmtiError
 489 JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
 490   jvmtiPhase phase = get_phase();


 496         break;
 497       }
 498     }
 499     return JVMTI_ERROR_NONE;
 500   } else if (phase == JVMTI_PHASE_LIVE) {
 501     // The phase is checked by the wrapper that called this function,
 502     // but this thread could be racing with the thread that is
 503     // terminating the VM so we check one more time.
 504     HandleMark hm;
 505 
 506     // create the zip entry (which will open the zip file and hence
 507     // check that the segment is indeed a zip file).
 508     ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment);
 509     if (zip_entry == NULL) {
 510       return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 511     }
 512     delete zip_entry;   // no longer needed
 513 
 514     // lock the loader
 515     Thread* THREAD = Thread::current();
 516     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
 517 
 518     ObjectLocker ol(loader, THREAD);
 519 
 520     // need the path as java.lang.String
 521     Handle path = java_lang_String::create_from_platform_dependent_str(segment, THREAD);
 522     if (HAS_PENDING_EXCEPTION) {
 523       CLEAR_PENDING_EXCEPTION;
 524       return JVMTI_ERROR_INTERNAL;
 525     }
 526 
 527     instanceKlassHandle loader_ik(THREAD, loader->klass());
 528 
 529     // Invoke the appendToClassPathForInstrumentation method - if the method
 530     // is not found it means the loader doesn't support adding to the class path
 531     // in the live phase.
 532     {
 533       JavaValue res(T_VOID);
 534       JavaCalls::call_special(&res,
 535                               loader,
 536                               loader_ik,




 450     return JVMTI_ERROR_NONE;
 451   } else if (use_version_1_0_semantics()) {
 452     // This JvmtiEnv requested version 1.0 semantics and this function
 453     // is only allowed in the ONLOAD phase in version 1.0 so we need to
 454     // return an error here.
 455     return JVMTI_ERROR_WRONG_PHASE;
 456   } else if (phase == JVMTI_PHASE_LIVE) {
 457     // The phase is checked by the wrapper that called this function,
 458     // but this thread could be racing with the thread that is
 459     // terminating the VM so we check one more time.
 460 
 461     // create the zip entry
 462     ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment);
 463     if (zip_entry == NULL) {
 464       return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 465     }
 466 
 467     // lock the loader
 468     Thread* thread = Thread::current();
 469     HandleMark hm;
 470     Handle loader_lock = Handle(thread, oopDesc::bs()->write_barrier(SystemDictionary::system_loader_lock()));
 471 
 472     ObjectLocker ol(loader_lock, thread);
 473 
 474     // add the jar file to the bootclasspath
 475     if (TraceClassLoading) {
 476       tty->print_cr("[Opened %s]", zip_entry->name());
 477     }
 478     ClassLoaderExt::append_boot_classpath(zip_entry);
 479     return JVMTI_ERROR_NONE;
 480   } else {
 481     return JVMTI_ERROR_WRONG_PHASE;
 482   }
 483 
 484 } /* end AddToBootstrapClassLoaderSearch */
 485 
 486 
 487 // segment - pre-checked for NULL
 488 jvmtiError
 489 JvmtiEnv::AddToSystemClassLoaderSearch(const char* segment) {
 490   jvmtiPhase phase = get_phase();


 496         break;
 497       }
 498     }
 499     return JVMTI_ERROR_NONE;
 500   } else if (phase == JVMTI_PHASE_LIVE) {
 501     // The phase is checked by the wrapper that called this function,
 502     // but this thread could be racing with the thread that is
 503     // terminating the VM so we check one more time.
 504     HandleMark hm;
 505 
 506     // create the zip entry (which will open the zip file and hence
 507     // check that the segment is indeed a zip file).
 508     ClassPathZipEntry* zip_entry = ClassLoader::create_class_path_zip_entry(segment);
 509     if (zip_entry == NULL) {
 510       return JVMTI_ERROR_ILLEGAL_ARGUMENT;
 511     }
 512     delete zip_entry;   // no longer needed
 513 
 514     // lock the loader
 515     Thread* THREAD = Thread::current();
 516     Handle loader = Handle(THREAD, oopDesc::bs()->write_barrier(SystemDictionary::java_system_loader()));
 517 
 518     ObjectLocker ol(loader, THREAD);
 519 
 520     // need the path as java.lang.String
 521     Handle path = java_lang_String::create_from_platform_dependent_str(segment, THREAD);
 522     if (HAS_PENDING_EXCEPTION) {
 523       CLEAR_PENDING_EXCEPTION;
 524       return JVMTI_ERROR_INTERNAL;
 525     }
 526 
 527     instanceKlassHandle loader_ik(THREAD, loader->klass());
 528 
 529     // Invoke the appendToClassPathForInstrumentation method - if the method
 530     // is not found it means the loader doesn't support adding to the class path
 531     // in the live phase.
 532     {
 533       JavaValue res(T_VOID);
 534       JavaCalls::call_special(&res,
 535                               loader,
 536                               loader_ik,


< prev index next >