11/*
2- * Copyright (c) 2009, 2020 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2009, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
2424/*
2525 * @test
2626 * @bug 4780570 4731671 6354700 6367077 6670965 4882974
27- * @summary Checks for LD_LIBRARY_PATH and execution on *nixes
28- * @requires os.family != "windows" & !vm.musl & os.family != "aix"
27+ * @summary Checks for LD_LIBRARY_PATH and execution on *nixes
28+ * @requires os.family != "windows"
2929 * @library /test/lib
3030 * @modules jdk.compiler
3131 * jdk.zipfs
32- * @compile -XDignore.symbol.file ExecutionEnvironment.java
33- * @run main/othervm -DexpandedLdLibraryPath=false ExecutionEnvironment
34- */
35-
36- /*
37- * @test
38- * @bug 4780570 4731671 6354700 6367077 6670965 4882974
39- * @summary Checks for LD_LIBRARY_PATH and execution on *nixes
40- * @requires os.family == "aix" | vm.musl
41- * @library /test/lib
42- * @modules jdk.compiler
43- * jdk.zipfs
44- * @compile -XDignore.symbol.file ExecutionEnvironment.java
45- * @run main/othervm -DexpandedLdLibraryPath=true ExecutionEnvironment
32+ * @run main/othervm ExecutionEnvironment
4633 */
4734
4835/*
4936 * This tests for various things as follows:
5037 * Ensures that:
51- * 1. uneccessary execs do not occur
38+ * 1. unneccessary execs do not occur
5239 * 2. the environment is pristine, users environment variable wrt.
5340 * LD_LIBRARY_PATH if set are not modified in any way.
5441 * 3. the correct vm is chosen with -server and -client options
55- * 4. the VM on Solaris correctly interprets the LD_LIBRARY_PATH32
56- * and LD_LIBRARY_PATH64 variables if set by the user, ie.
57- * i. on 32 bit systems:
58- * a. if LD_LIBRARY_PATH32 is set it will override LD_LIBRARY_PATH
59- * b. LD_LIBRARY_PATH64 is ignored if set
60- * ii. on 64 bit systems:
61- * a. if LD_LIBRARY_PATH64 is set it will override LD_LIBRARY_PATH
62- * b. LD_LIBRARY_PATH32 is ignored if set
63- * 5. no extra symlink exists on Solaris ie.
42+ * 4. no extra symlink exists i.e.
6443 * lib/$arch/libjvm.so -> client/libjvm.so
6544 * TODO:
66- * a. perhaps we need to add a test to audit all environment variables are
67- * in pristine condition after the launch, there may be a few that the
68- * launcher may add as implementation details.
69- * b. add a pldd for solaris to ensure only one libjvm.so is linked
45+ * perhaps we need to add a test to audit all environment variables are
46+ * in pristine condition after the launch, there may be a few that the
47+ * launcher may add as implementation details.
7048 */
7149
7250import jdk .test .lib .Platform ;
@@ -83,7 +61,7 @@ public class ExecutionEnvironment extends TestHelper {
8361 static final String LD_LIBRARY_PATH_32 = LD_LIBRARY_PATH + "_32" ;
8462 static final String LD_LIBRARY_PATH_64 = LD_LIBRARY_PATH + "_64" ;
8563
86- // Note: these paths need not exist on the filesytem
64+ // Note: these paths need not exist on the filesystem
8765 static final String LD_LIBRARY_PATH_VALUE = "/Bridge/On/The/River/Kwai" ;
8866 static final String LD_LIBRARY_PATH_32_VALUE = "/Lawrence/Of/Arabia" ;
8967 static final String LD_LIBRARY_PATH_64_VALUE = "/A/Passage/To/India" ;
@@ -131,8 +109,9 @@ private void flagError(TestResult tr, String message) {
131109 System .err .println (tr );
132110 throw new RuntimeException (message );
133111 }
112+
134113 /*
135- * tests if the launcher pollutes the LD_LIBRARY_PATH variables ie . there
114+ * tests if the launcher pollutes the LD_LIBRARY_PATH variables i.e . there
136115 * should not be any new variables or pollution/mutations of any kind, the
137116 * environment should be pristine.
138117 */
@@ -153,19 +132,21 @@ void testEcoFriendly() {
153132
154133 for (String x : LD_PATH_STRINGS ) {
155134 if (!tr .contains (x )) {
156- if (IS_EXPANDED_LD_LIBRARY_PATH && x .startsWith (LD_LIBRARY_PATH )) {
135+ if (( Platform . isAix () || Platform . isMusl ()) && x .startsWith (LD_LIBRARY_PATH )) {
157136 // AIX does not support the '-rpath' linker options so the
158137 // launchers have to prepend the jdk library path to 'LIBPATH'.
159138 // The musl library loader requires LD_LIBRARY_PATH to be set in
160139 // order to correctly resolve the dependency libjava.so has on libjvm.so.
140+ String jvmroot = System .getProperty ("java.home" );
161141 String libPath = LD_LIBRARY_PATH + "=" +
162- System .getenv (LD_LIBRARY_PATH ) +
163- System .getProperty ("path.separator" ) + LD_LIBRARY_PATH_VALUE ;
142+ jvmroot + "/lib/server" + System .getProperty ("path.separator" ) +
143+ jvmroot + "/lib" + System .getProperty ("path.separator" ) +
144+ jvmroot + "/../lib" + System .getProperty ("path.separator" ) +
145+ LD_LIBRARY_PATH_VALUE ;
164146 if (!tr .matches (libPath )) {
165147 flagError (tr , "FAIL: did not get <" + libPath + ">" );
166148 }
167- }
168- else {
149+ } else {
169150 flagError (tr , "FAIL: did not get <" + x + ">" );
170151 }
171152 }
@@ -215,23 +196,6 @@ private void verifyJavaLibraryPathGeneric(TestResult tr) {
215196 }
216197 }
217198
218- private void verifyJavaLibraryPathOverride (TestResult tr ,
219- boolean is32Bit ) {
220- // make sure the 32/64 bit value exists
221- if (!tr .matches ("java.library.path=.*" +
222- (is32Bit ? LD_LIBRARY_PATH_32_VALUE : LD_LIBRARY_PATH_64_VALUE ) + ".*" )) {
223- flagError (tr , "verifyJavaLibraryPathOverride: " +
224- " java.library.path does not contain " +
225- (is32Bit ? LD_LIBRARY_PATH_32_VALUE : LD_LIBRARY_PATH_64_VALUE ));
226-
227- }
228- // make sure the generic value is absent
229- if (!tr .notMatches ("java.library.path=.*" + LD_LIBRARY_PATH_VALUE + ".*" )) {
230- flagError (tr , "verifyJavaLibraryPathOverride: " +
231- " java.library.path contains " + LD_LIBRARY_PATH_VALUE );
232- }
233- }
234-
235199 /*
236200 * ensures we have indeed exec'ed the correct vm of choice if it exists
237201 */
0 commit comments