Skip to content

Commit 640014d

Browse files
committed
Update patch
1 parent 60c57a7 commit 640014d

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/hotspot/share/prims/jvmti.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,10 @@ Agent_OnUnload_L(JavaVM *vm)</example>
688688
mechanism causes the unload (an unload mechanism is not specified in this document)
689689
or the library is (in effect) unloaded by the termination of the VM whether through
690690
normal termination or VM failure, including start-up failure.
691-
Uncontrolled shutdown is, of course, an exception to this rule.
691+
Uncontrolled shutdown and Agent Start-Up failure
692+
(<internallink id="onload"><code>Agent_OnLoad</code></internallink> and
693+
<internallink id="onattach"><code>Agent_OnAttach</code></internallink>) are, of course,
694+
an exception to this rule.
692695
Note the distinction between this function and the
693696
<eventlink id="VMDeath">VM Death event</eventlink>: for the VM Death event
694697
to be sent, the VM must have run at least to the point of initialization and a valid

src/hotspot/share/prims/jvmtiExport.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2733,6 +2733,9 @@ jint JvmtiExport::load_agent_library(const char *agent, const char *absParam,
27332733
if (result == JNI_OK) {
27342734
Arguments::add_loaded_agent(agent_lib);
27352735
} else {
2736+
if (!agent_lib->is_static_lib()) {
2737+
os::dll_unload(library);
2738+
}
27362739
delete agent_lib;
27372740
}
27382741

test/hotspot/jtreg/serviceability/dcmd/jvmti/AttachFailed/AttachReturnError.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
2525

2626
/*
2727
* @test
28-
* @bug 8165736
28+
* @bug 8165736 8252657
2929
* @library /test/lib
3030
* @run testng AttachReturnError
3131
*/
@@ -36,8 +36,13 @@ public void run(CommandExecutor executor) {
3636
String libpath = getSharedObjectPath("ReturnError");
3737
OutputAnalyzer output = null;
3838

39+
// Check return code
3940
output = executor.execute("JVMTI.agent_load " + libpath);
4041
output.shouldContain("return code: -1");
42+
43+
// Check loaded libraries
44+
output = executor.execute("VM.dynlibs");
45+
output.shouldNotContain(libpath);
4146
} catch (Exception e) {
4247
throw new RuntimeException(e);
4348
}

0 commit comments

Comments
 (0)