diff options
author | Thomas Watson | 2008-07-02 19:43:08 +0000 |
---|---|---|
committer | Thomas Watson | 2008-07-02 19:43:08 +0000 |
commit | 734dcb08ef2c04e7ce525f4889fa22770bc82ac0 (patch) | |
tree | 6502cf6d6ebd29dd10b64e95710fb2549c0cccc7 | |
parent | a7bbd61993d0b845b9622c9c3aa0d76d52295ab5 (diff) | |
download | rt.equinox.framework-734dcb08ef2c04e7ce525f4889fa22770bc82ac0.tar.gz rt.equinox.framework-734dcb08ef2c04e7ce525f4889fa22770bc82ac0.tar.xz rt.equinox.framework-734dcb08ef2c04e7ce525f4889fa22770bc82ac0.zip |
Bug 239322 java.lang.StackOverflowError in BundleLoader with version 3.4rc3
12 files changed, 130 insertions, 28 deletions
diff --git a/bundles/org.eclipse.osgi.tests/.classpath b/bundles/org.eclipse.osgi.tests/.classpath index 8fdeb6bd9..0bcd4b1a3 100644 --- a/bundles/org.eclipse.osgi.tests/.classpath +++ b/bundles/org.eclipse.osgi.tests/.classpath @@ -48,6 +48,8 @@ <classpathentry kind="src" output="bundle_tests/exporter.importer2" path="bundles_src/exporter.importer2"/> <classpathentry kind="src" output="bundle_tests/exporter.importer3" path="bundles_src/exporter.importer3"/> <classpathentry kind="src" output="bundle_tests/exporter.importer4" path="bundles_src/exporter.importer4"/> + <classpathentry kind="src" output="bundle_tests/test.bug235958.x" path="bundles_src/test.bug235958.x"/> + <classpathentry kind="src" output="bundle_tests/test.bug235958.y" path="bundles_src/test.bug235958.y"/> <classpathentry kind="src" output="bundle_tests/test.fragment1" path="bundles_src/test.fragment1"/> <classpathentry kind="src" output="bundle_tests/test.fragment2" path="bundles_src/test.fragment2"/> <classpathentry kind="src" output="bundle_tests/test.fragment3" path="bundles_src/test.fragment3"/> diff --git a/bundles/org.eclipse.osgi.tests/build.properties b/bundles/org.eclipse.osgi.tests/build.properties index 99bf6cd8f..14e2fcab3 100644 --- a/bundles/org.eclipse.osgi.tests/build.properties +++ b/bundles/org.eclipse.osgi.tests/build.properties @@ -111,6 +111,10 @@ source.bundle_tests/exporter.importer3.jar = bundles_src/exporter.importer3/ manifest.bundle_tests/exporter.importer3.jar = META-INF/MANIFEST.MF source.bundle_tests/exporter.importer4.jar = bundles_src/exporter.importer4/ manifest.bundle_tests/exporter.importer4.jar = META-INF/MANIFEST.MF +source.bundle_tests/test.bug235958.x.jar = bundles_src/test.bug235958.x/ +manifest.bundle_tests/test.bug235958.x.jar = META-INF/MANIFEST.MF +source.bundle_tests/test.bug235958.y.jar = bundles_src/test.bug235958.y/ +manifest.bundle_tests/test.bug235958.y.jar = META-INF/MANIFEST.MF source.bundle_tests/test.fragment1.jar = bundles_src/test.fragment1/ manifest.bundle_tests/test.fragment1.jar = META-INF/MANIFEST.MF source.bundle_tests/test.fragment2.jar = bundles_src/test.fragment2/ @@ -211,6 +215,8 @@ jars.compile.order = osgitests.jar,\ bundle_tests/test.fragment3.jar,\ bundle_tests/test.fragment4.jar,\ bundle_tests/test.fragment5.jar,\ + bundle_tests/test.bug235958.x,\ + bundle_tests/test.bug235958.y,\ bundle_tests/substitutes.a.jar,\ bundle_tests/substitutes.a.frag.jar,\ bundle_tests/substitutes.b.jar,\ diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.x/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.x/META-INF/MANIFEST.MF new file mode 100644 index 000000000..346a93373 --- /dev/null +++ b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.x/META-INF/MANIFEST.MF @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: X Plug-in +Bundle-SymbolicName: test.bug235958.x +Bundle-Version: 1.0.0 +Bundle-Activator: test.bug235958.x.internal.Activator +Bundle-ActivationPolicy: lazy +Import-Package: org.osgi.framework;version="1.3.0" +Export-Package: test.bug235958.x; version=1.1 +Require-Bundle: test.bug235958.y diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.x/test/bug235958/x/X1.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.x/test/bug235958/x/X1.java new file mode 100644 index 000000000..69862359a --- /dev/null +++ b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.x/test/bug235958/x/X1.java @@ -0,0 +1,5 @@ +package test.bug235958.x; + +public class X1 { + +} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.x/test/bug235958/x/internal/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.x/test/bug235958/x/internal/Activator.java new file mode 100644 index 000000000..6708c0ee7 --- /dev/null +++ b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.x/test/bug235958/x/internal/Activator.java @@ -0,0 +1,24 @@ +package test.bug235958.x.internal; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import test.bug235958.x.X1; + +public class Activator implements BundleActivator { + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + new X1(); + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + } + +} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.y/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.y/META-INF/MANIFEST.MF new file mode 100644 index 000000000..823306c83 --- /dev/null +++ b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.y/META-INF/MANIFEST.MF @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Y Plug-in +Bundle-SymbolicName: test.bug235958.y +Bundle-Version: 1.0.0 +Bundle-Activator: test.bug235958.y.internal.Activator +Bundle-ActivationPolicy: lazy +Import-Package: org.osgi.framework;version="1.3.0", + test.bug235958.x; version="[1.0,2.0)" +Export-Package: test.bug235958.x; version=1.0, + test.bug235958.y; version=1.0 diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.y/test/bug235958/x/X.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.y/test/bug235958/x/X.java new file mode 100644 index 000000000..2edc4912e --- /dev/null +++ b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.y/test/bug235958/x/X.java @@ -0,0 +1,5 @@ +package test.bug235958.x; + +public class X { + +} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.y/test/bug235958/y/Y.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.y/test/bug235958/y/Y.java new file mode 100644 index 000000000..71910611e --- /dev/null +++ b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.y/test/bug235958/y/Y.java @@ -0,0 +1,5 @@ +package test.bug235958.y; + +public class Y { + +} diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.y/test/bug235958/y/internal/Activator.java b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.y/test/bug235958/y/internal/Activator.java new file mode 100644 index 000000000..fb271d4aa --- /dev/null +++ b/bundles/org.eclipse.osgi.tests/bundles_src/test.bug235958.y/test/bug235958/y/internal/Activator.java @@ -0,0 +1,22 @@ +package test.bug235958.y.internal; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + } + +} diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java index 981b8e0f5..d327d4372 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/bundles/ClassLoadingBundleTests.java @@ -738,29 +738,29 @@ public class ClassLoadingBundleTests extends AbstractBundleTests { assertNotNull("No exporter.importer.test found", origExportedPackages); //$NON-NLS-1$ assertEquals("Wrong number of exports", 1, origExportedPackages.length); //$NON-NLS-1$ Bundle exporter = origExportedPackages[0].getExportingBundle(); - assertEquals("Wrong exporter", importerExporter1, exporter); + assertEquals("Wrong exporter", importerExporter1, exporter); //$NON-NLS-1$ // TODO need to get clarification from OSGi on what is returned by getImportingBundles when there is no importers Bundle[] origImporters = origExportedPackages[0].getImportingBundles(); - assertTrue("Should have no importers", origImporters == null || origImporters.length == 0); + assertTrue("Should have no importers", origImporters == null || origImporters.length == 0); //$NON-NLS-1$ // install another importer/exporter. This bundle should wire to the original exporter Bundle importerExporter2 = installer.installBundle("exporter.importer2"); //$NON-NLS-1$ installer.resolveBundles(new Bundle[] {importerExporter2}); origImporters = origExportedPackages[0].getImportingBundles(); - assertNotNull("No importers found", origImporters); - assertEquals("Wrong number of importers", 1, origImporters.length); - assertEquals("Wrong importer", importerExporter2, origImporters[0]); + assertNotNull("No importers found", origImporters); //$NON-NLS-1$ + assertEquals("Wrong number of importers", 1, origImporters.length); //$NON-NLS-1$ + assertEquals("Wrong importer", importerExporter2, origImporters[0]); //$NON-NLS-1$ ExportedPackage[] newExportedPackages = pa.getExportedPackages("exporter.importer.test"); //$NON-NLS-1$ assertNotNull("No exporter.importer.test found", newExportedPackages); //$NON-NLS-1$ assertEquals("Wrong number of exports", 1, newExportedPackages.length); //$NON-NLS-1$ exporter = newExportedPackages[0].getExportingBundle(); - assertEquals("Wrong exporter", importerExporter1, exporter); + assertEquals("Wrong exporter", importerExporter1, exporter); //$NON-NLS-1$ Bundle[] newImporters = newExportedPackages[0].getImportingBundles(); - assertNotNull("No importers found", newImporters); - assertEquals("Wrong number of importers", 1, newImporters.length); - assertEquals("Wrong importer", importerExporter2, newImporters[0]); + assertNotNull("No importers found", newImporters); //$NON-NLS-1$ + assertEquals("Wrong number of importers", 1, newImporters.length); //$NON-NLS-1$ + assertEquals("Wrong importer", importerExporter2, newImporters[0]); //$NON-NLS-1$ } public void testImporterExporter02() throws BundleException { @@ -798,6 +798,17 @@ public class ClassLoadingBundleTests extends AbstractBundleTests { assertTrue("frag5 is not resolved", (frag5.getState() & Bundle.RESOLVED) != 0); //$NON-NLS-1$ } + public void testBug235958() throws BundleException { + Bundle testX = installer.installBundle("test.bug235958.x"); //$NON-NLS-1$ + Bundle testY = installer.installBundle("test.bug235958.y"); //$NON-NLS-1$ + installer.resolveBundles(new Bundle[] {testX, testY}); + try { + testX.start(); + } catch (Exception e) { + fail("Unexpected Exception", e); //$NON-NLS-1$ + } + } + // TODO temporarily disable til we can debug the build test machine on Win XP // public void testBuddyClassLoadingRegistered1() throws Exception{ // Bundle registeredA = installer.installBundle("buddy.registered.a"); diff --git a/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF index 319d20e2f..aba5bab11 100644 --- a/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.osgi/META-INF/MANIFEST.MF @@ -58,7 +58,7 @@ Bundle-Activator: org.eclipse.osgi.framework.internal.core.SystemBundleActivator Bundle-Description: %systemBundle Bundle-Copyright: %copyright Bundle-Vendor: %eclipse.org -Bundle-Version: 3.4.0.qualifier +Bundle-Version: 3.4.100.qualifier Bundle-Localization: systembundle Bundle-DocUrl: http://www.eclipse.org Eclipse-ExtensibleAPI: true diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java index b6f39854d..214368d0c 100644 --- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java +++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java @@ -225,7 +225,7 @@ public class BundleLoader implements ClassLoaderDelegate { policy = buddyList != null ? new PolicyHandler(this, buddyList) : null; } - private synchronized KeyedHashSet getImportedSources() { + private synchronized KeyedHashSet getImportedSources(KeyedHashSet visited) { if ((loaderFlags & FLAG_IMPORTSINIT) != 0) return importedSources; BundleDescription bundleDesc = proxy.getBundleDescription(); @@ -236,7 +236,7 @@ public class BundleLoader implements ClassLoaderDelegate { for (int i = 0; i < packages.length; i++) { if (packages[i].getExporter() == bundleDesc) continue; // ignore imports resolved to this bundle - PackageSource source = createExportPackageSource(packages[i]); + PackageSource source = createExportPackageSource(packages[i], visited); if (source != null) importedSources.add(source); } @@ -245,12 +245,12 @@ public class BundleLoader implements ClassLoaderDelegate { return importedSources; } - final PackageSource createExportPackageSource(ExportPackageDescription export) { + final PackageSource createExportPackageSource(ExportPackageDescription export, KeyedHashSet visited) { BundleLoaderProxy exportProxy = getLoaderProxy(export.getExporter()); if (exportProxy == null) // TODO log error!! return null; - PackageSource requiredSource = exportProxy.getBundleLoader().findRequiredSource(export.getName()); + PackageSource requiredSource = exportProxy.getBundleLoader().findRequiredSource(export.getName(), visited); PackageSource exportSource = exportProxy.createPackageSource(export, false); if (requiredSource == null) return exportSource; @@ -426,7 +426,7 @@ public class BundleLoader implements ClassLoaderDelegate { if (result != null) return result; // 3) search the imported packages - PackageSource source = findImportedSource(pkgName); + PackageSource source = findImportedSource(pkgName, null); if (source != null) { // 3) found import source terminate search at the source result = source.loadClass(name); @@ -435,7 +435,7 @@ public class BundleLoader implements ClassLoaderDelegate { throw new ClassNotFoundException(name); } // 4) search the required bundles - source = findRequiredSource(pkgName); + source = findRequiredSource(pkgName, null); if (source != null) // 4) attempt to load from source but continue on failure result = source.loadClass(name); @@ -589,12 +589,12 @@ public class BundleLoader implements ClassLoaderDelegate { if (result != null) return result; // 3) search the imported packages - PackageSource source = findImportedSource(pkgName); + PackageSource source = findImportedSource(pkgName, null); if (source != null) // 3) found import source terminate search at the source return source.getResource(name); // 4) search the required bundles - source = findRequiredSource(pkgName); + source = findRequiredSource(pkgName, null); if (source != null) // 4) attempt to load from source but continue on failure result = source.getResource(name); @@ -666,12 +666,12 @@ public class BundleLoader implements ClassLoaderDelegate { return result; // start at step 3 because of the comment above about ClassLoader#getResources // 3) search the imported packages - PackageSource source = findImportedSource(pkgName); + PackageSource source = findImportedSource(pkgName, null); if (source != null) // 3) found import source terminate search at the source return source.getResources(name); // 4) search the required bundles - source = findRequiredSource(pkgName); + source = findRequiredSource(pkgName, null); if (source != null) // 4) attempt to load from source but continue on failure result = source.getResources(name); @@ -901,7 +901,7 @@ public class BundleLoader implements ClassLoaderDelegate { if (isExportedPackage(packageName)) local = proxy.getPackageSource(packageName); else if (isSubstitutedExport(packageName)) { - result.add(findImportedSource(packageName)); + result.add(findImportedSource(packageName, visited)); return; // should not continue to required bundles in this case } // Must search required bundles that are exported first. @@ -1033,15 +1033,15 @@ public class BundleLoader implements ClassLoaderDelegate { private PackageSource findSource(String pkgName) { if (pkgName == null) return null; - PackageSource result = findImportedSource(pkgName); + PackageSource result = findImportedSource(pkgName, null); if (result != null) return result; // Note that dynamic imports are not checked to avoid aggressive wiring (bug 105779) - return findRequiredSource(pkgName); + return findRequiredSource(pkgName, null); } - private PackageSource findImportedSource(String pkgName) { - KeyedHashSet imports = getImportedSources(); + private PackageSource findImportedSource(String pkgName, KeyedHashSet visited) { + KeyedHashSet imports = getImportedSources(visited); if (imports == null) return null; synchronized (imports) { @@ -1053,7 +1053,7 @@ public class BundleLoader implements ClassLoaderDelegate { if (isDynamicallyImported(pkgName)) { ExportPackageDescription exportPackage = bundle.framework.adaptor.getState().linkDynamicImport(proxy.getBundleDescription(), pkgName); if (exportPackage != null) { - PackageSource source = createExportPackageSource(exportPackage); + PackageSource source = createExportPackageSource(exportPackage, null); synchronized (this) { if (importedSources == null) importedSources = new KeyedHashSet(false); @@ -1067,7 +1067,7 @@ public class BundleLoader implements ClassLoaderDelegate { return null; } - private PackageSource findRequiredSource(String pkgName) { + private PackageSource findRequiredSource(String pkgName, KeyedHashSet visited) { if (requiredBundles == null) return null; synchronized (requiredSources) { @@ -1075,7 +1075,8 @@ public class BundleLoader implements ClassLoaderDelegate { if (result != null) return result.isNullSource() ? null : result; } - KeyedHashSet visited = new KeyedHashSet(false); + if (visited == null) + visited = new KeyedHashSet(false); visited.add(bundle); // always add ourselves so we do not recurse back to ourselves ArrayList result = new ArrayList(3); for (int i = 0; i < requiredBundles.length; i++) { |