1 /* |
1 /* |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. 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. |
3737 // Try to load the agent from the standard dll directory |
3737 // Try to load the agent from the standard dll directory |
3738 if (os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), |
3738 if (os::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), |
3739 name)) { |
3739 name)) { |
3740 library = os::dll_load(buffer, ebuf, sizeof ebuf); |
3740 library = os::dll_load(buffer, ebuf, sizeof ebuf); |
3741 } |
3741 } |
3742 #ifdef KERNEL |
|
3743 // Download instrument dll |
|
3744 if (library == NULL && strcmp(name, "instrument") == 0) { |
|
3745 char *props = Arguments::get_kernel_properties(); |
|
3746 char *home = Arguments::get_java_home(); |
|
3747 const char *fmt = "%s/bin/java %s -Dkernel.background.download=false" |
|
3748 " sun.jkernel.DownloadManager -download client_jvm"; |
|
3749 size_t length = strlen(props) + strlen(home) + strlen(fmt) + 1; |
|
3750 char *cmd = NEW_C_HEAP_ARRAY(char, length, mtThread); |
|
3751 jio_snprintf(cmd, length, fmt, home, props); |
|
3752 int status = os::fork_and_exec(cmd); |
|
3753 FreeHeap(props); |
|
3754 if (status == -1) { |
|
3755 warning(cmd); |
|
3756 vm_exit_during_initialization("fork_and_exec failed: %s", |
|
3757 strerror(errno)); |
|
3758 } |
|
3759 FREE_C_HEAP_ARRAY(char, cmd, mtThread); |
|
3760 // when this comes back the instrument.dll should be where it belongs. |
|
3761 library = os::dll_load(buffer, ebuf, sizeof ebuf); |
|
3762 } |
|
3763 #endif // KERNEL |
|
3764 if (library == NULL) { // Try the local directory |
3742 if (library == NULL) { // Try the local directory |
3765 char ns[1] = {0}; |
3743 char ns[1] = {0}; |
3766 if (os::dll_build_name(buffer, sizeof(buffer), ns, name)) { |
3744 if (os::dll_build_name(buffer, sizeof(buffer), ns, name)) { |
3767 library = os::dll_load(buffer, ebuf, sizeof ebuf); |
3745 library = os::dll_load(buffer, ebuf, sizeof ebuf); |
3768 } |
3746 } |