1
1
/*
2
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
24
24
#include <jni.h>
25
25
#include <stdio.h>
26
26
#include <stdlib.h>
27
+ #ifdef AIX
28
+ #include <pthread.h>
29
+ #endif //AIX
27
30
28
- JNIEnv * create_vm ( JavaVM * * jvm )
29
- {
31
+ static void * run ( void * arg ) {
32
+ JavaVM * jvm ;
30
33
JNIEnv * env ;
31
34
JavaVMInitArgs args ;
32
35
JavaVMOption options [1 ];
@@ -41,39 +44,43 @@ JNIEnv* create_vm(JavaVM **jvm)
41
44
args .options = & options [0 ];
42
45
args .ignoreUnrecognized = 0 ;
43
46
44
- int ret = JNI_CreateJavaVM (jvm , (void * * )& env , & args );
47
+ int ret = JNI_CreateJavaVM (& jvm , (void * * )& env , & args );
45
48
if (ret < 0 ) {
46
49
exit (10 );
47
50
}
48
51
49
- return env ;
50
- }
51
-
52
-
53
- void run (JNIEnv * env ) {
54
- jclass test_class ;
55
- jmethodID test_method ;
52
+ jclass test_class ;
53
+ jmethodID test_method ;
56
54
57
- test_class = (* env )-> FindClass (env , "TestNativeProcessBuilder$Test" );
58
- if (test_class == NULL ) {
59
- exit (11 );
60
- }
55
+ test_class = (* env )-> FindClass (env , "TestNativeProcessBuilder$Test" );
56
+ if (test_class == NULL ) {
57
+ exit (11 );
58
+ }
61
59
62
- test_method = (* env )-> GetStaticMethodID (env , test_class , "test" , "()V" );
63
- if (test_method == NULL ) {
64
- exit (12 );
65
- }
60
+ test_method = (* env )-> GetStaticMethodID (env , test_class , "test" , "()V" );
61
+ if (test_method == NULL ) {
62
+ exit (12 );
63
+ }
66
64
67
- (* env )-> CallStaticVoidMethod (env , test_class , test_method );
65
+ (* env )-> CallStaticVoidMethod (env , test_class , test_method );
66
+ return 0 ;
68
67
}
69
68
70
-
71
- int main (int argc , char * * argv )
72
- {
73
- JavaVM * jvm ;
74
- JNIEnv * env = create_vm (& jvm );
75
-
76
- run (env );
77
-
78
- return 0 ;
69
+ int main (int argc , char * argv []) {
70
+ #ifdef AIX
71
+ size_t adjusted_stack_size = 1024 * 1024 ;
72
+ pthread_t id ;
73
+ int result ;
74
+ pthread_attr_t attr ;
75
+ pthread_attr_init (& attr );
76
+ pthread_attr_setstacksize (& attr , adjusted_stack_size );
77
+ result = pthread_create (& id , & attr , run , (void * )argv );
78
+ if (result != 0 ) {
79
+ fprintf (stderr , "Error: pthread_create failed with error code %d \n" , result );
80
+ return -1 ;
81
+ }
82
+ pthread_join (id , NULL );
83
+ #else
84
+ run (& argv );
85
+ #endif //AIX
79
86
}
0 commit comments