Skip to content

Commit 92bcac4

Browse files
committed
Use the module timestamp instead of the timestamp of the state object
Currently the state timestamp is used what can change if a bundle is resolved not only when it is installed/updated/uninstalled, but the Platform#getStateStamp() claims exactly this. To restore the documented behavior this iterates over all bundles and uses its Module#getTimestamp instead, this also removes the reference to the PlatformAdmin that currently requires the compatibility module and could therefore be removed from this once we have migrated PDE.
1 parent 9d08aa5 commit 92bcac4

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.io.File;
2020
import java.net.URL;
21+
import java.util.Arrays;
2122
import java.util.Collection;
2223
import java.util.Collections;
2324
import java.util.Comparator;
@@ -57,6 +58,7 @@
5758
import org.eclipse.equinox.log.ExtendedLogReaderService;
5859
import org.eclipse.equinox.log.ExtendedLogService;
5960
import org.eclipse.equinox.log.Logger;
61+
import org.eclipse.osgi.container.Module;
6062
import org.eclipse.osgi.container.ModuleContainer;
6163
import org.eclipse.osgi.framework.log.FrameworkLog;
6264
import org.eclipse.osgi.service.datalocation.Location;
@@ -538,8 +540,8 @@ public IPath getStateLocation(Bundle bundle, boolean create) throws IllegalState
538540
}
539541

540542
public long getStateTimeStamp() {
541-
PlatformAdmin admin = getPlatformAdmin();
542-
return admin == null ? -1 : admin.getState(false).getTimeStamp();
543+
return Arrays.stream(getBundleContext().getBundles()).map(bundle -> bundle.adapt(Module.class))
544+
.filter(Objects::nonNull).mapToLong(Module::getLastModified).sum();
543545
}
544546

545547
public Location getUserLocation() {

runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,20 +1166,24 @@ public static String[] getApplicationArgs() {
11661166
/**
11671167
* Returns the platform administrator for this running Eclipse.
11681168
* <p>
1169-
* Note: This is an internal method and <em>must not</em>
1170-
* be used by clients which are not part of the Eclipse Platform.
1171-
* This method allows access to classes which are not Eclipse
1172-
* Platform API but are part of the OSGi runtime that the Eclipse
1173-
* Platform is built on. Even as the Eclipse Platform evolves
1174-
* in compatible ways from release to release, the details of
1175-
* the OSGi implementation might not.
1176-
* </p><p>
1177-
* Clients can also acquire the {@link PlatformAdmin} service
1178-
* to retrieve this object.
1169+
* Note: This is an internal method and <em>must not</em> be used by clients
1170+
* which are not part of the Eclipse Platform. This method allows access to
1171+
* classes which are not Eclipse Platform API but are part of the OSGi runtime
1172+
* that the Eclipse Platform is built on. Even as the Eclipse Platform evolves
1173+
* in compatible ways from release to release, the details of the OSGi
1174+
* implementation might not.
1175+
* </p>
1176+
* <p>
1177+
* Clients can also acquire the {@link PlatformAdmin} service to retrieve this
1178+
* object.
11791179
* </p>
1180+
*
11801181
* @return the platform admin for this instance of Eclipse
1182+
* @deprecated only consumer is PDE and this should never be used by other
1183+
* clients, see javadoc for details.
11811184
* @since 3.0
11821185
*/
1186+
@Deprecated(forRemoval = true)
11831187
public static PlatformAdmin getPlatformAdmin() {
11841188
return InternalPlatform.getDefault().getPlatformAdmin();
11851189
}

0 commit comments

Comments
 (0)