oracle/graal

Support of java.net.*

Closed this issue · 4 comments

Do you plan to support java.net.* or some subset of that (java.net.URL and java.net.URI are quite common in many source codes).

Currently I'm getting:

Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported field java.net.URL.handlers is reachable...

The Native Image currently supports file, resource, http and https URL protocols. You can read more about it in the docs. We delete the java.net.URL.handlers field and replace java.net.URL.getURLStreamHandler() with our own implementation. Can you share more details about how you reach the Unsupported field java.net.URL.handlers is reachable error? Reproducible code would be ideal.

It seems the problem was caused by Eclipse JarRsrcLoader.java that was unnecessarily present in jar file.

Error: com.oracle.svm.hosted.substitute.DeletedElementException: Unsupported field java.net.URL.handlers is reachable
To diagnose the issue, you can add the option --report-unsupported-elements-at-runtime. The unsupported element is then reported at run time when it is accessed the first time.
Detailed message:
Trace:
        at parsing java.net.URL.setURLStreamHandlerFactory(URL.java:1118)
Call path from entry point to java.net.URL.setURLStreamHandlerFactory(URLStreamHandlerFactory):
        at java.net.URL.setURLStreamHandlerFactory(URL.java:1110)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:48)
        at com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:151)

        at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:186)
        at com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f54
82cc9a6abc971913ece43acb471d2631b(generated:0)

I am also running into this issue (see https://oss.oracle.com/pipermail/graalvm-users/2019-October/000174.html)

While I can catch and move on without support for a URLStreamHandlerFactory I am curious if this is going to be a permanent restriction going forward. I can understand not allowing a factory to override the native handlers for file, resource, http and https but will it be possible for custom protocol handlers in the future?

The Unsupported field java.net.URL.handlers is reachable error is fixed by #2059. Full support for custom URLStreamHandlerFactory is planned for a future release.