JDK 8 JVMTI spec. 1.2.3 (http://download.java.net/jdk8/docs/platform/jvmti/jvmti.html) states:
Agent Start-Up (Live phase)
...
If an agent is started during the live phase then its agent library must export a start-up function with the following prototype:
JNIEXPORT jint JNICALL
Agent_OnAttach(JavaVM* vm, char *options, void *reserved)
Or for a statically linked agent named 'L':
JNIEXPORT jint JNICALL
Agent_OnAttach_L(JavaVM* vm, char *options, void *reserved)
The VM will start the agent by calling this function.
....
According to this assertion the VM will never call Agent_OnAttach_L if the function exists and the agent library is dynamically linked.
This issue causes a failure of 366 JCK 8 tests (JCK-7301996)
Error log is:
--''--
Successfully attached to JVM with id: 15050
Native agent successfully loaded: name=jckjvmti opts=ascl00101
Agent_OnAttach_jckjvmti entry was unexpectedly invoked
--''--
Source file that returns "failed" status is JCK-runtime-8/src/javasoft/sqe/jck/lib/jvmti/Agent.java
Appropriate code snippet is:
if (isOnAttachMode) {
if (isJckjvmtiStaticallyLinked) {
if (!isAgentOnAttachForJckJvmtiInvoked()) {
out.println("Agent_OnAttach_jckjvmti entry was not invoked as expected\n");
status = STAT_FAILED;
return false;
}
if (isAgentOnAttachInvoked()) {
out.println("Agent_OnAttach entry was unexpectedly invoked");
status = STAT_FAILED;
return false;
}
} else {
if (!isAgentOnAttachInvoked()) {
out.println("Agent_OnAttach entry was not invoked as expected");
status = STAT_FAILED;
return false;
}
if (isAgentOnAttachForJckJvmtiInvoked()) {
out.println("Agent_OnAttach_jckjvmti entry was unexpectedly invoked");
status = STAT_FAILED;
return false;
}
}
if (isAgentOnLoadInvoked()) {
out.println("Agent_OnLoad entry was unexpectedly invoked");
status = STAT_FAILED;
return false;
}
if (isAgentOnLoadForJckJvmtiInvoked()) {
out.println("Agent_OnLoad_jckjvmti entry was unexpectedly invoked\n");
status = STAT_FAILED;
return false;
}
}
Note: This issue only happens on Mac OS X (10.9.1)