Skip to content

Commit

Permalink
Use the module timestamp instead of the timestamp of the state object
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
laeubi committed Feb 8, 2024
1 parent 9d08aa5 commit 92bcac4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.File;
import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
Expand Down Expand Up @@ -57,6 +58,7 @@
import org.eclipse.equinox.log.ExtendedLogReaderService;
import org.eclipse.equinox.log.ExtendedLogService;
import org.eclipse.equinox.log.Logger;
import org.eclipse.osgi.container.Module;
import org.eclipse.osgi.container.ModuleContainer;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.service.datalocation.Location;
Expand Down Expand Up @@ -538,8 +540,8 @@ public IPath getStateLocation(Bundle bundle, boolean create) throws IllegalState
}

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

public Location getUserLocation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1166,20 +1166,24 @@ public static String[] getApplicationArgs() {
/**
* Returns the platform administrator for this running Eclipse.
* <p>
* Note: This is an internal method and <em>must not</em>
* be used by clients which are not part of the Eclipse Platform.
* This method allows access to classes which are not Eclipse
* Platform API but are part of the OSGi runtime that the Eclipse
* Platform is built on. Even as the Eclipse Platform evolves
* in compatible ways from release to release, the details of
* the OSGi implementation might not.
* </p><p>
* Clients can also acquire the {@link PlatformAdmin} service
* to retrieve this object.
* Note: This is an internal method and <em>must not</em> be used by clients
* which are not part of the Eclipse Platform. This method allows access to
* classes which are not Eclipse Platform API but are part of the OSGi runtime
* that the Eclipse Platform is built on. Even as the Eclipse Platform evolves
* in compatible ways from release to release, the details of the OSGi
* implementation might not.
* </p>
* <p>
* Clients can also acquire the {@link PlatformAdmin} service to retrieve this
* object.
* </p>
*
* @return the platform admin for this instance of Eclipse
* @deprecated only consumer is PDE and this should never be used by other
* clients, see javadoc for details.
* @since 3.0
*/
@Deprecated(forRemoval = true)
public static PlatformAdmin getPlatformAdmin() {
return InternalPlatform.getDefault().getPlatformAdmin();
}
Expand Down

0 comments on commit 92bcac4

Please sign in to comment.