[jdk8u-dev] RFR: 8298108: Add a regression test for JDK-8297684
Andrew John Hughes
andrew at openjdk.org
Sat Apr 8 14:21:49 UTC 2023
On Tue, 4 Apr 2023 18:48:29 GMT, Severin Gehwolf <sgehwolf at openjdk.org> wrote:
>> jdk/test/java/security/SignedJar/spi-calendar-provider/TestSPISigned.java line 108:
>>
>>> 106: List<String> testRun = new ArrayList<>();
>>> 107: String extDir = System.getProperty("java.home") + File.separator + "lib" + File.separator + "ext";
>>> 108: testRun.add("-Djava.ext.dirs=" + System.getProperty("java.home") + extDir + File.pathSeparator + MODS_DIR.toAbsolutePath().toString());
>>
>> Doesn't this add `System.getProperty("java.home")` to the front of `extDir` which already begins with `System.getProperty("java.home")`?
>
> If you override the property, it will only contain what you pass it:
>
>
> $ /usr/lib/jvm/java-1.8.0-openjdk/bin/java -Djava.ext.dirs=/foo -XshowSettings:properties -version 2>&1 | grep java.ext.dirs
> java.ext.dirs = /foo
> $ /usr/lib/jvm/java-1.8.0-openjdk/bin/java -XshowSettings:properties -version 2>&1 | grep java.ext.dirs
> java.ext.dirs = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.362.b09-2.fc37.x86_64/jre/lib/ext
>
>
> The intention is to use the extra dir as well, but it should also use `${java.home}/ext`
Yeah, I get that, but I'm talking about the simpler issue of including the value of `System.getProperty("java.home")` twice, once in `extDir` and then again in the string passed to `testRun.add`.
If I break out the code into a test file,
~~~
$ cat TestExt.java
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
public class TestExt
{
private static final Path MODS_DIR = Paths.get("mods");
public static void main(String[] args) {
// run test, which must not throw a NPE
List<String> testRun = new ArrayList<>();
String extDir = System.getProperty("java.home") + File.separator + "lib" + File.separator + "ext";
testRun.add("-Djava.ext.dirs=" + System.getProperty("java.home") + extDir + File.pathSeparator + MODS_DIR.toAbsolutePath().toString());
System.out.println(testRun);
}
}
$ $HOME/build/icedtea8/bin/java -version
openjdk version "1.8.0_362"
OpenJDK Runtime Environment (IcedTea 3.26.0) (Gentoo build 1.8.0_362-b09)
OpenJDK 64-Bit Server VM (build 25.362-b09, mixed mode)
$ $HOME/build/icedtea8/bin/javac TestExt.java
$ $HOME/build/icedtea8/bin/java TestExt
[-Djava.ext.dirs=/home/andrew/build/icedtea8/jre/home/andrew/build/icedtea8/jre/lib/ext:/tmp/mods]
~~~
You can see the value passed includes `java.home` twice. I guess it's not causing an issue with the test because it doesn't actually need to use any of the extensions in the system extension directory.
-------------
PR Review Comment: https://git.openjdk.org/jdk8u-dev/pull/269#discussion_r1161117757
More information about the jdk8u-dev
mailing list