On Fri, 9 Feb 2024 11:38:07 GMT, Darragh Clarke <dcla...@openjdk.org> wrote:

> Currently these tests ignore vm flags, In most cases I've updated them to use 
> `ProcessTools.createTestJavaProcessBuilder` this usually required some 
> cleanup also.
> 
> `test/jdk/java/net/ServerSocket/AcceptCauseFileDescriptorLeak.java` and 
> `test/jdk/java/net/URLConnection/6212146/TestDriver.java` have been set to 
> use `@require vm.flagless` because they both use `sh` commands.
> 
> I've ran these changes against tiers 1-3 and everything seems stable

test/jdk/java/net/URLClassLoader/getresourceasstream/TestDriver.java line 63:

> 61:                 ),
> 62:                 ProcessTools.createTestJavaProcessBuilder(
> 63:                         "-cp", ".",

If I'm not mistaken, this will result in the `-cp` option being passed twice, 
with different values, to the `java` sub process. I believe that 
`ProcessTools.createTestJavaProcessBuilder` will end up passing "-cp 
<java.class.path>" to the subprocess, unless -Dtest.noclasspath=false is 
defined in the parent process.
Tough I could not find what would happen if -cp is passed twice in `man java` - 
it appears that the long standing behaviour is that the last one wins - so I 
guess that's OK, as I doubt this behaviour (last one wins) could be changed...

An alternative could be to create a new method in ProcessTools that would allow 
to pass a flag to prevent the addition of -cp <java.class.path> when that's not 
desiravle, and call that here - and in all other places where -cp is passed to 
`ProcessTools.createTestJavaProcessBuilder`.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/17787#discussion_r1484276695

Reply via email to