osgi/bugzilla-archive

[rfc 243] Use ServiceLoader to load FrameworkUtil helpers

Closed this issue · 5 comments

Original bug ID: BZ#3131
From: @tjwatson
Reported version: R8

Comment author: @tjwatson

For OSGi Connect RFC 243 new static methods were added to FrameworkUtil to add/remove Helper implementations:

org.osgi.framework.FrameworkUtil.addHelper(Helper)
org.osgi.framework.FrameworkUtil.removeHelper(Helper)

And a new type org.osgi.framework.FrameworkUtil.Helper was added.

This approach has several concerns. It allows connect implementations to add their helpers before launching the framework but it also allows normal bundles to try to add their own helpers to static set of helpers. This should not be allowed for many reasons, such as, concerns with pinning class loaders when a bundle is uninstalled and allowing normal bundles to influence the implementation of the FrameworkUtil dynamically.

We should move the Helper type to the new org.osgi.framework.connect package as something like org.osgi.framework.connect.FrameworkUtilHelper and instead have the FrameworkUtil only use the ServiceLoader to look up a static set of Helper implementations available on the class/module path available to the class loader loading the FrameworkUtil class. Moving the type to the connect package makes it obvious this is not a type to be used by normal bundles.

Comment author: @bjhargrave

+1

Comment author: @rotty3000

+1

Comment author: @tjwatson

I did do this update with:

https://osgi.org/gitweb/build.git/commitdiff/951dca2557cbe7b9fc0c806aed9fb9ab425a7b41?hp=5f49c44ed6d9232808b47cf6940427ddb0e4783b

Leaving open to make sure it is agreed to on an EG call that discusses RFC 243

Comment author: @bjhargrave

CPEG call: Fixed.