-
Notifications
You must be signed in to change notification settings - Fork 65
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
Fix ModuleCapability/ModuleRequirement hashcode/equals according to API #537
base: master
Are you sure you want to change the base?
Conversation
Test Results 660 files ±0 660 suites ±0 1h 11m 19s ⏱️ - 1m 3s For more details on these failures and errors, see this check. Results for commit 46bd105. ± Comparison against base commit c8ce736. ♻️ This comment has been updated with latest results. |
fcc43af
to
bd2975f
Compare
@tjwatson how can we proceed here? I wonder what would be the advantage of |
I don't think we should proceed here. In the framework each Equinox regions does this to create isolated regions. So for the case where the "same" bundle JAR (Resource) is installed multiple times (into different "regions"), the framework HAS to treat each |
But "same bundle" then means same bsn and same version is this really something to concern? Otherwise Req/Cap can never be the same (as bundle version would be different). Also as mentioned the Framework internally can still treat them differently than the default equals/hashcode... |
Not sure what you mean by concern. Yes same exact JAR is installed multiple times at a different bundle location. For this the framework has to treat each
Yes, this is what I am asserting. Each
I see no advantage to that complication when each |
But if the underlying BundleRevision == Resource is different then the Req/Cap wont be equal as well so maybe we are talking about different things. So I think we are safe here, I just wanted to reiterate on what the spec says:
So if bundle location is different two resources are not equal. Now for what is done here (Req/Cap) it says
So that should be safe as well from what you described, as each Rev is a different Resource. |
Okay I think we are on the same page then? We agree that the BundleRevision instances managed by the framework must be use identity equals/hashcode which implies that req/cap also can use identity equals/hash. To do extra calculations based on attributes/directives would be a waste because the backing resource (BundleRevision) is always identity unique. |
I should have mentioned this already. But the main reason each BundleRevision must be treated as identity unique is because each BundleRevision is used as a "recipe" for creating a bundle class loader. That creates a unique class space for the BundleRevision instance. The resolver has to then treat each BundleRevision as unique so that the |
The spec says something different and I don't see why Req/Cap must use identity equals/hash here.
A common short-cut for this is to do identity comparison first, so I don't see we loose much here but just assume I do wrap a Requirement (e.g. bnd does that because Req/Cap and Resource are all immutable objects) and then compare it to the original Requirement. For clarity we now name them
even though (from the perspective of the spec) must return equal in both cases. |
I don't see how that works. Identity comparison is false and you fall back to the other non-identity comparison just makes it always use non-identity comparison which will have it return true when it should be false. |
Why should it return true when false is expected? |
I've lost track on what you are proposing or what problem you are trying to fix. Perhaps an update to the PR would help? |
bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleCapability.java
Outdated
Show resolved
Hide resolved
26d68e2
to
72e3806
Compare
The API of Capability/Requirement currently defines the contract to be: This Capability/Requirement is equal to another Capability/Requirement if they have the same namespace, directives and attributes and are declared by the same resource. But Equinox currently implements hashCode/equals in terms of object identity.
72e3806
to
46bd105
Compare
The API of Capability/Requirement currently defines the contract to be: This Capability/Requirement is equal to another Capability/Requirement if they have the same namespace, directives and attributes and are declared by the same resource.
But Equinox currently implements hashCode/equals in terms of object identity.
A similar problem might be in
ModuleRevision
where it says two resources are equal if:I find this a bit unclear what "content" means, in the context of a repository it might be the hashsum but for a Bundle(Revision) I think this is hard to answer.