Skip to content

Conversation

@chrisrueger
Copy link
Contributor

@chrisrueger chrisrueger commented Oct 16, 2025

Closes #6867

fixes a problem that Verifier.verifyActivator() throws an error "The Bundle-Activator header only supports a single type. The following types were found" when the bnd instructions already define a Bundle-Activator but a processed jar also contributed a Bundle-Activator (e.g. via @Header(name = Constants.BUNDLE_ACTIVATOR, value = "${@class}") annotation).

see org.apache.logging.log4j.util.Activator

image

Before this fix the Bundle-Activator header was concatenated to the existing Bundle-Activator header in the outer bnd of the bundle and thus resulted in multiple values (separated by comma). But for Bundle-Activator this does not make sense as it supports only a single value, as there can only be one single Bundle-Activator in the manifest - which is correctly complained about by Verifier.verifyActivator().

This PR fixes the root cause where the multiple-values are created, so that Verifier.verifyActivator() does not complain anymore.

This for example happened with -includeresource of a Bundle (unrolling or lib:=true) or other ways where bnd scans classes of jar files.

I also identified some other Bundle headers in which should also only contain a single value and not be concatenated.

@chrisrueger
Copy link
Contributor Author

chrisrueger commented Oct 16, 2025

Any thoughts @pkriens @peterkir ?

Do you think there are other headers too, which should have only a single value, if already defined? Or is Bundle-Activator the only header like this?

Update: Added a few other headers which only allow a single value

@chrisrueger chrisrueger force-pushed the fix-multiple-bundleactivator-heads branch 2 times, most recently from 47efbc4 to 450c62e Compare October 18, 2025 14:19
@chrisrueger chrisrueger self-assigned this Oct 18, 2025
@chrisrueger chrisrueger force-pushed the fix-multiple-bundleactivator-heads branch 5 times, most recently from 6144325 to 2398098 Compare October 19, 2025 12:57
@chrisrueger
Copy link
Contributor Author

chrisrueger commented Oct 26, 2025

Note: A related issue which touches a similar topic #5363 (and non-merged PR #5389 )

From there it also becomes apparent that Require-Capability & Provide-Capability are the main targets of that method.
That means, that the current fix is at least not wrong.

@stbischof
Copy link
Contributor

stbischof commented Oct 28, 2025

plans to merge, what blocks?

@chrisrueger
Copy link
Contributor Author

chrisrueger commented Oct 28, 2025

what blocks?

The lack of feedback. And the controversy in the issue discussion. I think the PR fixes the problem reported in the #6868 . If it fixes it in the best way - I don't know.

I will try to bring it up in the next bnd zoom call

@stbischof
Copy link
Contributor

+1

@juergen-albert
Copy link
Contributor

The Mechanism should also make sure, that any bundle activator header is not just a singlton, but that the property in the bnd file wins, so I can overwrite whatever included classfiles may define here.

@chrisrueger
Copy link
Contributor Author

chrisrueger commented Oct 28, 2025

that the property in the bnd file wins, so I can overwrite whatever included classfiles may define here.

That is the exact purpose of that PR. But only for the properties in the new Set BUNDLE_HEADERS_SINGLE_VALUE I defined (which includes Bundle-Activator).

image

https://github.com/bndtools/bnd/pull/6868/files#diff-be27a5a501f05ec3c1bc10a14a8bed0592a76cd02407998f98792675cd2b60c5R153-R156

Is that what you mean? @juergen-albert

@chrisrueger chrisrueger force-pushed the fix-multiple-bundleactivator-heads branch from 2398098 to 67ebbf1 Compare October 28, 2025 22:11
fixes a problem in Verifier.verifyActivator() ("The Bundle-Activator header only supports a single type. The following types were found") when the bnd instructions already define a Bundle-Activator but a processed jar also contributed a Bundle-Activator. Before this fix the Bundle-Activator header was concatenated to the existing Bundle-Activator header in bnd.bnd and thus contained multiple values (separated by comma). But for Bundle-Activator this does not make sense as it supports only a single value.

Added Constants.BUNDLE_HEADERS_SINGLE_VALUE for a list of other headers which should also not be concatenated

Signed-off-by: Christoph Rueger <[email protected]>
@chrisrueger chrisrueger force-pushed the fix-multiple-bundleactivator-heads branch from 67ebbf1 to 30b1622 Compare October 28, 2025 22:17
@chrisrueger
Copy link
Contributor Author

I renamed the private variable to AnnotationHeaders.BUNDLE_HEADERS_ANALYZER_WINS and added some explanation. I hope this makes the intention clearer. Since it's all private people can come up with better wording in the future.

@stbischof
Copy link
Contributor

Here is an example where i would use this

https://github.com/eclipse-osgi-technology/command/blob/main/all/src/main/java/org/eclipse/osgi/technology/command/all/Activator.java#L26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bundle-Activator errors when dependencies contain Activators

3 participants