Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan2018-08-03 03:41:27 +0000
committerJan2018-08-03 03:41:27 +0000
commitcaca3292f85ac32ddb26035c1e25913481192888 (patch)
treeadb09ff46acd1ead597630c0b5f8e189de68c91a
parent4c9068b77ef45e926d343294da4ae98a6325b2d9 (diff)
downloadrt.equinox.framework-caca3292f85ac32ddb26035c1e25913481192888.tar.gz
rt.equinox.framework-caca3292f85ac32ddb26035c1e25913481192888.tar.xz
rt.equinox.framework-caca3292f85ac32ddb26035c1e25913481192888.zip
Bug 537549 - Augment "auto-detection of available packages" logic to consider all packages of automatic modules as exported
Signed-off-by: Jan Luehe <janluehe@yahoo.com>
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java20
1 files changed, 16 insertions, 4 deletions
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 6e097c601..c541e6c8a 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
@@ -1714,6 +1714,8 @@ public class Storage {
Method getDescriptor = moduleClass.getMethod("getDescriptor"); //$NON-NLS-1$
Class<?> moduleDescriptorClass = Class.forName("java.lang.module.ModuleDescriptor"); //$NON-NLS-1$
Method exports = moduleDescriptorClass.getMethod("exports"); //$NON-NLS-1$
+ Method isAutomatic = moduleDescriptorClass.getMethod("isAutomatic");
+ Method packagesMethod = moduleDescriptorClass.getMethod("packages");
Class<?> exportsClass = Class.forName("java.lang.module.ModuleDescriptor$Exports"); //$NON-NLS-1$
Method targets = exportsClass.getMethod("targets"); //$NON-NLS-1$
Method source = exportsClass.getMethod("source"); //$NON-NLS-1$
@@ -1722,10 +1724,20 @@ public class Storage {
Set<?> bootModules = (Set<?>) modules.invoke(bootLayer);
for (Object m : bootModules) {
Object descriptor = getDescriptor.invoke(m);
- for (Object export : (Set<?>) exports.invoke(descriptor)) {
- String pkg = (String) source.invoke(export);
- if (((Set<?>) targets.invoke(export)).isEmpty()) {
- packages.add(pkg);
+ if ((Boolean) isAutomatic.invoke(descriptor)) {
+ /*
+ * Automatic modules are supposed to export all their packages.
+ * However, java.lang.module.ModuleDescriptor::exports returns an empty set for them.
+ * Add all their packages (as returned by java.lang.module.ModuleDescriptor::packages)
+ * to the list of VM supplied packages.
+ */
+ packages.addAll((Set<String>) packagesMethod.invoke(descriptor));
+ } else {
+ for (Object export : (Set<?>) exports.invoke(descriptor)) {
+ String pkg = (String) source.invoke(export);
+ if (((Set<?>) targets.invoke(export)).isEmpty()) {
+ packages.add(pkg);
+ }
}
}
}

Back to the top