While running some tests on Alpine linux I noticed that the `JDK-6354700/JDK-6367077` issue is still occurring on alpine linux
After checking the code base, this seem to be intentionally done https://github.com/openjdk/jdk/blob/6f6966b28b2c5a18b001be49f5db429c667d7a8f/src/java.base/unix/native/libjli/java_md.c#L210
However these extra values should not propagate to future children of the java process as it might cause unintended behaviour in the resolution of shared objects
For example running the following on alpine produces the following output
LD_LIBRARY_PATH=somepath $JAVA_HOME/bin/java Main.java
```
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException, InterruptedException {
ProcessBuilder pb = new ProcessBuilder("env");
pb.inheritIO().start().waitFor();
}
}
```
```
HOME=/root
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
TERM=xterm
LD_LIBRARY_PATH=$JAVA_HOME/lib/server:$JAVA_HOME/lib:somepath
PWD=$(pwd)
HOSTNAME=52d859218924
```
I found this while running a modern jtreg version on some tests using JDK25 as my driving JDK & JDK8 as my test JDK.
I noticed that the jtreg was incorrectly evaluating the JDK version (filtering based on JDK version was being done incorrectly), after investigation I noticed that `java -version` process that the jtreg spawns returns bad values for the JDK8 test JDK which led me to the `LD_LIBRARY_PATH` problem
```
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException, InterruptedException {
ProcessBuilder pb = new ProcessBuilder(args[0], "-version");
pb.inheritIO().start().waitFor();
}
}
```
jdk25/bin/java Main.java jdk8/bin/java
After checking the code base, this seem to be intentionally done https://github.com/openjdk/jdk/blob/6f6966b28b2c5a18b001be49f5db429c667d7a8f/src/java.base/unix/native/libjli/java_md.c#L210
However these extra values should not propagate to future children of the java process as it might cause unintended behaviour in the resolution of shared objects
For example running the following on alpine produces the following output
LD_LIBRARY_PATH=somepath $JAVA_HOME/bin/java Main.java
```
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException, InterruptedException {
ProcessBuilder pb = new ProcessBuilder("env");
pb.inheritIO().start().waitFor();
}
}
```
```
HOME=/root
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
TERM=xterm
LD_LIBRARY_PATH=$JAVA_HOME/lib/server:$JAVA_HOME/lib:somepath
PWD=$(pwd)
HOSTNAME=52d859218924
```
I found this while running a modern jtreg version on some tests using JDK25 as my driving JDK & JDK8 as my test JDK.
I noticed that the jtreg was incorrectly evaluating the JDK version (filtering based on JDK version was being done incorrectly), after investigation I noticed that `java -version` process that the jtreg spawns returns bad values for the JDK8 test JDK which led me to the `LD_LIBRARY_PATH` problem
```
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException, InterruptedException {
ProcessBuilder pb = new ProcessBuilder(args[0], "-version");
pb.inheritIO().start().waitFor();
}
}
```
jdk25/bin/java Main.java jdk8/bin/java