Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 313058

Summary: [R5] No way to tell if VersionRange has no upper limit
Product: [Eclipse Project] Equinox Reporter: Tim deBoer <deboer>
Component: FrameworkAssignee: equinox.framework-inbox <equinox.framework-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aniefer, tjwatson
Version: 3.6   
Target Milestone: Juno M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 354191    

Description Tim deBoer CLA 2010-05-16 23:21:09 EDT
I'm using PDE to find a set of bundles I'm interested in, then using PDE's IPluginModelBase to get a BundleDescription. From the bundle description I'm looking at each bundle's ImportPackageSpecification and org.eclipse.osgi.service.resolver.VersionRange.

From this level, there is no way to tell if the original bundle does not have a maximum version range on an import. Or conversely, if you want to tell if a bundle has no meaningful upper range, you have to create your own copy of versionMax to compare the maximum range to.

It seems like there should be a VersionRange.isMaximumSet(), or more likely the versionMax field should just be exposed to save clients from creating their own.
Comment 1 Thomas Watson CLA 2010-05-17 10:05:25 EDT
Consider in 3.7.  Too late for 3.6.
Comment 2 Andrew Niefer CLA 2010-05-17 11:19:43 EDT
As a workaround, the way to tell would be something like this:
Version testVersion = new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
range.isIncluded(testVersion);

or some variation of looking at range.getMaximum() to see if it has Integer.MAX_VALUE
Comment 3 Tim deBoer CLA 2010-05-17 11:47:01 EDT
Yup, that's essentially what I'm doing - just thought it would be cleaner if there was something built in. Thanks for the quick response, 3.7 is fine.
Comment 4 Thomas Watson CLA 2011-06-08 11:30:30 EDT
Move all 3.8 bugs to Juno.
Comment 5 Thomas Watson CLA 2011-08-08 17:33:29 EDT
In OSGi R4.4 OSGi is going to provide a VersionRange class.  This new class should provide us a way to do this.
Comment 6 Thomas Watson CLA 2012-01-04 14:55:58 EST
In bug 366419 I released a fix to rebase the Equinox VersionRange class on top of the new OSGi VersionRange class.  The method org.eclipse.osgi.service.resolver.VersionRange.getMaximum() has been deprecated.  Use the method org.osgi.framework.VersionRange.getRight() instead.  This method will return a null value when the right endpoint (maximum version) is infinity.