varargs support
It seems that j4rs does not support calling java methods defined with varargs from rust. I'll take a look into whats missing for this to work, but if you have any ideas I'd love to hear them.
The readme lists statics as supporting variadics but that doesnt seem possible since static and non-static methods have the same underlying implementation and neither of them support variadics/varargs.
After looking at the implementation, the fix looks fairly straightforward and I should have a PR up soon.
Looking further into it: There is a test testing that variadics works, so I must be misunderstanding the implementation. ~~However for some reason a lot of the tests fail when run on my machine:~~ ~~For example:~~
running 1 test
test lib_unit_tests::variadic_string_method ... Exception in thread "main" org.astonbitecode.j4rs.errors.InvocationException: While invoking method deploy of Class org.astonbitecode.j4rs.api.deploy.SimpleMavenDeployer
at org.astonbitecode.j4rs.api.invocation.JsonInvocationImpl.invoke(JsonInvocationImpl.java:74)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.astonbitecode.j4rs.api.invocation.JsonInvocationImpl.invokeMethod(JsonInvocationImpl.java:198)
at org.astonbitecode.j4rs.api.invocation.JsonInvocationImpl.invoke(JsonInvocationImpl.java:70)
Caused by: java.io.FileNotFoundException: https://repo.maven.apache.org/maven2/io/github/astonbitecode/j4rs-testing/0.21.0-SNAPSHOT/maven-metadata.xml
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:2010)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1615)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:223)
at java.base/java.net.URL.openStream(URL.java:1325)
at org.astonbitecode.j4rs.api.deploy.SimpleMavenDeployer.getLatestSnapshotName(SimpleMavenDeployer.java:126)
at org.astonbitecode.j4rs.api.deploy.SimpleMavenDeployer.generateUrlTagret(SimpleMavenDeployer.java:117)
at org.astonbitecode.j4rs.api.deploy.SimpleMavenDeployer.deploy(SimpleMavenDeployer.java:78)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
... 3 more
FAILED
failures:
---- lib_unit_tests::variadic_string_method stdout ----
ERROR: An Exception was thrown by Java... Please check the logs or the console.
Error: JavaError("org.astonbitecode.j4rs.errors.InstantiationException: Cannot create instance of org.astonbitecode.j4rs.tests.MyTest\n\tat org.astonbitecode.j4rs.api.instantiation.NativeInstantiationImpl.instantiate(NativeInstantiationImpl.java:47)\nCaused by: java.lang.ClassNotFoundException: org.astonbitecode.j4rs.tests.MyTest\n\tat java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)\n\tat java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592)\n\tat java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)\n\tat java.base/java.lang.Class.forName0(Native Method)\n\tat java.base/java.lang.Class.forName(Class.java:529)\n\tat java.base/java.lang.Class.forName(Class.java:508)\n\tat org.astonbitecode.j4rs.utils.Utils.forNameEnhanced(Utils.java:60)\n\tat org.astonbitecode.j4rs.api.instantiation.NativeInstantiationImpl.createInstance(NativeInstantiationImpl.java:96)\n\tat org.astonbitecode.j4rs.api.instantiation.NativeInstantiationImpl.instantiate(NativeInstantiationImpl.java:44)\n")
Test failure resolved by: https://github.com/astonbitecode/j4rs/pull/124