Import-Package for sun.net.www.protocol.*

89 views
Skip to first unread message

Chris Rankin

unread,
Nov 17, 2020, 6:33:23 PM11/17/20
to bndtools-users

Hi,

I've noticed that Bnd 5.2 has generated an `Import-Package header for the sun.net.www.protocol.jar package. As I understand it, this package provides the URL handler for the "jar" protocol, and also has friends called "file" and "http". Should all of these packages be considered as part of the JDK and so be listed in bndlib's EE properties files alongside sun.misc and sun.reflect please? Or do these protocol packages have special handling already?

Just wondering,
Thanks,
Chris

BJ Hargrave

unread,
Nov 18, 2020, 8:39:14 AM11/18/20
to bndtool...@googlegroups.com
Normally the sun protocol classes are only directly referenced by the Java runtime to access the URL protocol implementations. User code should not be directly referencing them.

Those packages should not be part of the EE as they are pure implementation details. The EE generally only list package which are considered part of the platform by the runtime. See https://github.com/bjhargrave/java-platform-packages for the tool we use to generate the EE lists from the runtimes.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bndtools-users/ccc04e7f-c719-446a-86d2-217cbaa063f9n%40googlegroups.com.


--

BJ

Chris Rankin

unread,
Nov 18, 2020, 8:55:42 AM11/18/20
to bndtool...@googlegroups.com
On Wed, 18 Nov 2020 at 13:39, BJ Hargrave <b...@bjhargrave.com> wrote:
Normally the sun protocol classes are only directly referenced by the Java runtime to access the URL protocol implementations. User code should not be directly referencing them.
 
Hi, thanks for the reply.

I've managed to track the package reference down to this single line of code:

Class.forName("sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream").getName()

where someone is compiling a list of "allowed" classes (for serialization / deserialization, I think). So maybe adding this package to the "system.extra" property will be enough.

Cheers,
Chris

BJ Hargrave

unread,
Nov 18, 2020, 10:15:21 AM11/18/20
to bndtool...@googlegroups.com
You may want to consider the `-noclassforname: true` instruction. See https://bnd.bndtools.org/instructions/noclassforname.html

This tells Bnd not to look for `Class.forName("class string constant")` usage and generate imports for them.

But if you do that, you'll need to make sure bootdelegation is configured for sun.* packages so that bundles can load the sun.* classes. See https://docs.osgi.org/specification/osgi.core/7.0.0/framework.module.html#framework.module.parentdelegation

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.


--

BJ
Reply all
Reply to author
Forward
0 new messages