Repository: quarkusio/quarkus
Issue: mongodb+srv protocol no more working on dev mode since Quarkus 1.3 with Java 11

**Describe the bug**
SInce Quarkus 1.3, using a MongoDB connection String with `mongodb+srv` didn't work anymore on dev mode.
This work fine when launching the JAR file (native mode didn't works for `mongo+srv`).
This work fine with Quarkus 1.2.
This is a Java 11 and later only issue on dev mode.

Adding the right export to the JVM do the trick but we normally didn't need to as using the JAR file works : `--add-exports jdk.naming.dns/com.sun.jndi.dns=java.naming`

**Actual behavior**
It fails with the following stacktrace:
```
Caused by: com.mongodb.MongoClientException: Unable to support mongodb+srv// style connections as the 'com.sun.jndi.dns.DnsContextFactory' class is not available in this JRE. A JNDI context is required for resolving SRV records.
	at com.mongodb.internal.dns.DefaultDnsResolver.createDnsDirContext(DefaultDnsResolver.java:152)
	at com.mongodb.internal.dns.DefaultDnsResolver.resolveAdditionalQueryParametersFromTxtRecords(DefaultDnsResolver.java:112)
	at com.mongodb.ConnectionString.<init>(ConnectionString.java:382)
	at io.quarkus.mongodb.runtime.AbstractMongoClientProducer.createMongoConfiguration(AbstractMongoClientProducer.java:240)
	at io.quarkus.mongodb.runtime.AbstractMongoClientProducer.createMongoClient(AbstractMongoClientProducer.java:87)
	at io.quarkus.mongodb.runtime.MongoClientProducer.createDefaultMongoClient(MongoClientProducer.zig:37)
	at io.quarkus.mongodb.runtime.MongoClientProducer_ProducerMethod_createDefaultMongoClient_e88f14bf92aae40841e4b513ac764f8acd21873d_Bean.create(MongoClientProducer_ProducerMethod_createDefaultMongoClient_e88f14bf92aae40841e4b513ac764f8acd21873d_Bean.zig:138)
	at io.quarkus.mongodb.runtime.MongoClientProducer_ProducerMethod_createDefaultMongoClient_e88f14bf92aae40841e4b513ac764f8acd21873d_Bean.create(MongoClientProducer_ProducerMethod_createDefaultMongoClient_e88f14bf92aae40841e4b513ac764f8acd21873d_Bean.zig:77)
	at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:80)
	at io.quarkus.arc.impl.ComputingCache$CacheFunction.lambda$apply$0(ComputingCache.java:99)
	at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
	at io.quarkus.arc.impl.ComputingCache.getValue(ComputingCache.java:41)
	at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:25)
	at io.quarkus.mongodb.runtime.MongoClientProducer_ProducerMethod_createDefaultMongoClient_e88f14bf92aae40841e4b513ac764f8acd21873d_ClientProxy.arc$delegate(MongoClientProducer_ProducerMethod_createDefaultMongoClient_e88f14bf92aae40841e4b513ac764f8acd21873d_ClientProxy.zig:264)
	at io.quarkus.mongodb.runtime.MongoClientProducer_ProducerMethod_createDefaultMongoClient_e88f14bf92aae40841e4b513ac764f8acd21873d_ClientProxy.getDatabase(MongoClientProducer_ProducerMethod_createDefaultMongoClient_e88f14bf92aae40841e4b513ac764f8acd21873d_ClientProxy.zig:104)
	at org.acme.rest.json.FruitService.getCollection(FruitService.java:44)
	at org.acme.rest.json.FruitService.list(FruitService.java:20)
	at org.acme.rest.json.FruitService_ClientProxy.list(FruitService_ClientProxy.zig:51)
	at org.acme.rest.json.FruitResource.list(FruitResource.java:21)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
	at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:621)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:487)
	at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:437)
	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:362)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:439)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:400)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:374)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:67)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:488)
	... 20 more
Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.jndi.dns.DnsContextFactory [Root exception is java.lang.IllegalAccessException: class javax.naming.spi.NamingManager (in module java.naming) cannot access class com.sun.jndi.dns.DnsContextFactory (in module jdk.naming.dns) because module jdk.naming.dns does not export com.sun.jndi.dns to module java.naming]
	at java.naming/javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:719)
	at java.naming/javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305)
	at java.naming/javax.naming.InitialContext.init(InitialContext.java:236)
	at java.naming/javax.naming.InitialContext.<init>(InitialContext.java:208)
	at java.naming/javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:101)
	at com.mongodb.internal.dns.DefaultDnsResolver.createDnsDirContext(DefaultDnsResolver.java:150)
	... 53 more
Caused by: java.lang.IllegalAccessException: class javax.naming.spi.NamingManager (in module java.naming) cannot access class com.sun.jndi.dns.DnsContextFactory (in module jdk.naming.dns) because module jdk.naming.dns does not export com.sun.jndi.dns to module java.naming
	at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)
	at java.base/jdk.internal.reflect.Reflection.ensureMemberAccess(Reflection.java:99)
	at java.base/java.lang.Class.newInstance(Class.java:579)
	at java.naming/javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:716)
	... 58 more
```


**To Reproduce**
The issue can be reproduced easily on the `mongodb-client` integration test:

- Use Java 11
- Update `application.properties` with the following connection String : 
```
quarkus.mongodb.connection-string=mongodb+srv://sarah:connor@toto.tata.titi.com/test?retryWrites=true&w=majority
```
- Launch the application in dev mode: `mvn quarkus:dev`
- Access the endpoint: `curl localhost:8080/books`

Of course, this cluster didn't exist ;) but the test fails before connecting to it.


Changed files:
independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java

diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java
index e2a0164082f..da14e314d16 100644
--- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java
+++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/QuarkusClassLoader.java
@@ -4,6 +4,7 @@
 import java.io.Closeable;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
 import java.security.ProtectionDomain;
 import java.util.ArrayList;
@@ -73,13 +74,28 @@ public class QuarkusClassLoader extends ClassLoader implements Closeable {
     private volatile ClassLoader transformerClassLoader;
     private volatile ClassLoaderState state;
 
+    static final ClassLoader PLATFORM_CLASS_LOADER;
+
+    static {
+        ClassLoader cl = null;
+        try {
+            cl = (ClassLoader) ClassLoader.class.getDeclaredMethod("getPlatformClassLoader").invoke(null);
+        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+
+        }
+        PLATFORM_CLASS_LOADER = cl;
+    }
+
     private QuarkusClassLoader(Builder builder) {
         //we need the parent to be null
         //as MP has super broken class loading where it attempts to resolve stuff from the parent
         //will hopefully be fixed in 1.4
         //e.g. https://github.com/eclipse/microprofile-config/issues/390
         //e.g. https://github.com/eclipse/microprofile-reactive-streams-operators/pull/130
-        super(null);
+        //to further complicate things we also have https://github.com/quarkusio/quarkus/issues/8985
+        //where getParent must work to load JDK services on JDK9+
+        //to get around this we pass in the platform ClassLoader, if it exists
+        super(PLATFORM_CLASS_LOADER);
         this.name = builder.name;
         this.elements = builder.elements;
         this.bytecodeTransformers = builder.bytecodeTransformers;