You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ javac HelloWorld.java
$ java HelloWorld
Hello World
But it fails when compiled to a native image:
$ native-image --no-server -H:Name=hello HelloWorld -H:+ReportUnsupportedElementsAtRuntime
$ ./hello
Hello World
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.lang.Throwable.<init>(Throwable.java:310)
at java.lang.Exception.<init>(Exception.java:102)
at java.lang.ReflectiveOperationException.<init>(ReflectiveOperationException.java:89)
at java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:72)
at com.oracle.svm.reflect.proxies.Proxy_1_HelloWorld_main.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:199)
at Lcom/oracle/svm/core/code/CEntryPointCallStubs;.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0)
Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Unsupported field java.lang.reflect.Proxy.proxyClassCache is reachable
at java.lang.Throwable.<init>(Throwable.java:265)
at java.lang.Error.<init>(Error.java:70)
at com.oracle.svm.core.jdk.UnsupportedFeatureError.<init>(UnsupportedFeatureError.java:29)
at com.oracle.svm.core.jdk.Target_com_oracle_svm_core_util_VMError.unsupportedFeature(VMErrorSubstitutions.java:103)
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:419)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:719)
at HelloWorld.main(HelloWorld.java:12)
... 4 more
See also #348 (because Proxy is used heavily by Spring).
The text was updated successfully, but these errors were encountered:
@dsyer thank you for your report. java.lang.reflect.Proxy is currently not supported on SubstrateVM. The main reason is that proxies generate bytecode and we cannot support that at run time. We plan to implement this, but, as with reflection, we would need to know ahead-of-time the interfaces that the proxy implements, so we can generate the bytecodes at build time. In your example we could automatically detect the interface, i.e., the Serializable.class, since it is a compile time constant. If the interfaces are loaded from configuration files then they will need to be explicitly configured and made available to the native image builder.
144516a adds support for dynamic proxy classes. The example above works out of the box, i.e., the interface list is detected automatically and the proxy is generated at image build time. Please read the documentation for further details.
Here's a
HelloWorld
app that runs fine from java:So:
But it fails when compiled to a native image:
See also #348 (because
Proxy
is used heavily by Spring).The text was updated successfully, but these errors were encountered: