2727#include " cds/cds_globals.hpp"
2828#include " cds/cdsConfig.hpp"
2929#include " jni.h"
30- #include " jvm.h"
3130#include " jvm_io.h"
3231#include " jvmtifiles/jvmtiEnv.hpp"
3332#include " prims/jvmtiEnvBase.hpp"
@@ -268,10 +267,10 @@ static void assert_preload(const JvmtiAgent* agent) {
268267// For statically linked agents we can't rely on os_lib == nullptr because
269268// statically linked agents could have a handle of RTLD_DEFAULT which == 0 on some platforms.
270269// If this function returns true, then agent->is_static_lib() && agent->is_loaded().
271- static bool load_agent_from_executable (JvmtiAgent* agent, const char * on_load_symbols[], size_t num_symbol_entries ) {
270+ static bool load_agent_from_executable (JvmtiAgent* agent, const char * on_load_symbol ) {
272271 DEBUG_ONLY (assert_preload (agent);)
273- assert (on_load_symbols != nullptr , " invariant" );
274- return os::find_builtin_agent (agent, &on_load_symbols[ 0 ], num_symbol_entries );
272+ assert (on_load_symbol != nullptr , " invariant" );
273+ return os::find_builtin_agent (agent, on_load_symbol );
275274}
276275
277276// Load the library from the absolute path of the agent, if available.
@@ -310,7 +309,7 @@ static void* load_agent_from_relative_path(JvmtiAgent* agent, bool vm_exit_on_er
310309}
311310
312311// For absolute and relative paths.
313- static void * load_library (JvmtiAgent* agent, const char * on_symbols[], size_t num_symbol_entries, bool vm_exit_on_error) {
312+ static void * load_library (JvmtiAgent* agent, bool vm_exit_on_error) {
314313 return agent->is_absolute_path () ? load_agent_from_absolute_path (agent, vm_exit_on_error) :
315314 load_agent_from_relative_path (agent, vm_exit_on_error);
316315}
@@ -321,30 +320,27 @@ extern "C" {
321320}
322321
323322// Find the OnLoad entry point for -agentlib: -agentpath: -Xrun agents.
324- // num_symbol_entries must be passed-in since only the caller knows the number of symbols in the array.
325- static OnLoadEntry_t lookup_On_Load_entry_point (JvmtiAgent* agent, const char * on_load_symbols[], size_t num_symbol_entries) {
323+ static OnLoadEntry_t lookup_On_Load_entry_point (JvmtiAgent* agent, const char * on_load_symbol) {
326324 assert (agent != nullptr , " invariant" );
327325 if (!agent->is_loaded ()) {
328- if (!load_agent_from_executable (agent, on_load_symbols, num_symbol_entries )) {
329- void * const library = load_library (agent, on_load_symbols, num_symbol_entries, /* vm exit on error */ true );
326+ if (!load_agent_from_executable (agent, on_load_symbol )) {
327+ void * const library = load_library (agent, /* vm exit on error */ true );
330328 assert (library != nullptr , " invariant" );
331329 agent->set_os_lib (library);
332330 agent->set_loaded ();
333331 }
334332 }
335333 assert (agent->is_loaded (), " invariant" );
336334 // Find the OnLoad function.
337- return CAST_TO_FN_PTR (OnLoadEntry_t, os::find_agent_function (agent, false , on_load_symbols, num_symbol_entries ));
335+ return CAST_TO_FN_PTR (OnLoadEntry_t, os::find_agent_function (agent, false , on_load_symbol ));
338336}
339337
340338static OnLoadEntry_t lookup_JVM_OnLoad_entry_point (JvmtiAgent* lib) {
341- const char * on_load_symbols[] = JVM_ONLOAD_SYMBOLS;
342- return lookup_On_Load_entry_point (lib, on_load_symbols, sizeof (on_load_symbols) / sizeof (char *));
339+ return lookup_On_Load_entry_point (lib, " JVM_OnLoad" );
343340}
344341
345342static OnLoadEntry_t lookup_Agent_OnLoad_entry_point (JvmtiAgent* agent) {
346- const char * on_load_symbols[] = AGENT_ONLOAD_SYMBOLS;
347- return lookup_On_Load_entry_point (agent, on_load_symbols, sizeof (on_load_symbols) / sizeof (char *));
343+ return lookup_On_Load_entry_point (agent, " Agent_OnLoad" );
348344}
349345
350346void JvmtiAgent::convert_xrun_agent () {
@@ -499,14 +495,13 @@ static bool invoke_Agent_OnAttach(JvmtiAgent* agent, outputStream* st) {
499495 assert (agent->is_dynamic (), " invariant" );
500496 assert (st != nullptr , " invariant" );
501497 assert (JvmtiEnvBase::get_phase () == JVMTI_PHASE_LIVE, " not in live phase!" );
502- const char * on_attach_symbols[] = AGENT_ONATTACH_SYMBOLS;
503- const size_t num_symbol_entries = ARRAY_SIZE (on_attach_symbols);
498+ const char * on_attach_symbol = " Agent_OnAttach" ;
504499 void * library = nullptr ;
505500 bool previously_loaded;
506- if (load_agent_from_executable (agent, &on_attach_symbols[ 0 ], num_symbol_entries )) {
501+ if (load_agent_from_executable (agent, on_attach_symbol )) {
507502 previously_loaded = JvmtiAgentList::is_static_lib_loaded (agent->name ());
508503 } else {
509- library = load_library (agent, &on_attach_symbols[ 0 ], num_symbol_entries, /* vm_exit_on_error */ false );
504+ library = load_library (agent, /* vm_exit_on_error */ false );
510505 if (library == nullptr ) {
511506 st->print_cr (" %s was not loaded." , agent->name ());
512507 if (*ebuf != ' \0 ' ) {
@@ -531,10 +526,10 @@ static bool invoke_Agent_OnAttach(JvmtiAgent* agent, outputStream* st) {
531526 assert (agent->is_loaded (), " invariant" );
532527 // The library was loaded so we attempt to lookup and invoke the Agent_OnAttach function.
533528 OnAttachEntry_t on_attach_entry = CAST_TO_FN_PTR (OnAttachEntry_t,
534- os::find_agent_function (agent, false , &on_attach_symbols[ 0 ], num_symbol_entries ));
529+ os::find_agent_function (agent, false , on_attach_symbol ));
535530
536531 if (on_attach_entry == nullptr ) {
537- st->print_cr (" %s is not available in %s" , on_attach_symbols[ 0 ] , agent->name ());
532+ st->print_cr (" %s is not available in %s" , on_attach_symbol , agent->name ());
538533 unload_library (agent, library);
539534 return false ;
540535 }
@@ -629,10 +624,10 @@ extern "C" {
629624}
630625
631626void JvmtiAgent::unload () {
632- const char * on_unload_symbols[] = AGENT_ONUNLOAD_SYMBOLS ;
627+ const char * on_unload_symbol = " Agent_OnUnload " ;
633628 // Find the Agent_OnUnload function.
634629 Agent_OnUnload_t unload_entry = CAST_TO_FN_PTR (Agent_OnUnload_t,
635- os::find_agent_function (this , false , &on_unload_symbols[ 0 ], ARRAY_SIZE (on_unload_symbols) ));
630+ os::find_agent_function (this , false , on_unload_symbol ));
636631 if (unload_entry != nullptr ) {
637632 // Invoke the Agent_OnUnload function
638633 JavaThread* thread = JavaThread::current ();
0 commit comments