hotspot/test/serviceability/jvmti/GetNamedModule/libGetNamedModuleTest.c
changeset 44520 0553e129e0ec
parent 44330 aaa5ce0d9d01
equal deleted inserted replaced
44471:7e8e5ceecf99 44520:0553e129e0ec
    45 
    45 
    46 #define PASSED 0
    46 #define PASSED 0
    47 #define FAILED 2
    47 #define FAILED 2
    48 
    48 
    49 static const char *EXC_CNAME = "java/lang/Exception";
    49 static const char *EXC_CNAME = "java/lang/Exception";
    50 static const char* MOD_CNAME = "Ljava/lang/reflect/Module;";
    50 static const char* MOD_CNAME = "Ljava/lang/Module;";
    51 
    51 
    52 static jvmtiEnv *jvmti = NULL;
    52 static jvmtiEnv *jvmti = NULL;
    53 static jint result = PASSED;
    53 static jint result = PASSED;
    54 static jboolean printdump = JNI_FALSE;
    54 static jboolean printdump = JNI_FALSE;
    55 
    55 
   113     }
   113     }
   114     return loader;
   114     return loader;
   115 }
   115 }
   116 
   116 
   117 static
   117 static
   118 jclass jlrM(JNIEnv *env) {
   118 jclass jlM(JNIEnv *env) {
   119     jclass cls = NULL;
   119     jclass cls = NULL;
   120 
   120 
   121     cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, MOD_CNAME));
   121     cls = JNI_ENV_PTR(env)->FindClass(JNI_ENV_ARG(env, MOD_CNAME));
   122     if (cls == NULL) {
   122     if (cls == NULL) {
   123         printf("    Error in JNI FindClass: %s\n", MOD_CNAME);
   123         printf("    Error in JNI FindClass: %s\n", MOD_CNAME);
   140 jobject get_module_loader(JNIEnv *env, jobject module) {
   140 jobject get_module_loader(JNIEnv *env, jobject module) {
   141     static jmethodID cl_method = NULL;
   141     static jmethodID cl_method = NULL;
   142     jobject loader = NULL;
   142     jobject loader = NULL;
   143 
   143 
   144     if (cl_method == NULL) {
   144     if (cl_method == NULL) {
   145         cl_method = get_method(env, jlrM(env), "getClassLoader", "()Ljava/lang/ClassLoader;");
   145         cl_method = get_method(env, jlM(env), "getClassLoader", "()Ljava/lang/ClassLoader;");
   146     }
   146     }
   147     loader = (jobject)JNI_ENV_PTR(env)->CallObjectMethod(JNI_ENV_ARG(env, module), cl_method);
   147     loader = (jobject)JNI_ENV_PTR(env)->CallObjectMethod(JNI_ENV_ARG(env, module), cl_method);
   148     return loader;
   148     return loader;
   149 }
   149 }
   150 
   150 
   155     jstring jstr = NULL;
   155     jstring jstr = NULL;
   156     const char *name = NULL;
   156     const char *name = NULL;
   157     const char *nstr = NULL;
   157     const char *nstr = NULL;
   158 
   158 
   159     if (method == NULL) {
   159     if (method == NULL) {
   160         method = get_method(env, jlrM(env), "getName", "()Ljava/lang/String;");
   160         method = get_method(env, jlM(env), "getName", "()Ljava/lang/String;");
   161     }
   161     }
   162     jstr = (jstring)JNI_ENV_PTR(env)->CallObjectMethod(JNI_ENV_ARG(env, module), method);
   162     jstr = (jstring)JNI_ENV_PTR(env)->CallObjectMethod(JNI_ENV_ARG(env, module), method);
   163     if (jstr != NULL) {
   163     if (jstr != NULL) {
   164         name = JNI_ENV_PTR(env)->GetStringUTFChars(JNI_ENV_ARG(env, jstr), NULL);
   164         name = JNI_ENV_PTR(env)->GetStringUTFChars(JNI_ENV_ARG(env, jstr), NULL);
   165     }
   165     }