Skip to content

Preven bndtools from erroneously adding "org.antlr.v4.gui" to the Import-Package header#3672

Closed
badfish69 wants to merge 1 commit intoantlr:devfrom
badfish69:dev
Closed

Preven bndtools from erroneously adding "org.antlr.v4.gui" to the Import-Package header#3672
badfish69 wants to merge 1 commit intoantlr:devfrom
badfish69:dev

Conversation

@badfish69
Copy link

Since a recent update of the version of maven-bundle-plugin used when building the java runtime, the resulting jar file fails to load in OSGI servers due to an unsatisfied package dependency:
Unable to resolve org.antlr.antlr4-runtime/4.10.1: missing requirement [org.antlr.antlr4-runtime/4.10.1] osgi.wiring.package; filter:="(osgi.wiring.package=org.antlr.v4.gui)"

The cause of this is an erroneous reference to org.antlr.v4.gui in the Import-Package header in MANIFEST.MF.

It appears that newer versions of bndtools are a little to good at discovering class usage, and are detecting the static string reference in the Class.forName("org.antlr.v4.gui.TestRig") call in TestRig.java.

This commit obscures the class name a bit to prevent bndtools from finding it at compile-time.

…ort-Package header

Signed-off-by: Richard Begg <richard.begg@cybercx.com.au>
@rovarga
Copy link
Contributor

rovarga commented Apr 27, 2022

Ah, nice hack. Wouldn't it be better to have the import as optional (as in #3675 )?

@badfish69
Copy link
Author

@rovarga Your fix is probably better.
Alternatively, you could turn the Class.forName() analysis off entirely with a
<_noclassforname>true</_noclassforname> directive
I guess it depends on whether there is ever likely to be a need to resolve the deprecated TestRig class at runtime in an OSGI container?

@parrt parrt closed this Jun 25, 2022
@parrt
Copy link
Member

parrt commented Jun 25, 2022

Closed in favor of the other

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.

3 participants