< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/aod/VirtualMachine/VirtualMachine09/agent00.cpp

Print this page
rev 52233 : 8212884: Remove the assignments in ifs for vmTestbase/[a-s]
Summary:
Reviewed-by:


  31 /*
  32  * Test checks following spec clause: "Agent_OnAttach function is invoked even if the agent library was loaded
  33  * prior to invoking this method"
  34  *
  35  * This agent is loaded as static agent via 'agentlib:' VM option and also dynamically attached, so this agent
  36  * has both Agent_OnLoad and Agent_OnAttach.
  37  */
  38 
  39 JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *optionsString, void *reserved) {
  40     // can't use NSK_DISPLAY since needed for nsk_ functions initialization isn't done here
  41     printf("Agent_OnLoad: agent is loaded\n");
  42     fflush(stdout);
  43     return JNI_OK;
  44 }
  45 
  46 JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) {
  47     JNIEnv* jni = NULL;
  48     Options* options = NULL;
  49     const char* agentName;
  50 
  51     if (!NSK_VERIFY((options = (Options*) nsk_aod_createOptions(optionsString)) != NULL))

  52         return JNI_ERR;
  53 
  54     agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
  55 
  56     if ((jni = (JNIEnv*) nsk_aod_createJNIEnv(vm)) == NULL)

  57         return JNI_ERR;
  58 
  59     NSK_DISPLAY1("%s: initialization was done\n", agentName);
  60 
  61     if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
  62         return JNI_ERR;
  63 
  64     nsk_aod_agentFinished(jni, agentName, 1);
  65 
  66     return JNI_OK;
  67 }
  68 
  69 }


  31 /*
  32  * Test checks following spec clause: "Agent_OnAttach function is invoked even if the agent library was loaded
  33  * prior to invoking this method"
  34  *
  35  * This agent is loaded as static agent via 'agentlib:' VM option and also dynamically attached, so this agent
  36  * has both Agent_OnLoad and Agent_OnAttach.
  37  */
  38 
  39 JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *vm, char *optionsString, void *reserved) {
  40     // can't use NSK_DISPLAY since needed for nsk_ functions initialization isn't done here
  41     printf("Agent_OnLoad: agent is loaded\n");
  42     fflush(stdout);
  43     return JNI_OK;
  44 }
  45 
  46 JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *vm, char *optionsString, void *reserved) {
  47     JNIEnv* jni = NULL;
  48     Options* options = NULL;
  49     const char* agentName;
  50 
  51     options = (Options*) nsk_aod_createOptions(optionsString);
  52     if (!NSK_VERIFY(options != NULL))
  53         return JNI_ERR;
  54 
  55     agentName = nsk_aod_getOptionValue(options, NSK_AOD_AGENT_NAME_OPTION);
  56 
  57     jni = (JNIEnv*) nsk_aod_createJNIEnv(vm);
  58     if (jni == NULL)
  59         return JNI_ERR;
  60 
  61     NSK_DISPLAY1("%s: initialization was done\n", agentName);
  62 
  63     if (!NSK_VERIFY(nsk_aod_agentLoaded(jni, agentName)))
  64         return JNI_ERR;
  65 
  66     nsk_aod_agentFinished(jni, agentName, 1);
  67 
  68     return JNI_OK;
  69 }
  70 
  71 }
< prev index next >