From 664dd67f1b7243bae360df038ae09730f4c60972 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Thu, 27 Apr 2017 13:08:01 -0500 Subject: Bug 515920 - "Windows Server 2016" to osname.aliases Change-Id: I07d5537eddb796db7a434a3616bc50acdc51b8ec Signed-off-by: Thomas Watson --- .../osgi/tests/bundles/SystemBundleTests.java | 28 ++++++++++++++++++++++ .../osgi/internal/framework/AliasMapper.java | 8 ++++++- .../eclipse/osgi/internal/framework/osname.aliases | 1 + 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java index e6707c409..a28dbb22c 100755 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java @@ -3043,4 +3043,32 @@ public class SystemBundleTests extends AbstractBundleTests { assertNotNull("No framework active thread for \"" + uuid + "\" found in : " + Arrays.toString(threads), found); assertEquals("Wrong daemon type.", expectIsDeamon, found.isDaemon()); } + + public void testWindowsAlias() { + String origOS = System.getProperty("os.name"); + File config = OSGiTestsActivator.getContext().getDataFile(getName()); //$NON-NLS-1$ + Map configuration = new HashMap(); + configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath()); + System.setProperty("os.name", "Windows 5000"); + Equinox equinox = null; + try { + equinox = new Equinox(configuration); + equinox.init(); + Assert.assertEquals("Wrong framework os name value", "win32", equinox.getBundleContext().getProperty(Constants.FRAMEWORK_OS_NAME)); + } catch (BundleException e) { + fail("Failed init", e); + } finally { + System.setProperty("os.name", origOS); + try { + if (equinox != null) { + equinox.stop(); + equinox.waitForStop(1000); + } + } catch (BundleException e) { + fail("Failed to stop framework.", e); + } catch (InterruptedException e) { + fail("Failed to stop framework.", e); + } + } + } } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java index 67be8107b..b6fd06b3c 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/AliasMapper.java @@ -65,7 +65,13 @@ public class AliasMapper { } public String getCanonicalOSName(String osname) { - String result = osnameCanonicalTable.get(osname.toLowerCase()); + String lowerName = osname.toLowerCase(); + String result = osnameCanonicalTable.get(lowerName); + if (result == null) { + if (lowerName.startsWith("windows")) { //$NON-NLS-1$ + return "win32"; //$NON-NLS-1$ + } + } return result == null ? osname : result; } diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/osname.aliases b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/osname.aliases index 513730b80..729762a6c 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/osname.aliases +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/osname.aliases @@ -46,6 +46,7 @@ WindowsServer2012 "Windows 2012" "Windows Server 2012" Win2012 Win32 # Microsoft WindowsServer2012R2 "Windows 2012 R2" "Windows Server 2012 R2" Win2012R2 Win32 # Microsoft WindowsServer2015 "Windows 2015" "Windows Server 2015" Win2015 Win32 # Microsoft WindowsServer2015R2 "Windows 2015 R2" "Windows Server 2015 R2" Win2015R2 Win32 # Microsoft +WindowsServer2016 "Windows 2016" "Windows Server 2016" Win2016 Win32 # Microsoft Windows7 "Windows 7" Win7 Win32 # Microsoft Windows8 "Windows 8" "Windows 8.1" "Windows 8.2" "Windows 8.3" Win8 Win32 # Microsoft Windows10 "Windows 10" Win10 Win32 # Microsoft -- cgit v1.2.3