Hey there, first of all i would like to thank for developing this software! I am a backend engineer at [Prisma](https://github.com/prismagraphql/prisma). I am opening this issue as we are a happy user of this library and would like it to be compatible with Graal. **What is Graal?** Graal is a collection of tools. For one it is a JVM replacement that does not only run Java Bytecode but also other languages like Javascript or Ruby. It also comes with a tool called native image. This allows to **compile a JAR into a standalone binary**. We would like to turn our Prisma Server into a lightweight binary with Graal. However the Graal native image tool comes with some limitations. Some features of the JVM are not supported, e.g. the support for reflection is limited because it is not a good fit with ahead of time compilation. Therefore we created a [test suite](https://github.com/prismagraphql/graal-compatibility) to check the compatibility of our used dependencies with Graal. For each dependency we tried to come up with a super small program and see whether it compiles with Graal or not. The program to test compatibility with this library can be found [here](https://github.com/prismagraphql/graal-compatibility/blob/master/mysql/src/main/scala/Main.scala). **What's the problem we have hit?** When running with `-H:+ReportUnsupportedElementsAtRuntime`: ``` Opening db connection Exception in thread "main" java.lang.ClassCastException: com.mysql.cj.exceptions.CJException cannot be cast to com.mysql.cj.exceptions.WrongArgumentException at com.mysql.cj.util.Util.getInstance(Util.java:187) at com.mysql.cj.util.Util.getInstance(Util.java:192) at com.mysql.cj.conf.ConnectionUrl.getConnectionUrlInstance(ConnectionUrl.java:201) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:204) at Main$.main(Main.scala:25) at Main.main(Main.scala) at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:177) ``` When running without `-H:+ReportUnsupportedElementsAtRuntime`: ``` error: unsupported features in 5 methods Detailed message: Error: Unsupported method sun.management.MemoryImpl.getMemoryManagers0() is reachable: Native method. If you intend to use the Java Native Interface (JNI), specify -H:+JNI and see also -H:JNIConfigurationFiles= (use -H:+PrintFlags for details) To diagnose the issue, you can add the option -H:+ReportUnsupportedElementsAtRuntime. The unsupported element is then reported at run time when it is accessed the first time. Call path from entry point to sun.management.MemoryImpl.getMemoryManagers0(): at sun.management.MemoryImpl.getMemoryManagers0(MemoryImpl.java) at sun.management.MemoryImpl.getMemoryManagers(MemoryImpl.java:98) at sun.management.ManagementFactoryHelper.getMemoryManagerMXBeans(ManagementFactoryHelper.java:121) at java.lang.management.PlatformComponent$5.getMXBeans(PlatformComponent.java:130) at java.lang.management.PlatformComponent.getMXBeans(PlatformComponent.java:377) at java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:472) at com.mysql.cj.jdbc.jmx.LoadBalanceConnectionGroupManager.registerJmx(LoadBalanceConnectionGroupManager.java:54) at com.mysql.cj.jdbc.ConnectionGroupManager.registerJmx(ConnectionGroupManager.java:63) at com.mysql.cj.jdbc.ha.LoadBalancedConnectionProxy.(LoadBalancedConnectionProxy.java:148) at com.mysql.cj.jdbc.ha.LoadBalancedConnectionProxy.createProxyInstance(LoadBalancedConnectionProxy.java:117) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:210) at Main$.main(Main.scala:25) at Main.main(Main.scala) at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:177) at com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0) Error: Unsupported method sun.management.MemoryImpl.getMemoryPools0() is reachable: Native method. If you intend to use the Java Native Interface (JNI), specify -H:+JNI and see also -H:JNIConfigurationFiles= (use -H:+PrintFlags for details) To diagnose the issue, you can add the option -H:+ReportUnsupportedElementsAtRuntime. The unsupported element is then reported at run time when it is accessed the first time. Call path from entry point to sun.management.MemoryImpl.getMemoryPools0(): at sun.management.MemoryImpl.getMemoryPools0(MemoryImpl.java) at sun.management.MemoryImpl.getMemoryPools(MemoryImpl.java:92) at sun.management.ManagementFactoryHelper.getMemoryPoolMXBeans(ManagementFactoryHelper.java:112) at java.lang.management.PlatformComponent$6.getMXBeans(PlatformComponent.java:144) at java.lang.management.PlatformComponent.getMXBeans(PlatformComponent.java:377) at java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:472) at com.mysql.cj.jdbc.jmx.LoadBalanceConnectionGroupManager.registerJmx(LoadBalanceConnectionGroupManager.java:54) at com.mysql.cj.jdbc.ConnectionGroupManager.registerJmx(ConnectionGroupManager.java:63) at com.mysql.cj.jdbc.ha.LoadBalancedConnectionProxy.(LoadBalancedConnectionProxy.java:148) at com.mysql.cj.jdbc.ha.LoadBalancedConnectionProxy.createProxyInstance(LoadBalancedConnectionProxy.java:117) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:210) at Main$.main(Main.scala:25) at Main.main(Main.scala) at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:177) at com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0) Error: Unsupported method sun.management.VMManagementImpl.getStartupTime() is reachable: Native method. If you intend to use the Java Native Interface (JNI), specify -H:+JNI and see also -H:JNIConfigurationFiles= (use -H:+PrintFlags for details) To diagnose the issue, you can add the option -H:+ReportUnsupportedElementsAtRuntime. The unsupported element is then reported at run time when it is accessed the first time. Call path from entry point to sun.management.VMManagementImpl.getStartupTime(): at sun.management.VMManagementImpl.getStartupTime(VMManagementImpl.java) at sun.management.RuntimeImpl.(RuntimeImpl.java:55) at sun.management.ManagementFactoryHelper.getRuntimeMXBean(ManagementFactoryHelper.java:92) at java.lang.management.PlatformComponent$8.getMXBeans(PlatformComponent.java:170) at java.lang.management.PlatformComponent.getMXBeans(PlatformComponent.java:377) at java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:472) at com.mysql.cj.jdbc.jmx.LoadBalanceConnectionGroupManager.registerJmx(LoadBalanceConnectionGroupManager.java:54) at com.mysql.cj.jdbc.ConnectionGroupManager.registerJmx(ConnectionGroupManager.java:63) at com.mysql.cj.jdbc.ha.LoadBalancedConnectionProxy.(LoadBalancedConnectionProxy.java:148) at com.mysql.cj.jdbc.ha.LoadBalancedConnectionProxy.createProxyInstance(LoadBalancedConnectionProxy.java:117) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:210) at Main$.main(Main.scala:25) at Main.main(Main.scala) at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:177) at com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0) Error: Unsupported method sun.management.VMManagementImpl.isThreadAllocatedMemoryEnabled() is reachable: Native method. If you intend to use the Java Native Interface (JNI), specify -H:+JNI and see also -H:JNIConfigurationFiles= (use -H:+PrintFlags for details) To diagnose the issue, you can add the option -H:+ReportUnsupportedElementsAtRuntime. The unsupported element is then reported at run time when it is accessed the first time. Call path from entry point to sun.management.VMManagementImpl.isThreadAllocatedMemoryEnabled(): at sun.management.VMManagementImpl.isThreadAllocatedMemoryEnabled(VMManagementImpl.java) at sun.management.ThreadImpl.(ThreadImpl.java:56) at sun.management.ManagementFactoryHelper.getThreadMXBean(ManagementFactoryHelper.java:85) at java.lang.management.PlatformComponent$9.getMXBeans(PlatformComponent.java:183) at java.lang.management.PlatformComponent.getMXBeans(PlatformComponent.java:377) at java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:472) at com.mysql.cj.jdbc.jmx.LoadBalanceConnectionGroupManager.registerJmx(LoadBalanceConnectionGroupManager.java:54) at com.mysql.cj.jdbc.ConnectionGroupManager.registerJmx(ConnectionGroupManager.java:63) at com.mysql.cj.jdbc.ha.LoadBalancedConnectionProxy.(LoadBalancedConnectionProxy.java:148) at com.mysql.cj.jdbc.ha.LoadBalancedConnectionProxy.createProxyInstance(LoadBalancedConnectionProxy.java:117) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:210) at Main$.main(Main.scala:25) at Main.main(Main.scala) at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:177) at com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0) Error: Unsupported method sun.management.VMManagementImpl.isThreadCpuTimeEnabled() is reachable: Native method. If you intend to use the Java Native Interface (JNI), specify -H:+JNI and see also -H:JNIConfigurationFiles= (use -H:+PrintFlags for details) To diagnose the issue, you can add the option -H:+ReportUnsupportedElementsAtRuntime. The unsupported element is then reported at run time when it is accessed the first time. Call path from entry point to sun.management.VMManagementImpl.isThreadCpuTimeEnabled(): at sun.management.VMManagementImpl.isThreadCpuTimeEnabled(VMManagementImpl.java) at sun.management.ThreadImpl.(ThreadImpl.java:55) at sun.management.ManagementFactoryHelper.getThreadMXBean(ManagementFactoryHelper.java:85) at java.lang.management.PlatformComponent$9.getMXBeans(PlatformComponent.java:183) at java.lang.management.PlatformComponent.getMXBeans(PlatformComponent.java:377) at java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:472) at com.mysql.cj.jdbc.jmx.LoadBalanceConnectionGroupManager.registerJmx(LoadBalanceConnectionGroupManager.java:54) at com.mysql.cj.jdbc.ConnectionGroupManager.registerJmx(ConnectionGroupManager.java:63) at com.mysql.cj.jdbc.ha.LoadBalancedConnectionProxy.(LoadBalancedConnectionProxy.java:148) at com.mysql.cj.jdbc.ha.LoadBalancedConnectionProxy.createProxyInstance(LoadBalancedConnectionProxy.java:117) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:210) at Main$.main(Main.scala:25) at Main.main(Main.scala) at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:177) at com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0) ``` **Note**: The Graal compilation terminates on the first encountered error. Therefore there might be more problems that need to be addressed. **How can incompatibilities with Graal be fixed?** Here is a [blog post](https://medium.com/graalvm/instant-netty-startup-using-graalvm-native-image-generation-ed6f14ff7692) by the Graal team that explains how the native image tool is working and how they were able to compile a server built on top of netty into a binary. We ran this test with Graal `1.0.0-rc5`.