### CI Link

https://gradle-enterprise.elastic.co/s/jfyygdphnhmu6

### Repro line

./gradlew ':server:test' --tests "org.elasticsearch.plugins.UberModuleClassLoaderTests" -Dtests.seed=A39D03284C84C6A2 -Dtests.locale=en-US -Dtests.timezone=Atlantic/Reykjavik -Druntime.java=19

### Does it reproduce?

No

### Applicable branches

main

### Failure history

https://gradle-enterprise.elastic.co/scans/tests?search.timeZoneId=Europe/Bucharest&tests.container=org.elasticsearch.plugins.UberModuleClassLoaderTests&tests.test=classMethod

### Failure excerpt

```
  2> java.io.IOException: Could not remove the following files (in the order of attempts):
       C:\Users\jenkins\workspace\platform-support\479\server\build\testrun\test\temp\org.elasticsearch.plugins.UberModuleClassLoaderTests_A39D03284C84C6A2-001\libs-002: java.nio.file.DirectoryNotEmptyException: C:\Users\jenkins\workspace\platform-support\479\server\build\testrun\test\temp\org.elasticsearch.plugins.UberModuleClassLoaderTests_A39D03284C84C6A2-001\libs-002
       C:\Users\jenkins\workspace\platform-support\479\server\build\testrun\test\temp\org.elasticsearch.plugins.UberModuleClassLoaderTests_A39D03284C84C6A2-001\libs-002\parent.jar: java.nio.file.AccessDeniedException: C:\Users\jenkins\workspace\platform-support\479\server\build\testrun\test\temp\org.elasticsearch.plugins.UberModuleClassLoaderTests_A39D03284C84C6A2-001\libs-002\parent.jar
       C:\Users\jenkins\workspace\platform-support\479\server\build\testrun\test\temp\org.elasticsearch.plugins.UberModuleClassLoaderTests_A39D03284C84C6A2-001\libs-002\optional.jar: java.nio.file.AccessDeniedException: C:\Users\jenkins\workspace\platform-support\479\server\build\testrun\test\temp\org.elasticsearch.plugins.UberModuleClassLoaderTests_A39D03284C84C6A2-001\libs-002\optional.jar
       C:\Users\jenkins\workspace\platform-support\479\server\build\testrun\test\temp\org.elasticsearch.plugins.UberModuleClassLoaderTests_A39D03284C84C6A2-001\libs-002\modular.jar: java.nio.file.AccessDeniedException: C:\Users\jenkins\workspace\platform-support\479\server\build\testrun\test\temp\org.elasticsearch.plugins.UberModuleClassLoaderTests_A39D03284C84C6A2-001\libs-002\modular.jar
       C:\Users\jenkins\workspace\platform-support\479\server\build\testrun\test\temp\org.elasticsearch.plugins.UberModuleClassLoaderTests_A39D03284C84C6A2-001\libs-002\non-modular.jar: java.nio.file.AccessDeniedException: C:\Users\jenkins\workspace\platform-support\479\server\build\testrun\test\temp\org.elasticsearch.plugins.UberModuleClassLoaderTests_A39D03284C84C6A2-001\libs-002\non-modular.jar
       C:\Users\jenkins\workspace\platform-support\479\server\build\testrun\test\temp\org.elasticsearch.plugins.UberModuleClassLoaderTests_A39D03284C84C6A2-001: java.nio.file.DirectoryNotEmptyException: C:\Users\jenkins\workspace\platform-support\479\server\build\testrun\test\temp\org.elasticsearch.plugins.UberModuleClassLoaderTests_A39D03284C84C6A2-001
        at __randomizedtesting.SeedInfo.seed([A39D03284C84C6A2]:0)
        at org.apache.lucene.util.IOUtils.rm(IOUtils.java:341)
        at org.apache.lucene.tests.util.TestRuleTemporaryFilesCleanup.afterAlways(TestRuleTemporaryFilesCleanup.java:209)
        at com.carrotsearch.randomizedtesting.rules.TestRuleAdapter$1.afterAlways(TestRuleAdapter.java:31)
        at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:43)
        at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at org.apache.lucene.tests.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:53)
        at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
        at org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
        at org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
        at org.apache.lucene.tests.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:47)
        at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
        at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
        at com.carrotsearch.randomizedtesting.ThreadLeakControl.lambda$forkTimeoutingTask$0(ThreadLeakControl.java:850)
        at java.base/java.lang.Thread.run(Thread.java:1589)
  2> REPRODUCE WITH: gradlew ':server:test' --tests "org.elasticsearch.plugins.UberModuleClassLoaderTests" -Dtests.seed=A39D03284C84C6A2 -Dtests.locale=en-US -Dtests.timezone=Atlantic/Reykjavik -Druntime.java=19
  2> NOTE: test params are: codec=Lucene94, sim=Asserting(RandomSimilarity(queryNorm=true): {}), locale=sq-AL, timezone=Asia/Manila
  2> NOTE: Windows Server 2012 R2 6.3 amd64/Oracle Corporation 19.0.1 (64-bit)/cpus=32,threads=1,free=331172344,total=536870912
```
server/src/test/java/org/elasticsearch/plugins/UberModuleClassLoaderTests.java
createMinimalJar(jar1, "p.a.FirstClass");
        createMinimalJar(jar2, "p.b.SecondClass");
        createMinimalJar(jar3, "p.c.ThirdClass");
        try (UberModuleClassLoader loader = getLoader(List.of(jar1, jar2, jar3))) {
            Class<?> c1 = loader.loadClass("p.a.FirstClass");
            Object instance1 = c1.getConstructor().newInstance();
            assertThat(instance1.toString(), equalTo("FirstClass"));
            Class<?> c2 = loader.loadClass("p.b.SecondClass");
            Object instance2 = c2.getConstructor().newInstance();
            assertThat(instance2.toString(), equalTo("SecondClass"));
            Class<?> c3 = loader.loadClass("p.c.ThirdClass");
            Object instance3 = c3.getConstructor().newInstance();
            assertThat(instance3.toString(), equalTo("ThirdClass"));
        }
    }
    public void testModuleDenyList() throws Exception {
        Path topLevelDir = createTempDir(getTestName());
        Path jar = topLevelDir.resolve("my-jar-with-resources.jar");
        createSingleClassJar(jar, "p.MyImportingClass", """
            package p;
            import java.sql.ResultSet;
            public class MyImportingClass {
                @Override
                public String toString() {
                    return "MyImportingClass[imports " + ResultSet.class.getSimpleName() + "]";
                }
            }
            """);
        try (
            UberModuleClassLoader denyListLoader = UberModuleClassLoader.getInstance(