Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Version: 3.34.100.qualifier
Bundle-Version: 3.34.200.qualifier
Bundle-SymbolicName: org.eclipse.core.runtime; singleton:=true
Bundle-Vendor: %providerName
Bundle-Activator: org.eclipse.core.internal.runtime.PlatformActivator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,11 @@ public String getOption(String option) {
}

public String getOS() {
return getContextProperty(PROP_OS);
String property = getContextProperty(PROP_OS);
if (property == null) {
return Platform.OS_UNKNOWN;
}
return property;
}

public String getWS() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.Objects;
import java.util.ResourceBundle;
import org.eclipse.core.internal.runtime.AuthorizationHandler;
import org.eclipse.core.internal.runtime.InternalPlatform;
Expand Down Expand Up @@ -79,7 +80,7 @@ private OS() {
* @since 3.30
*/
public static boolean is(String osString) {
return Platform.getOS().equals(osString);
return Objects.equals(Platform.getOS(), osString);
}
Comment on lines 82 to 84
Copy link

Copilot AI Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this change correctly fixes the NPE issue, there's no test coverage for the case where Platform.getOS() returns null. Consider adding a test case to verify that OS.is() returns false when Platform.getOS() returns null, ensuring the documented behavior 'false in all other cases' is maintained even when the OS cannot be determined.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that the Platform class doesn't work stand alone and that while we can fix symptoms of that, it will produce poor results so maybe better it fail dismally than just fail to work correctly.

For the reported problem it would be better to use SWT.getPlatform() as suggested in:

eclipse-platform/eclipse.platform.ui#3604 (comment)

We seem many uses of that:

Image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that the Platform class doesn't work stand alone and that while we can fix symptoms of that, it will produce poor results so maybe better it fail dismally than just fail to work correctly.

I'm not sure what you mean by "standalone" the class works perfectly fine and uses some kind of delegation model that ultimately falls back to using system properties. In any case I think using a defensive approach here is better than throwing an NPE or any other exception as it does not really helps the user here.

For the reported problem it would be better to use SWT.getPlatform() as suggested in:

Independent from that the Platform class needs to work (independent from SWT).

Copy link
Contributor

@basilevs basilevs Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent from that the Platform class needs to work

This can not be correct. Please see Platform class documentation - it requires Platform to be in Running state to be usable. Instead of returning strange values, it might be better to throw an explicit exception and refer clients to class documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can not be correct.

What specifically

Instead of returning strange values,

Why is it strange to say it is not windows if we can not detect it is windows?

it requires Platform to be in Running state to be usable

This is not particular true... the javadoc only says (emphasis by me)

A runtime exception might be thrown or incorrect result might be returned if a method from this class is called while Platform is not running.

So it perfectly aligns with the contracts of the class.


/**
Expand Down
Loading