My application works fine with JDK 8 running this snipper code below
import javax.net.ssl.HttpsURLConnection;
import sun.net.www.protocol.https.Handler;
final URL resourceUrl = new URL(null, builder.addToURI(uri).toString(), new sun.net.www.protocol.https.Handler());
Now, I am upgrading to JDK 17, and I get the error message. It is caused by the package sun.net.www.protocol.https.Handler
is already moved to java.base
(internal package)
Package 'sun.net.www.protocol.https' is declared in module 'java.base', which does not export it to the unnamed module
I know there is a workaround solution that uses --add-exports <module>/<package>=<target-module>(,<target-module>)*
command, but I cannot use it for production, at least in my case.
Is there a way that can replace this internal call?