Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed the required StateFactory implementations #455

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

laeubi
Copy link
Member

@laeubi laeubi commented Feb 8, 2024

Currently P2 has the BundleDescription in its API where the only implementation is in the discouraged osgi.compatibility fragment, but actually P2 does not really need a full implementation, it is just using that to parse manifest headers and generate metadata from it.

This embeds a stripped down version of the actual implementation in the p2.publisher.eclipse that allows to create implementation objects without rely on the compatibility fragment anymore.

This is currently work in progress and a way to track progress, the classes can most probably stripped down even more and currently depends on some equinox framework internals that probably should either be inline as well or an alternative should be chosen.

Copy link

github-actions bot commented Feb 8, 2024

Test Results

    9 files  ±0      9 suites  ±0   29m 7s ⏱️ - 2m 19s
2 197 tests ±0  2 193 ✅ ±0   4 💤 ±0  0 ❌ ±0 
6 681 runs  ±0  6 670 ✅ ±0  11 💤 ±0  0 ❌ ±0 

Results for commit f74d051. ± Comparison against base commit 96d0fc5.

♻️ This comment has been updated with latest results.

@laeubi
Copy link
Member Author

laeubi commented Feb 9, 2024

Beside the zip packaging problem this seem to not break anything @merks do you want to give it a try with Ooomph?

@tjwatson what do you think? I know it is not nice to copy the code, but it seems unlikely P2 will ever be able to move away from the API interface and at least we can strip down everything to the bare minimum P2 is actually using here (e.g. it never uses a State anyways and would make PDE the only consumer of the compatibility fragment.

It seems without a state this always operates in "nonstrict mode" and we can even remove all code pathes that work on "strict" checks.

@merks
Copy link
Contributor

merks commented Feb 9, 2024

It appears to cause no breakage for Oomph...

@laeubi
Copy link
Member Author

laeubi commented Feb 9, 2024

One option would be if we move the fragment to P2 instead of copy one can simply link the sources here, see

@@ -33,12 +33,15 @@ Import-Package: org.eclipse.equinox.app;version="[1.0.0,2.0.0)",
org.eclipse.equinox.simpleconfigurator.manipulator;version="[2.0.0,3.0.0)",
org.eclipse.equinox.spi.p2.publisher,
org.eclipse.osgi.framework.util,
org.eclipse.osgi.internal.framework,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importing of internal packages should not be done for this.

@tjwatson
Copy link
Contributor

I'm not convinced making a copy here helps much with anything vs. using the APIs and implementation fragment as they are today.

@laeubi
Copy link
Member Author

laeubi commented Apr 29, 2024

I'm not convinced making a copy here helps much with anything vs. using the APIs and implementation fragment as they are today.

The API will still be used (as we can't change this much) but the implementation (compatibility fragment) will not be required anymore as P2 don't really wants the "real" implementation, in fact is only uses that to parse the MANIFEST and provides that as a structured way to access the information.

So one can also reimplement that, but copy whats already there seems to be a faster approach.

Currently P2 has the BundleDescription in its API where the only
implementation is in the discouraged osgi.compatibility fragment, but
actually P2 does not really need a full implementation, it is just using
that to parse manifest headers and generate metadata from it.

This embeds a stripped down version of the actual implementation in the
p2.publisher.eclipse that allows to create implementation objects
without rely on the compatibility fragment anymore.

import java.lang.reflect.Constructor;
import java.util.*;
import org.eclipse.osgi.internal.framework.EquinoxContainer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not import this internal for the constant. And you seem to have an EquinoxContainer class in this statefactory you can use.

import java.util.*;
import org.eclipse.osgi.internal.framework.EquinoxContainer;
import org.eclipse.osgi.internal.framework.FilterImpl;
import org.eclipse.osgi.internal.messages.Msg;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not use the frameworks internal NLS classs Msg

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.osgi.internal.framework.FilterImpl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use FrameworkUtil.createFilter instead of using the internal FilterImpl of the framework.

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