charlesgodwin wrote:for example this code fragment from FavoritesPlugin
- Code: Select all
public static final PluginVersionIdentifier IDE_VERSION_EXPECTED =
/* $if version == 3.1 $ */
new PluginVersionIdentifier(3, 1, 0);
/* $elseif version == 3.0 $
new PluginVersionIdentifier(3, 0, 0);
$endif $ */
and
- Code: Select all
org.eclipse.core.runtime.PluginVersionIdentifier
is deprecated
There is nothing wrong with the above code. It runs fine in every major version of Eclipse currently in use. The use of the
PluginVersionIdentifier class is intentional as it is available in Eclipse 3.2 and each major version prior to that.
The entire purpose behind all of the above code is to provide a way to determine the version of Eclipse being used in a
version independent way. It is very important that this code work the same way in every major version of Eclipse (from at least v2.1 on).
If you only care about Eclipse 3.2, you would not use any of this code, so it would be a moot point. If you are creating a plugin that needs to run in Eclipse 2.1 (WSAD 5.1), Eclipse 3.0 (RAD 6.0), Eclipse 3.1 and Eclipse 3.2, then you need to use code that works in all of those versions.
Eclipse 3.2 does include a newer mechanism for indentifying the Eclipse version (which is why they deprecated the old version), but that new mechanism isn't available in older versions of Eclipse, so it can't be used for this purpose.
I should also point out that the
PluginVersionIdentifier class was actually deprecated in
Eclipse 3.2 RC4...more than a month
after the Eclipse 3.2 API was supposedly locked down and barely a month before the final release. This was a very late API change that actually broke the Eclipse.org rules (no API changes allowed once the release candidate cycle starts with RC1).
This late API change also occurred after the 2nd edition of our book went to press (so there was no way for us to anticipate that change). Note that the 2nd printing of the 2nd edition of the book (released earlier this month) includes the following added note at the bottom of p706:
In Eclipse 3.2, the PluginVersionIdentifier class has been deprecated and replaced with the org.osgi.framework.Version class. For version checking to work across Eclipse versions, PluginVersionIdentifier should still be used.