diff options
-rw-r--r-- | bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/SystemBundleTests.java | 45 | ||||
-rw-r--r-- | bundles/org.eclipse.osgi/JavaSE-9.0.profile (renamed from bundles/org.eclipse.osgi/JavaSE-1.9.profile) | 12 | ||||
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java | 14 |
3 files changed, 62 insertions, 9 deletions
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 570c596af..2decd5802 100644 --- 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 @@ -2587,6 +2587,51 @@ public class SystemBundleTests extends AbstractBundleTests { assertNotNull("No system bundle class loader.", cl); } + public void testJavaProfile() { + String original = System.getProperty("java.specification.version"); + try { + doTestJavaProfile("9.3.1", "JavaSE-9.0"); + doTestJavaProfile("9", "JavaSE-9.0"); + doTestJavaProfile("8.4", "JavaSE-1.8"); + doTestJavaProfile("1.10.1", "JavaSE-1.8"); + doTestJavaProfile("1.9", "JavaSE-1.8"); + doTestJavaProfile("1.8", "JavaSE-1.8"); + doTestJavaProfile("1.7", "JavaSE-1.7"); + } finally { + System.setProperty("java.specification.version", original); + } + } + + private void doTestJavaProfile(String javaSpecVersion, String expectedEEName) { + System.setProperty("java.specification.version", javaSpecVersion); + // create/stop/ test + File config = OSGiTestsActivator.getContext().getDataFile(getName() + javaSpecVersion); + Map<String, Object> configuration = new HashMap<String, Object>(); + configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath()); + Equinox equinox = new Equinox(configuration); + try { + equinox.init(); + } catch (BundleException e) { + fail("Unexpected exception in init()", e); //$NON-NLS-1$ + } + @SuppressWarnings("deprecation") + String osgiEE = equinox.getBundleContext().getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT); + // don't do anything; just put the framework back to the RESOLVED state + try { + equinox.stop(); + } catch (BundleException e) { + fail("Unexpected error stopping framework", e); //$NON-NLS-1$ + } + try { + equinox.waitForStop(10000); + } catch (InterruptedException e) { + fail("Unexpected interrupted exception", e); //$NON-NLS-1$ + } + assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState()); //$NON-NLS-1$ + + assertTrue("Wrong osgi EE: " + osgiEE, osgiEE.endsWith(expectedEEName)); + } + private static File[] createBundles(File outputDir, int bundleCount) throws IOException { outputDir.mkdirs(); diff --git a/bundles/org.eclipse.osgi/JavaSE-1.9.profile b/bundles/org.eclipse.osgi/JavaSE-9.0.profile index f26f22c38..9c8400824 100644 --- a/bundles/org.eclipse.osgi/JavaSE-1.9.profile +++ b/bundles/org.eclipse.osgi/JavaSE-9.0.profile @@ -195,15 +195,15 @@ org.osgi.framework.executionenvironment = \ JavaSE-1.6,\ JavaSE-1.7,\ JavaSE-1.8,\ - JavaSE-1.9 + JavaSE-9.0 org.osgi.framework.system.capabilities = \ osgi.ee; osgi.ee="OSGi/Minimum"; version:List<Version>="1.0, 1.1, 1.2",\ osgi.ee; osgi.ee="JRE"; version:List<Version>="1.0, 1.1",\ - osgi.ee; osgi.ee="JavaSE"; version:List<Version>="1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9",\ - osgi.ee; osgi.ee="JavaSE/compact1"; version:List<Version>="1.8",\ - osgi.ee; osgi.ee="JavaSE/compact2"; version:List<Version>="1.8",\ - osgi.ee; osgi.ee="JavaSE/compact3"; version:List<Version>="1.8" -osgi.java.profile.name = JavaSE-1.9 + osgi.ee; osgi.ee="JavaSE"; version:List<Version>="1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 9.0",\ + osgi.ee; osgi.ee="JavaSE/compact1"; version:List<Version>="1.8, 9.0",\ + osgi.ee; osgi.ee="JavaSE/compact2"; version:List<Version>="1.8, 9.0",\ + osgi.ee; osgi.ee="JavaSE/compact3"; version:List<Version>="1.8, 9.0" +osgi.java.profile.name = JavaSE-9.0 org.eclipse.jdt.core.compiler.compliance=1.9 org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java index c0a4288ef..8cf7de1db 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java @@ -1480,11 +1480,19 @@ public class Storage { private InputStream findNextBestProfile(Generation systemGeneration, String javaEdition, Version javaVersion, String embeddedProfileName) { InputStream result = null; + int major = javaVersion.getMajor(); int minor = javaVersion.getMinor(); do { - result = findInSystemBundle(systemGeneration, javaEdition + embeddedProfileName + javaVersion.getMajor() + "." + minor + PROFILE_EXT); //$NON-NLS-1$ - minor = minor - 1; - } while (result == null && minor > 0); + result = findInSystemBundle(systemGeneration, javaEdition + embeddedProfileName + major + "." + minor + PROFILE_EXT); //$NON-NLS-1$ + if (minor > 0) { + minor -= 1; + } else if (major > 9) { + major -= 1; + } else if (major <= 9 && major > 1) { + minor = 8; + major = 1; + } + } while (result == null && minor >= 0); return result; } |