Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 88128 | Differences between
and this patch

Collapse All | Expand All

(-)core/framework/org/eclipse/osgi/framework/internal/core/BundleHost.java (-3 / +1 lines)
Lines 545-554 Link Here
545
			return;
545
			return;
546
		// First close the BundleLoader
546
		// First close the BundleLoader
547
		BundleLoader loader = proxy.getBasicBundleLoader();
547
		BundleLoader loader = proxy.getBasicBundleLoader();
548
		if (loader != null) {
548
		if (loader != null)
549
			loader.clear();
550
			loader.close();
549
			loader.close();
551
		}
552
		proxy.setStale();
550
		proxy.setStale();
553
		// if proxy is not null then make sure to unset user object
551
		// if proxy is not null then make sure to unset user object
554
		// associated with the proxy in the state
552
		// associated with the proxy in the state
(-)core/framework/org/eclipse/osgi/framework/internal/core/BundleLoader.java (-36 / +16 lines)
Lines 33-38 Link Here
33
public class BundleLoader implements ClassLoaderDelegate {
33
public class BundleLoader implements ClassLoaderDelegate {
34
	public final static String DEFAULT_PACKAGE = "."; //$NON-NLS-1$
34
	public final static String DEFAULT_PACKAGE = "."; //$NON-NLS-1$
35
	public final static String JAVA_PACKAGE = "java."; //$NON-NLS-1$
35
	public final static String JAVA_PACKAGE = "java."; //$NON-NLS-1$
36
	public final static byte FLAG_IMPORTSINIT = 0x01;
37
	public final static byte FLAG_HASDYNAMICIMPORTS = 0x02;
38
	public final static byte FLAG_HASDYNAMICEIMPORTALL = 0x04;
39
	public final static byte FLAG_CLOSED = 0x08;
36
40
37
	/* the proxy */
41
	/* the proxy */
38
	BundleLoaderProxy proxy;
42
	BundleLoaderProxy proxy;
Lines 44-56 Link Here
44
48
45
	/* cache of imported packages. Key is packagename, Value is PackageSource */
49
	/* cache of imported packages. Key is packagename, Value is PackageSource */
46
	KeyedHashSet importedSources;
50
	KeyedHashSet importedSources;
47
	boolean importsInit = false;
48
	/* cache of required package sources. Key is packagename, value is PackageSource */
51
	/* cache of required package sources. Key is packagename, value is PackageSource */
49
	KeyedHashSet requiredSources;
52
	KeyedHashSet requiredSources;
50
	/* flag that indicates this bundle has dynamic imports */
51
	boolean hasDynamicImports = false;
52
	/* If true, import all packages dynamically. */
53
	boolean dynamicImportPackageAll;
54
	/* If not null, list of package stems to import dynamically. */
53
	/* If not null, list of package stems to import dynamically. */
55
	String[] dynamicImportPackageStems;
54
	String[] dynamicImportPackageStems;
56
	/* If not null, list of package names to import dynamically. */
55
	/* If not null, list of package names to import dynamically. */
Lines 61-66 Link Here
61
	BundleLoaderProxy[] requiredBundles;
60
	BundleLoaderProxy[] requiredBundles;
62
	/* List of indexes into the requiredBundles list of reexported bundles */
61
	/* List of indexes into the requiredBundles list of reexported bundles */
63
	int[] reexportTable;
62
	int[] reexportTable;
63
	/* loader flags */
64
	byte loaderFlags = 0;
64
65
65
	/**
66
	/**
66
	 * Returns the package name from the specified class name.
67
	 * Returns the package name from the specified class name.
Lines 172-178 Link Here
172
	}
173
	}
173
174
174
	private synchronized void addImportedPackages(ExportPackageDescription[] packages) {
175
	private synchronized void addImportedPackages(ExportPackageDescription[] packages) {
175
		if (importsInit)
176
		if ((loaderFlags & FLAG_IMPORTSINIT) != 0)
176
			return;
177
			return;
177
		if (packages != null && packages.length > 0) {
178
		if (packages != null && packages.length > 0) {
178
			if (importedSources == null)
179
			if (importedSources == null)
Lines 183-189 Link Here
183
					importedSources.add(source);
184
					importedSources.add(source);
184
			}
185
			}
185
		}
186
		}
186
		importsInit = true;
187
		loaderFlags |= FLAG_IMPORTSINIT;
187
	}
188
	}
188
189
189
	final PackageSource createExportPackageSource(ExportPackageDescription export) {
190
	final PackageSource createExportPackageSource(ExportPackageDescription export) {
Lines 232-245 Link Here
232
	 *
233
	 *
233
	 */
234
	 */
234
	void close() {
235
	void close() {
235
		if (bundle == null)
236
		if ((loaderFlags & FLAG_CLOSED) != 0)
236
			return;
237
			return;
237
		importedSources = null;
238
239
		if (classloader != null)
238
		if (classloader != null)
240
			classloader.close();
239
			classloader.close();
241
		classloader = null;
240
		loaderFlags |= FLAG_CLOSED; /* This indicates the BundleLoader is destroyed */
242
		bundle = null; /* This indicates the BundleLoader is destroyed */
243
	}
241
	}
244
242
245
	/**
243
	/**
Lines 348-355 Link Here
348
				}
346
				}
349
		}
347
		}
350
348
351
		if (isClosed())
352
			throw new ClassNotFoundException(name);
353
		String pkgName = getPackageName(name);
349
		String pkgName = getPackageName(name);
354
		Class result = null;
350
		Class result = null;
355
		// 3) search the imported packages
351
		// 3) search the imported packages
Lines 377-383 Link Here
377
	}
373
	}
378
374
379
	final boolean isClosed() {
375
	final boolean isClosed() {
380
		return bundle == null;
376
		return (loaderFlags & FLAG_CLOSED) != 0;
381
	}
377
	}
382
378
383
	/**
379
	/**
Lines 405-412 Link Here
405
					return result;
401
					return result;
406
			}
402
			}
407
		}
403
		}
408
		if (isClosed())
409
			return null;
410
404
411
		URL result = null;
405
		URL result = null;
412
		// 3) search the imported packages
406
		// 3) search the imported packages
Lines 447-454 Link Here
447
	 */
441
	 */
448
	public Enumeration findResources(String name) throws IOException {
442
	public Enumeration findResources(String name) throws IOException {
449
		// do not delegate to parent because ClassLoader#getResources already did and it is final!!
443
		// do not delegate to parent because ClassLoader#getResources already did and it is final!!
450
		if (isClosed())
451
			return null;
452
		if ((name.length() > 1) && (name.charAt(0) == '/')) /* if name has a leading slash */
444
		if ((name.length() > 1) && (name.charAt(0) == '/')) /* if name has a leading slash */
453
			name = name.substring(1); /* remove leading slash before search */
445
			name = name.substring(1); /* remove leading slash before search */
454
		String pkgName = getResourcePackageName(name);
446
		String pkgName = getResourcePackageName(name);
Lines 503-510 Link Here
503
	 * @return     the absolute path of the native library or null if not found
495
	 * @return     the absolute path of the native library or null if not found
504
	 */
496
	 */
505
	public String findLibrary(final String name) {
497
	public String findLibrary(final String name) {
506
		if (isClosed())
507
			return null;
508
		if (System.getSecurityManager() == null)
498
		if (System.getSecurityManager() == null)
509
			return findLocalLibrary(name);
499
			return findLocalLibrary(name);
510
		return (String) AccessController.doPrivileged(new PrivilegedAction() {
500
		return (String) AccessController.doPrivileged(new PrivilegedAction() {
Lines 595-605 Link Here
595
			return true;
585
			return true;
596
586
597
		/* quick shortcut check */
587
		/* quick shortcut check */
598
		if (!hasDynamicImports)
588
		if ((loaderFlags & FLAG_HASDYNAMICIMPORTS) == 0)
599
			return false;
589
			return false;
600
590
601
		/* "*" shortcut */
591
		/* "*" shortcut */
602
		if (dynamicImportPackageAll)
592
		if ((loaderFlags & FLAG_HASDYNAMICEIMPORTALL) != 0)
603
			return true;
593
			return true;
604
594
605
		/* match against specific names */
595
		/* match against specific names */
Lines 673-679 Link Here
673
		if (packages == null)
663
		if (packages == null)
674
			return;
664
			return;
675
665
676
		hasDynamicImports = true;
666
		loaderFlags |= FLAG_HASDYNAMICIMPORTS;
677
		// make sure importedPackages is not null;
667
		// make sure importedPackages is not null;
678
		if (importedSources == null) {
668
		if (importedSources == null) {
679
			importedSources = new KeyedHashSet(10, false);
669
			importedSources = new KeyedHashSet(10, false);
Lines 708-714 Link Here
708
			if (isDynamicallyImported(name))
698
			if (isDynamicallyImported(name))
709
				continue;
699
				continue;
710
			if (name.equals("*")) { /* shortcut *///$NON-NLS-1$
700
			if (name.equals("*")) { /* shortcut *///$NON-NLS-1$
711
				dynamicImportPackageAll = true;
701
				loaderFlags |= FLAG_HASDYNAMICEIMPORTALL;
712
				return;
702
				return;
713
			}
703
			}
714
704
Lines 744-759 Link Here
744
			addDynamicImportPackage((String[]) dynamicImports.toArray(new String[dynamicImports.size()]));
734
			addDynamicImportPackage((String[]) dynamicImports.toArray(new String[dynamicImports.size()]));
745
	}
735
	}
746
736
747
	final void clear() {
748
		exportedPackages = null;
749
		requiredBundles = null;
750
		requiredSources = null;
751
		reexportTable = null;
752
		importedSources = null;
753
		dynamicImportPackages = null;
754
		dynamicImportPackageStems = null;
755
	}
756
757
	final void attachFragment(BundleFragment fragment) throws BundleException {
737
	final void attachFragment(BundleFragment fragment) throws BundleException {
758
		if (classloader == null)
738
		if (classloader == null)
759
			return;
739
			return;
Lines 779-785 Link Here
779
	}
759
	}
780
760
781
	private PackageSource findImportedSource(String pkgName) {
761
	private PackageSource findImportedSource(String pkgName) {
782
		if (!importsInit)
762
		if ((loaderFlags & FLAG_IMPORTSINIT) == 0)
783
			addImportedPackages(proxy.getBundleDescription().getResolvedImports());
763
			addImportedPackages(proxy.getBundleDescription().getResolvedImports());
784
		return importedSources == null ? null : (PackageSource) importedSources.getByKey(pkgName);
764
		return importedSources == null ? null : (PackageSource) importedSources.getByKey(pkgName);
785
	}
765
	}
(-)defaultAdaptor/src/org/eclipse/osgi/framework/adaptor/core/AbstractFrameworkAdaptor.java (+2 lines)
Lines 202-207 Link Here
202
	protected abstract void persistNextBundleID(long value) throws IOException;
202
	protected abstract void persistNextBundleID(long value) throws IOException;
203
203
204
	public FrameworkLog getFrameworkLog() {
204
	public FrameworkLog getFrameworkLog() {
205
		if (frameworkLog == null)
206
			frameworkLog = createFrameworkLog();
205
		return frameworkLog;
207
		return frameworkLog;
206
	}
208
	}
207
209

Return to bug 88128