8300139: [AIX] Use pthreads to avoid JNI_createVM call from primordial thread
Reviewed-by: dholmes, stuefe
This commit is contained in:
parent
bbd8ae7820
commit
cb8107303e
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -25,9 +25,6 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8067744
|
* @bug 8067744
|
||||||
* @comment Test uses custom launcher that starts VM in primordial thread. This is
|
|
||||||
* not possible on aix.
|
|
||||||
* @requires os.family != "aix"
|
|
||||||
* @requires vm.flagless
|
* @requires vm.flagless
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,6 +24,9 @@
|
|||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifdef AIX
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif //AIX
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
@ -104,7 +107,15 @@ long long unsigned int d2l(double d) {
|
|||||||
|
|
||||||
#define print_reg(r) printf("%s = %f (0x%llX)\n", #r, r, d2l(r));
|
#define print_reg(r) printf("%s = %f (0x%llX)\n", #r, r, d2l(r));
|
||||||
|
|
||||||
int main(int argc, const char** argv) {
|
typedef struct {
|
||||||
|
int argc;
|
||||||
|
char **argv;
|
||||||
|
} args_list;
|
||||||
|
|
||||||
|
static void* run(void* argp) {
|
||||||
|
args_list *arg = (args_list*) argp;
|
||||||
|
int argc = arg->argc;
|
||||||
|
char **argv = arg->argv;
|
||||||
JavaVM* jvm;
|
JavaVM* jvm;
|
||||||
JNIEnv* env;
|
JNIEnv* env;
|
||||||
JavaVMInitArgs vm_args;
|
JavaVMInitArgs vm_args;
|
||||||
@ -239,3 +250,24 @@ int main(int argc, const char** argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
args_list args;
|
||||||
|
args.argc = argc;
|
||||||
|
args.argv = argv;
|
||||||
|
#ifdef AIX
|
||||||
|
size_t adjusted_stack_size = 1024*1024;
|
||||||
|
pthread_t id;
|
||||||
|
int result;
|
||||||
|
pthread_attr_t attr;
|
||||||
|
pthread_attr_init(&attr);
|
||||||
|
pthread_attr_setstacksize(&attr, adjusted_stack_size);
|
||||||
|
result = pthread_create(&id, &attr, run, (void *)&args);
|
||||||
|
if (result != 0) {
|
||||||
|
fprintf(stderr, "Error: pthread_create failed with error code %d \n", result);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pthread_join(id, NULL);
|
||||||
|
#else
|
||||||
|
run(&args);
|
||||||
|
#endif //AIX
|
||||||
|
}
|
||||||
|
@ -25,10 +25,7 @@
|
|||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @bug 8221530 8221642
|
* @bug 8221530 8221642
|
||||||
* @summary Test uses custom launcher that starts VM using JNI that verifies
|
|
||||||
* reflection API with null caller class
|
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @requires os.family != "aix"
|
|
||||||
* @run main/native CallerAccessTest
|
* @run main/native CallerAccessTest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#ifdef AIX
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif //AIX
|
||||||
|
|
||||||
#include "jni.h"
|
#include "jni.h"
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
@ -42,7 +45,7 @@ int setAccessible(JNIEnv *env, char* declaringClass_name, char* field_name);
|
|||||||
int trySetAccessible(JNIEnv *env, char* declaringClass_name, char* field_name, jboolean canAccess);
|
int trySetAccessible(JNIEnv *env, char* declaringClass_name, char* field_name, jboolean canAccess);
|
||||||
int checkAccess(JNIEnv *env, char* declaringClass_name, char* field_name, jboolean canAccess);
|
int checkAccess(JNIEnv *env, char* declaringClass_name, char* field_name, jboolean canAccess);
|
||||||
|
|
||||||
int main(int argc, char** args) {
|
static void* run(void* argp) {
|
||||||
JavaVM *jvm;
|
JavaVM *jvm;
|
||||||
JNIEnv *env;
|
JNIEnv *env;
|
||||||
JavaVMInitArgs vm_args;
|
JavaVMInitArgs vm_args;
|
||||||
@ -236,3 +239,22 @@ int checkAccess(JNIEnv *env, char* declaringClass_name, char* field_name, jboole
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
#ifdef AIX
|
||||||
|
size_t adjusted_stack_size = 1024*1024;
|
||||||
|
pthread_t id;
|
||||||
|
int result;
|
||||||
|
pthread_attr_t attr;
|
||||||
|
pthread_attr_init(&attr);
|
||||||
|
pthread_attr_setstacksize(&attr, adjusted_stack_size);
|
||||||
|
result = pthread_create(&id, &attr, run, (void *)&argv);
|
||||||
|
if (result != 0) {
|
||||||
|
fprintf(stderr, "Error: pthread_create failed with error code %d \n", result);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pthread_join(id, NULL);
|
||||||
|
#else
|
||||||
|
run(&argv);
|
||||||
|
#endif //AIX
|
||||||
|
}
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
* jdk.compiler
|
* jdk.compiler
|
||||||
* @build NullCallerTest
|
* @build NullCallerTest
|
||||||
* jdk.test.lib.compiler.CompilerUtils
|
* jdk.test.lib.compiler.CompilerUtils
|
||||||
* @requires os.family != "aix"
|
|
||||||
* @run main/native NullCallerTest
|
* @run main/native NullCallerTest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "CallHelper.hpp"
|
#include "CallHelper.hpp"
|
||||||
|
#ifdef AIX
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif //AIX
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test for JDK-8280902
|
* Test for JDK-8280902
|
||||||
@ -156,7 +159,7 @@ void getResourceAsStream(JNIEnv *env) {
|
|||||||
class_ClosedResources, env->NewStringUTF("test.txt"));
|
class_ClosedResources, env->NewStringUTF("test.txt"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** args) {
|
static void* run(void *arg) {
|
||||||
JavaVM *jvm;
|
JavaVM *jvm;
|
||||||
JNIEnv *env;
|
JNIEnv *env;
|
||||||
JavaVMInitArgs vm_args;
|
JavaVMInitArgs vm_args;
|
||||||
@ -184,3 +187,22 @@ int main(int argc, char** args) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
#ifdef AIX
|
||||||
|
size_t adjusted_stack_size = 1024*1024;
|
||||||
|
pthread_t id;
|
||||||
|
int result;
|
||||||
|
pthread_attr_t attr;
|
||||||
|
pthread_attr_init(&attr);
|
||||||
|
pthread_attr_setstacksize(&attr, adjusted_stack_size);
|
||||||
|
result = pthread_create(&id, &attr, run, (void *)argv);
|
||||||
|
if (result != 0) {
|
||||||
|
fprintf(stderr, "Error: pthread_create failed with error code %d \n", result);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pthread_join(id, NULL);
|
||||||
|
#else
|
||||||
|
run(&argv);
|
||||||
|
#endif //AIX
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -24,9 +24,12 @@
|
|||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#ifdef AIX
|
||||||
|
#include <pthread.h>
|
||||||
|
#endif //AIX
|
||||||
|
|
||||||
JNIEnv* create_vm(JavaVM **jvm)
|
static void* run(void *arg) {
|
||||||
{
|
JavaVM *jvm;
|
||||||
JNIEnv* env;
|
JNIEnv* env;
|
||||||
JavaVMInitArgs args;
|
JavaVMInitArgs args;
|
||||||
JavaVMOption options[1];
|
JavaVMOption options[1];
|
||||||
@ -41,39 +44,43 @@ JNIEnv* create_vm(JavaVM **jvm)
|
|||||||
args.options = &options[0];
|
args.options = &options[0];
|
||||||
args.ignoreUnrecognized = 0;
|
args.ignoreUnrecognized = 0;
|
||||||
|
|
||||||
int ret = JNI_CreateJavaVM(jvm, (void**)&env, &args);
|
int ret = JNI_CreateJavaVM(&jvm, (void**)&env, &args);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
exit(10);
|
exit(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
return env;
|
jclass test_class;
|
||||||
|
jmethodID test_method;
|
||||||
|
|
||||||
|
test_class = (*env)->FindClass(env, "TestNativeProcessBuilder$Test");
|
||||||
|
if (test_class == NULL) {
|
||||||
|
exit(11);
|
||||||
|
}
|
||||||
|
|
||||||
|
test_method = (*env)->GetStaticMethodID(env, test_class, "test", "()V");
|
||||||
|
if (test_method == NULL) {
|
||||||
|
exit(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
(*env)->CallStaticVoidMethod(env, test_class, test_method);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
void run(JNIEnv *env) {
|
#ifdef AIX
|
||||||
jclass test_class;
|
size_t adjusted_stack_size = 1024*1024;
|
||||||
jmethodID test_method;
|
pthread_t id;
|
||||||
|
int result;
|
||||||
test_class = (*env)->FindClass(env, "TestNativeProcessBuilder$Test");
|
pthread_attr_t attr;
|
||||||
if (test_class == NULL) {
|
pthread_attr_init(&attr);
|
||||||
exit(11);
|
pthread_attr_setstacksize(&attr, adjusted_stack_size);
|
||||||
}
|
result = pthread_create(&id, &attr, run, (void *)argv);
|
||||||
|
if (result != 0) {
|
||||||
test_method = (*env)->GetStaticMethodID(env, test_class, "test", "()V");
|
fprintf(stderr, "Error: pthread_create failed with error code %d \n", result);
|
||||||
if (test_method == NULL) {
|
return -1;
|
||||||
exit(12);
|
}
|
||||||
}
|
pthread_join(id, NULL);
|
||||||
|
#else
|
||||||
(*env)->CallStaticVoidMethod(env, test_class, test_method);
|
run(&argv);
|
||||||
}
|
#endif //AIX
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
JavaVM *jvm;
|
|
||||||
JNIEnv *env = create_vm(&jvm);
|
|
||||||
|
|
||||||
run(env);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user