Opened 11 months ago
Last modified 9 months ago
#22094 new defect
MethodTooLargeException when creating the proxy for the Port type in java 21 SDK
Reported by: | Emond Papegaaij | Owned by: | |
---|---|---|---|
Component: | webservices | Version: | VirtualBox-7.0.18 |
Keywords: | Cc: | Emond, Papegaaij | |
Guest type: | other | Host type: | other |
Description
When trying to work with the Java SDK on Java 21, we get a MethodTooLargeException trying to get the proxy for the service endpoint class. The VboxPortType has 1832 methods. I suspect this is too much for the proxy generation in Java 21. This makes it impossible to use the SDK on Java 21.
Exception in thread "Thread-5" jdk.internal.org.objectweb.asm.MethodTooLargeException: Method too large: jdk/proxy2/$Proxy89.<clinit> ()V at java.base/jdk.internal.org.objectweb.asm.MethodWriter.computeMethodInfoSize(MethodWriter.java:2120) at java.base/jdk.internal.org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:543) at java.base/java.lang.reflect.ProxyGenerator.generateClassFile(ProxyGenerator.java:506) at java.base/java.lang.reflect.ProxyGenerator.generateProxyClass(ProxyGenerator.java:178) at java.base/java.lang.reflect.Proxy$ProxyBuilder.defineProxyClass(Proxy.java:544) at java.base/java.lang.reflect.Proxy$ProxyBuilder.build(Proxy.java:657) at java.base/java.lang.reflect.Proxy.lambda$getProxyConstructor$1(Proxy.java:440) at java.base/jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(AbstractClassLoaderValue.java:329) at java.base/jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:205) at java.base/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:438) at java.base/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1034) at com.sun.xml.ws.client.WSServiceDelegate$3.run(WSServiceDelegate.java:720) at java.base/java.security.AccessController.doPrivileged(AccessController.java:319) at com.sun.xml.ws.client.WSServiceDelegate.createProxy(WSServiceDelegate.java:716) at com.sun.xml.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:797) at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:426) at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:392) at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:373) at jakarta.xml.ws.Service.getPort(Service.java:139) at org.virtualbox_7_0.jaxws.VboxService.getVboxServicePort(VboxService.java:56) at org.virtualbox_7_0.PortPool.getPort(VirtualBoxManager.java:151) at org.virtualbox_7_0.PortPool.preinit(VirtualBoxManager.java:120) at org.virtualbox_7_0.PortPool.access$200(VirtualBoxManager.java:73) at org.virtualbox_7_0.PortPool$1.run(VirtualBoxManager.java:97) at java.base/java.lang.Thread.run(Thread.java:1583)
Change History (2)
comment:1 by , 9 months ago
comment:2 by , 9 months ago
We decided to copy the VboxPortType java file to our project and delete a bunch of methods we don't need. This works fine and it is easy to keep the file update to date with updates to the SDK: just copy it again and delete the same methods.
org.virtualbox.service.VboxPortType is the stranger having round about 1800 methods. Why is it so large? Because it is generated (maybe by jaxws-maven-plugin) from vboxwebService_7_0.wsdl and compiled into the SDK. The SDK is opensource, you could either develop your own SDK having a smaller wsdl. This worked for me.