diff options
author | Thomas Watson | 2017-12-15 20:12:53 +0000 |
---|---|---|
committer | Thomas Watson | 2017-12-15 20:14:02 +0000 |
commit | 847091d8de7ec31db33fa4d3d7189eb872330eba (patch) | |
tree | 250479ac58f2212bb0c2ab0d0de1c48bc53dad1f /bundles/org.eclipse.osgi/container/src/org | |
parent | 90eb309b4bf2228e6012ec868fd38f6bc550ddb3 (diff) | |
download | rt.equinox.framework-847091d8de7ec31db33fa4d3d7189eb872330eba.tar.gz rt.equinox.framework-847091d8de7ec31db33fa4d3d7189eb872330eba.tar.xz rt.equinox.framework-847091d8de7ec31db33fa4d3d7189eb872330eba.zip |
Bug 528422 - [osgi R7] Support for Multi-Release jarsI20180101-2000I20171231-2000I20171230-1500I20171229-2000I20171228-2000I20171227-2000I20171226-2000I20171225-2000I20171224-2000I20171223-1500I20171222-2000I20171221-2000I20171220-2000I20171219-2000I20171218-2000I20171217-2000I20171216-1500I20171215-2000
Add check to prevent versioning of files under META-INF
Change-Id: Ibb7afa65e0da75c012ec024cd0d79fa774cf9f51
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles/org.eclipse.osgi/container/src/org')
4 files changed, 61 insertions, 12 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathEntry.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathEntry.java index 09ceba150..d627a496c 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathEntry.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/loader/classpath/ClasspathEntry.java @@ -102,10 +102,10 @@ public class ClasspathEntry { } List<BundleFile> mrBundleFiles = new ArrayList<>(); for (int i = storage.getRuntimeVersion().getMajor(); i > 8; i--) { - String versionPath = "META-INF/versions/" + i + '/'; //$NON-NLS-1$ + String versionPath = BundleInfo.MULTI_RELEASE_VERSIONS + i + '/'; BundleEntry versionEntry = bundlefile.getEntry(versionPath); if (versionEntry != null) { - mrBundleFiles.add(storage.createNestedBundleFile(versionPath, bundlefile, generation)); + mrBundleFiles.add(storage.createNestedBundleFile(versionPath, bundlefile, generation, BundleInfo.MULTI_RELEASE_FILTER_PREFIXES)); } } return Collections.unmodifiableList(mrBundleFiles); diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java index 286bcb7d1..e4ebfd822 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/BundleInfo.java @@ -53,6 +53,8 @@ import org.osgi.framework.Constants; public final class BundleInfo { public static final String OSGI_BUNDLE_MANIFEST = "META-INF/MANIFEST.MF"; //$NON-NLS-1$ public static final String MULTI_RELEASE_HEADER = "Multi-Release"; //$NON-NLS-1$ + public static final String MULTI_RELEASE_VERSIONS = "META-INF/versions/"; //$NON-NLS-1$ + public static final Collection<String> MULTI_RELEASE_FILTER_PREFIXES = Collections.singleton("META-INF/"); //$NON-NLS-1$ public final class Generation { private final long generationId; 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 4a1156ac8..5e759f0a0 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 @@ -1045,8 +1045,12 @@ public class Storage { } public BundleFile createNestedBundleFile(String nestedDir, BundleFile bundleFile, Generation generation) { + return createNestedBundleFile(nestedDir, bundleFile, generation, Collections.<String> emptyList()); + } + + public BundleFile createNestedBundleFile(String nestedDir, BundleFile bundleFile, Generation generation, Collection<String> filterPrefixes) { // here we assume the content is a path offset into the base bundle file; create a NestedDirBundleFile - return wrapBundleFile(new NestedDirBundleFile(bundleFile, nestedDir), generation, false); + return wrapBundleFile(new NestedDirBundleFile(bundleFile, nestedDir, filterPrefixes), generation, false); } public BundleFile wrapBundleFile(BundleFile bundleFile, Generation generation, boolean isBase) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/NestedDirBundleFile.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/NestedDirBundleFile.java index 718441417..842295272 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/NestedDirBundleFile.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/bundlefile/NestedDirBundleFile.java @@ -13,6 +13,8 @@ package org.eclipse.osgi.storage.bundlefile; import java.io.File; import java.io.IOException; +import java.util.Collection; +import java.util.Collections; import java.util.Enumeration; /** @@ -28,46 +30,87 @@ import java.util.Enumeration; */ public class NestedDirBundleFile extends BundleFile { private final BundleFile baseBundleFile; - private final String cp; + private final String nestedDirName; + private final Collection<String> filterPrefixes; /** * Constructs a NestedDirBundleFile * @param baseBundlefile the base bundle file - * @param cp + * @param nestedDirName */ - public NestedDirBundleFile(BundleFile baseBundlefile, String cp) { + public NestedDirBundleFile(BundleFile baseBundlefile, String nestedDirName) { + this(baseBundlefile, nestedDirName, Collections.<String> emptyList()); + } + + /** + * Constructs a NestedDirBundleFile + * @param baseBundlefile the base bundle file + * @param nestedDirName + * @param filterPrefixes the prefixes to filter out for the bundle file + */ + public NestedDirBundleFile(BundleFile baseBundlefile, String nestedDirName, Collection<String> filterPrefixes) { super(baseBundlefile.getBaseFile()); this.baseBundleFile = baseBundlefile; - if (cp.charAt(cp.length() - 1) != '/') { - cp = cp + '/'; + if (nestedDirName.charAt(nestedDirName.length() - 1) != '/') { + nestedDirName = nestedDirName + '/'; } - this.cp = cp; + this.nestedDirName = nestedDirName; + this.filterPrefixes = filterPrefixes; } public void close() { // do nothing. } + private boolean filterPath(String path) { + if (path.length() > 0 && path.charAt(0) == '/') + path = path.substring(1); + for (String prefix : filterPrefixes) { + if (path.startsWith(prefix)) { + return true; + } + } + return false; + } + + private boolean filterDir(String path) { + if (filterPrefixes.isEmpty()) { + return false; + } + if (path.length() > 0 && path.charAt(path.length() - 1) != '/') { + path = path + '/'; + } + return filterPath(path); + } + public BundleEntry getEntry(String path) { + if (filterPath(path)) { + return null; + } return baseBundleFile.getEntry(prependNestedDir(path)); } public boolean containsDir(String dir) { if (dir == null) return false; - + if (filterPath(dir)) { + return false; + } return baseBundleFile.containsDir(prependNestedDir(dir)); } private String prependNestedDir(String path) { if (path.length() > 0 && path.charAt(0) == '/') path = path.substring(1); - return new StringBuffer(cp).append(path).toString(); + return new StringBuffer(nestedDirName).append(path).toString(); } public Enumeration<String> getEntryPaths(String path, boolean recurse) { + if (filterDir(path)) { + return null; + } final Enumeration<String> basePaths = baseBundleFile.getEntryPaths(prependNestedDir(path), recurse); - final int cpLength = cp.length(); + final int cpLength = nestedDirName.length(); if (basePaths == null) return null; return new Enumeration<String>() { |