2525
2626/*
2727 * ===========================================================================
28- * (c) Copyright IBM Corp. 2020, 2021 All Rights Reserved
28+ * (c) Copyright IBM Corp. 2020, 2023 All Rights Reserved
2929 * ===========================================================================
3030 */
3131
@@ -376,12 +376,35 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
376376 * o $JVMPATH (directory portion only)
377377 * o $JRE/lib
378378 * o $JRE/../lib
379- * o ZLIBNX_PATH (for AIX P9 or newer systems with NX)
379+ * o ZLIBNX_PATH (for AIX P9 or newer systems with NX, unless -XX:-UseZlibNX is set )
380380 *
381381 * followed by the user's previous effective LD_LIBRARY_PATH, if
382382 * any.
383383 */
384384
385+ #ifdef AIX
386+ int aixargc = * pargc - 1 ; // skip the launcher name
387+ char * * aixargv = * pargv + 1 ;
388+ const char * aixarg = NULL ;
389+ jboolean useZlibNX = JNI_TRUE ;
390+ while (aixargc > 0 && * (aixarg = * aixargv ) == '-' ) {
391+ if (JLI_StrCmp (aixarg , "-XX:+UseZlibNX" ) == 0 ) {
392+ useZlibNX = JNI_TRUE ;
393+ } else if (JLI_StrCmp (aixarg , "-XX:-UseZlibNX" ) == 0 ) {
394+ useZlibNX = JNI_FALSE ;
395+ }
396+ aixargc -- ;
397+ aixargv ++ ;
398+ }
399+ useZlibNX = useZlibNX && power_9_andup () && power_nx_gzip ();
400+ if (JLI_IsTraceLauncher ()) {
401+ printf ("Add " ZLIBNX_PATH " to the LIBPATH: %s P9+ %s NX %s\n" ,
402+ useZlibNX ? "TRUE" : "FALSE" ,
403+ power_9_andup () ? "TRUE" : "FALSE" ,
404+ power_nx_gzip () ? "TRUE" : "FALSE" );
405+ }
406+ #endif
407+
385408 runpath = getenv (LD_LIBRARY_PATH );
386409
387410 /* runpath contains current effective LD_LIBRARY_PATH setting */
@@ -390,8 +413,8 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
390413 new_runpath_size = ((runpath != NULL ) ? JLI_StrLen (runpath ) : 0 ) +
391414 2 * JLI_StrLen (jrepath ) +
392415#ifdef AIX
393- /* On AIX P9 or newer with NX accelerator enabled, add the accelerated zlibNX to LIBPATH */
394- (( power_9_andup () && power_nx_gzip ()) ? JLI_StrLen (":" ZLIBNX_PATH ) : 0 ) +
416+ /* On AIX P9 or newer with NX accelerator enabled, add the accelerated zlibNX to LIBPATH. */
417+ (useZlibNX ? JLI_StrLen (":" ZLIBNX_PATH ) : 0 ) +
395418#endif
396419 JLI_StrLen (new_jvmpath ) + 52 ;
397420 new_runpath = JLI_MemAlloc (new_runpath_size );
@@ -419,7 +442,7 @@ CreateExecutionEnvironment(int *pargc, char ***pargv,
419442 jrepath ,
420443 jrepath
421444#ifdef AIX
422- , (( power_9_andup () && power_nx_gzip ()) ? (":" ZLIBNX_PATH ) : "" )
445+ , (useZlibNX ? (":" ZLIBNX_PATH ) : "" )
423446#endif
424447 );
425448
0 commit comments