Repository: quarkusio/quarkus
Issue: URLClassPath substitutions not working with Java 11

```
Error: substitution target for io.quarkus.vertx.core.runtime.graal.Target_sun_misc_URLClassPath is not loaded. Use field `onlyWith` in the `TargetClass` annotation to make substitution only active when needed.
com.oracle.svm.core.util.UserError$UserException: substitution target for io.quarkus.vertx.core.runtime.graal.Target_sun_misc_URLClassPath is not loaded. Use field `onlyWith` in the `TargetClass` annotation to make substitution only active when needed.
	at com.oracle.svm.core.util.UserError.abort(UserError.java:65)
	at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.findTargetClass(AnnotationSubstitutionProcessor.java:823)
	at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleClass(AnnotationSubstitutionProcessor.java:252)
	at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.init(AnnotationSubstitutionProcessor.java:230)
	at com.oracle.svm.hosted.NativeImageGenerator.createDeclarativeSubstitutionProcessor(NativeImageGenerator.java:874)
	at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:823)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:528)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:445)
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
```

PR on its way

Changed files:
extensions/vertx-core/runtime/src/main/java/io/quarkus/vertx/core/runtime/graal/JdkSubstitutions.java

diff --git a/extensions/vertx-core/runtime/src/main/java/io/quarkus/vertx/core/runtime/graal/JdkSubstitutions.java b/extensions/vertx-core/runtime/src/main/java/io/quarkus/vertx/core/runtime/graal/JdkSubstitutions.java
index 14afde0c967..a6413dbfde9 100644
--- a/extensions/vertx-core/runtime/src/main/java/io/quarkus/vertx/core/runtime/graal/JdkSubstitutions.java
+++ b/extensions/vertx-core/runtime/src/main/java/io/quarkus/vertx/core/runtime/graal/JdkSubstitutions.java
@@ -4,43 +4,46 @@
 import java.io.IOException;
 import java.net.URL;
 import java.util.function.BooleanSupplier;
+import java.util.function.Function;
 
 import com.oracle.svm.core.annotate.Alias;
 import com.oracle.svm.core.annotate.Substitute;
 import com.oracle.svm.core.annotate.TargetClass;
+import com.oracle.svm.core.jdk.JDK11OrLater;
+import com.oracle.svm.core.jdk.JDK8OrEarlier;
 
-@TargetClass(className = "sun.misc.URLClassPath$Loader")
-final class Target_sun_misc_URLClassPath$Loader {
+@TargetClass(className = "URLClassPath$Loader", classNameProvider = Package_jdk_internal_loader.class)
+final class Target_URLClassPath$Loader {
 
     @Alias
-    public Target_sun_misc_URLClassPath$Loader(URL url) {
+    public Target_URLClassPath$Loader(URL url) {
     }
 }
 
-@TargetClass(className = "sun.misc.URLClassPath$FileLoader")
-final class Target_sun_misc_URLClassPath$FileLoader {
+@TargetClass(className = "URLClassPath$FileLoader", classNameProvider = Package_jdk_internal_loader.class)
+final class Target_URLClassPath$FileLoader {
 
     @Alias
-    public Target_sun_misc_URLClassPath$FileLoader(URL url) throws IOException {
+    public Target_URLClassPath$FileLoader(URL url) throws IOException {
     }
 }
 
-@TargetClass(className = "sun.misc.URLClassPath")
+@TargetClass(className = "sun.misc.URLClassPath", onlyWith = JDK8OrEarlier.class)
 final class Target_sun_misc_URLClassPath {
 
     @Substitute
-    private Target_sun_misc_URLClassPath$Loader getLoader(final URL url) throws IOException {
+    private Target_URLClassPath$Loader getLoader(final URL url) throws IOException {
         String file = url.getFile();
         if (file != null && file.endsWith("/")) {
             if ("file".equals(url.getProtocol())) {
-                return (Target_sun_misc_URLClassPath$Loader) (Object) new Target_sun_misc_URLClassPath$FileLoader(
+                return (Target_URLClassPath$Loader) (Object) new Target_URLClassPath$FileLoader(
                         url);
             } else {
-                return new Target_sun_misc_URLClassPath$Loader(url);
+                return new Target_URLClassPath$Loader(url);
             }
         } else {
             // that must be wrong, but JarLoader is deleted by SVM
-            return (Target_sun_misc_URLClassPath$Loader) (Object) new Target_sun_misc_URLClassPath$FileLoader(
+            return (Target_URLClassPath$Loader) (Object) new Target_URLClassPath$FileLoader(
                     url);
         }
     }
@@ -51,6 +54,28 @@ private int[] getLookupCache(String name) {
     }
 }
 
+@TargetClass(className = "jdk.internal.loader.URLClassPath", onlyWith = JDK11OrLater.class)
+final class Target_jdk_internal_loader_URLClassPath {
+
+    @Substitute
+    private Target_URLClassPath$Loader getLoader(final URL url) throws IOException {
+        String file = url.getFile();
+        if (file != null && file.endsWith("/")) {
+            if ("file".equals(url.getProtocol())) {
+                return (Target_URLClassPath$Loader) (Object) new Target_URLClassPath$FileLoader(
+                        url);
+            } else {
+                return new Target_URLClassPath$Loader(url);
+            }
+        } else {
+            // that must be wrong, but JarLoader is deleted by SVM
+            return (Target_URLClassPath$Loader) (Object) new Target_URLClassPath$FileLoader(
+                    url);
+        }
+    }
+
+}
+
 @TargetClass(className = "sun.nio.ch.DatagramChannelImpl", onlyWith = GraalVersion19_0.class)
 final class Target_sun_nio_ch_DatagramChannelImpl {
 
@@ -68,6 +93,20 @@ public boolean getAsBoolean() {
     }
 }
 
+final class Package_jdk_internal_loader implements Function<TargetClass, String> {
+
+    private static final JDK8OrEarlier JDK_8_OR_EARLIER = new JDK8OrEarlier();
+
+    @Override
+    public String apply(TargetClass annotation) {
+        if (JDK_8_OR_EARLIER.getAsBoolean()) {
+            return "sun.misc." + annotation.className();
+        }
+
+        return "jdk.internal.loader." + annotation.className();
+    }
+}
+
 class JdkSubstitutions {
 
 }