< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/SetNativeMethodPrefix002.cpp

Print this page
rev 52100 : 8212082: Remove the NSK_CPP_STUB macros for remaining vmTestbase/jvmti/[sS]*
Summary:
Reviewed-by:


  43 /* ============================================================================= */
  44 
  45 static jvmtiEnv *jvmti = NULL;
  46 
  47 /* ============================================================================= */
  48 
  49 JNIEXPORT int JNICALL
  50 Java_nsk_jvmti_SetNativeMethodPrefix_SetNativeMethodPrefix002_foo (
  51         JNIEnv *jni
  52         , jclass klass
  53     )
  54 {
  55     NSK_DISPLAY1(" >>> SetNativeMethodPrefix002.foo() (Library: SetNativeMethodPrefix002).\n", prefix);
  56     return FOO;
  57 }
  58 
  59 /* ============================================================================= */
  60 
  61 static jboolean setMethodPrefix (char *prefix)
  62 {
  63     if (!NSK_JVMTI_VERIFY(
  64                 NSK_CPP_STUB2(
  65                     SetNativeMethodPrefix
  66                     , jvmti
  67                     , prefix)
  68                 )
  69        )
  70         return JNI_FALSE;
  71 
  72     return JNI_TRUE;
  73 }
  74 
  75 /* ============================================================================= */
  76 
  77 /* Agent initialization procedure */
  78 #ifdef STATIC_BUILD
  79 JNIEXPORT jint JNICALL Agent_OnLoad_SetNativeMethodPrefix002(JavaVM *jvm, char *options, void *reserved) {
  80     return Agent_Initialize(jvm, options, reserved);
  81 }
  82 JNIEXPORT jint JNICALL Agent_OnAttach_SetNativeMethodPrefix002(JavaVM *jvm, char *options, void *reserved) {
  83     return Agent_Initialize(jvm, options, reserved);
  84 }
  85 JNIEXPORT jint JNI_OnLoad_SetNativeMethodPrefix002(JavaVM *jvm, char *options, void *reserved) {
  86     return JNI_VERSION_1_8;
  87 }
  88 #endif
  89 jint Agent_Initialize(JavaVM *vm, char *options, void *reserved)


  97        )
  98         return JNI_ERR;
  99 
 100     // Parse additional parameters
 101 
 102     // Specify native method prefix
 103     prefix = (char *)nsk_jvmti_findOptionValue("prefix");
 104     if (prefix != NULL) {
 105         NSK_DISPLAY1("Prefix: %s\n", prefix);
 106     }
 107 
 108     // Specify whether prefix should be applied or not
 109     apply = nsk_jvmti_findOptionIntValue("apply", 1);
 110 
 111     if (!NSK_VERIFY(
 112                 (jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL
 113                 )
 114        )
 115         return JNI_ERR;
 116 
 117     if (!NSK_JVMTI_VERIFY(
 118                 NSK_CPP_STUB2(
 119                     GetCapabilities
 120                     , jvmti
 121                     , &caps)
 122                 )
 123        )
 124         return JNI_ERR;
 125 
 126     // Register all necessary JVM capabilities
 127     caps.can_set_native_method_prefix = 1;
 128 
 129     if (!NSK_JVMTI_VERIFY(
 130                 NSK_CPP_STUB2(
 131                     AddCapabilities
 132                     , jvmti
 133                     , &caps)
 134                 )
 135        )
 136         return JNI_ERR;
 137 
 138 
 139     if (apply) {
 140         if (!setMethodPrefix(prefix)) {
 141             NSK_COMPLAIN0("Can't specify prefix for native method lookup.");
 142             return JNI_ERR;
 143         }
 144     }
 145 
 146     return JNI_OK;
 147 }
 148 
 149 }


  43 /* ============================================================================= */
  44 
  45 static jvmtiEnv *jvmti = NULL;
  46 
  47 /* ============================================================================= */
  48 
  49 JNIEXPORT int JNICALL
  50 Java_nsk_jvmti_SetNativeMethodPrefix_SetNativeMethodPrefix002_foo (
  51         JNIEnv *jni
  52         , jclass klass
  53     )
  54 {
  55     NSK_DISPLAY1(" >>> SetNativeMethodPrefix002.foo() (Library: SetNativeMethodPrefix002).\n", prefix);
  56     return FOO;
  57 }
  58 
  59 /* ============================================================================= */
  60 
  61 static jboolean setMethodPrefix (char *prefix)
  62 {
  63     if (!NSK_JVMTI_VERIFY(jvmti->SetNativeMethodPrefix(prefix)))






  64         return JNI_FALSE;
  65 
  66     return JNI_TRUE;
  67 }
  68 
  69 /* ============================================================================= */
  70 
  71 /* Agent initialization procedure */
  72 #ifdef STATIC_BUILD
  73 JNIEXPORT jint JNICALL Agent_OnLoad_SetNativeMethodPrefix002(JavaVM *jvm, char *options, void *reserved) {
  74     return Agent_Initialize(jvm, options, reserved);
  75 }
  76 JNIEXPORT jint JNICALL Agent_OnAttach_SetNativeMethodPrefix002(JavaVM *jvm, char *options, void *reserved) {
  77     return Agent_Initialize(jvm, options, reserved);
  78 }
  79 JNIEXPORT jint JNI_OnLoad_SetNativeMethodPrefix002(JavaVM *jvm, char *options, void *reserved) {
  80     return JNI_VERSION_1_8;
  81 }
  82 #endif
  83 jint Agent_Initialize(JavaVM *vm, char *options, void *reserved)


  91        )
  92         return JNI_ERR;
  93 
  94     // Parse additional parameters
  95 
  96     // Specify native method prefix
  97     prefix = (char *)nsk_jvmti_findOptionValue("prefix");
  98     if (prefix != NULL) {
  99         NSK_DISPLAY1("Prefix: %s\n", prefix);
 100     }
 101 
 102     // Specify whether prefix should be applied or not
 103     apply = nsk_jvmti_findOptionIntValue("apply", 1);
 104 
 105     if (!NSK_VERIFY(
 106                 (jvmti = nsk_jvmti_createJVMTIEnv(vm, reserved)) != NULL
 107                 )
 108        )
 109         return JNI_ERR;
 110 
 111     if (!NSK_JVMTI_VERIFY(jvmti->GetCapabilities(&caps)))






 112         return JNI_ERR;
 113 
 114     // Register all necessary JVM capabilities
 115     caps.can_set_native_method_prefix = 1;
 116 
 117     if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&caps)))






 118         return JNI_ERR;
 119 
 120 
 121     if (apply) {
 122         if (!setMethodPrefix(prefix)) {
 123             NSK_COMPLAIN0("Can't specify prefix for native method lookup.");
 124             return JNI_ERR;
 125         }
 126     }
 127 
 128     return JNI_OK;
 129 }
 130 
 131 }
< prev index next >