Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2019-11-14 17:28:50 +0000
committerThomas Watson2019-11-14 17:28:50 +0000
commita28ef7857351ad705f0947d515e95c8b6e8bcd54 (patch)
tree8cef1ca3ced5defd6076a0e6b817ec7fd06c1768
parentdf79d6707569c92d25cb2d347bab6e7ee062da58 (diff)
parenta731195ec06070c34a03d7bfd15b51bfd1fd5283 (diff)
downloadrt.equinox.framework-a28ef7857351ad705f0947d515e95c8b6e8bcd54.tar.gz
rt.equinox.framework-a28ef7857351ad705f0947d515e95c8b6e8bcd54.tar.xz
rt.equinox.framework-a28ef7857351ad705f0947d515e95c8b6e8bcd54.zip
Merge branch 'master' into osgiR8
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java2
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java57
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/Storage.java5
3 files changed, 45 insertions, 19 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java
index 5d9ced4b3..ec38d9bed 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/url/MultiplexingFactory.java
@@ -49,7 +49,7 @@ public abstract class MultiplexingFactory {
* The setAccessible class will be defined in the java.base module which grants
* it the ability to call setAccessible(true) on other types from the java.base module
*/
- static final Collection<AccessibleObject> setAccessible;
+ public static final Collection<AccessibleObject> setAccessible;
static final Collection<ClassLoader> systemLoaders;
static {
Collection<AccessibleObject> result = null;
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java
index 9cb603f64..e21515254 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/storage/FrameworkExtensionInstaller.java
@@ -14,6 +14,7 @@
package org.eclipse.osgi.storage;
import java.io.File;
+import java.lang.reflect.AccessibleObject;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
@@ -36,6 +37,7 @@ import org.eclipse.osgi.internal.framework.EquinoxConfiguration;
import org.eclipse.osgi.internal.hookregistry.ActivatorHookFactory;
import org.eclipse.osgi.internal.hookregistry.HookRegistry;
import org.eclipse.osgi.internal.messages.Msg;
+import org.eclipse.osgi.internal.url.MultiplexingFactory;
import org.eclipse.osgi.storage.BundleInfo.Generation;
import org.eclipse.osgi.storage.ContentProvider.Type;
import org.eclipse.osgi.util.NLS;
@@ -51,21 +53,32 @@ import org.osgi.resource.Capability;
public class FrameworkExtensionInstaller {
private static final ClassLoader CL = FrameworkExtensionInstaller.class.getClassLoader();
private static final Method ADD_FWK_URL_METHOD = findAddURLMethod(CL, "addURL"); //$NON-NLS-1$
+ private static final Method ADD_FWK_FILE_PATH_METHOD = ADD_FWK_URL_METHOD == null ? findAddFilePathMethod(CL, "appendToClassPathForInstrumentation") : null; //$NON-NLS-1$
private final ArrayMap<BundleActivator, Bundle> hookActivators = new ArrayMap<>(5);
private static Method findAddURLMethod(ClassLoader cl, String name) {
if (cl == null)
return null;
- return findMethod(cl.getClass(), name, new Class[] {URL.class});
+ return findMethod(cl.getClass(), name, new Class[] {URL.class}, null);
+ }
+
+ private static Method findAddFilePathMethod(ClassLoader cl, String name) {
+ if (cl == null)
+ return null;
+ return findMethod(cl.getClass(), name, new Class[] {String.class}, MultiplexingFactory.setAccessible);
}
// recursively searches a class and it's superclasses for a (potentially inaccessable) method
- private static Method findMethod(Class<?> clazz, String name, Class<?>[] args) {
+ private static Method findMethod(Class<?> clazz, String name, Class<?>[] args, Collection<AccessibleObject> setAccessible) {
if (clazz == null)
return null; // ends the recursion when getSuperClass returns null
try {
Method result = clazz.getDeclaredMethod(name, args);
- result.setAccessible(true);
+ if (setAccessible != null) {
+ setAccessible.add(result);
+ } else {
+ result.setAccessible(true);
+ }
return result;
} catch (SecurityException e) {
// if we do not have the permissions then we will not find the method
@@ -73,7 +86,7 @@ public class FrameworkExtensionInstaller {
// do nothing look in super class below
// have to avoid blowing up <clinit>
}
- return findMethod(clazz.getSuperclass(), name, args);
+ return findMethod(clazz.getSuperclass(), name, args, setAccessible);
}
private static void callAddURLMethod(URL arg) throws InvocationTargetException {
@@ -84,6 +97,14 @@ public class FrameworkExtensionInstaller {
}
}
+ private static void callAddFilePathMethod(File file) throws InvocationTargetException {
+ try {
+ ADD_FWK_FILE_PATH_METHOD.invoke(CL, new Object[] {file.getCanonicalPath()});
+ } catch (Throwable t) {
+ throw new InvocationTargetException(t);
+ }
+ }
+
private final EquinoxConfiguration configuration;
public FrameworkExtensionInstaller(EquinoxConfiguration configuraiton) {
@@ -114,32 +135,36 @@ public class FrameworkExtensionInstaller {
// framework extensions
return;
}
- if (CL == null || ADD_FWK_URL_METHOD == null) {
- // use the first revision as the blame
- ModuleRevision revision = revisions.iterator().next();
- throw new BundleException("Cannot support framework extension bundles without a public addURL(URL) method on the framework class loader: " + revision.getBundle()); //$NON-NLS-1$
- }
for (ModuleRevision revision : revisions) {
+ if (CL == null || (ADD_FWK_URL_METHOD == null && ADD_FWK_FILE_PATH_METHOD == null)) {
+ // use the first revision as the blame
+ throw new BundleException("Cannot support framework extension bundles without a public addURL(URL) or appendToClassPathForInstrumentation(String) method on the framework class loader: " + revision.getBundle()); //$NON-NLS-1$
+ }
File[] files = getExtensionFiles(revision);
-
for (File file : files) {
if (file == null) {
continue;
}
try {
- callAddURLMethod(StorageUtil.encodeFileURL(file));
+ if (ADD_FWK_URL_METHOD != null) {
+ callAddURLMethod(StorageUtil.encodeFileURL(file));
+ } else if (ADD_FWK_FILE_PATH_METHOD != null) {
+ callAddFilePathMethod(file);
+ }
} catch (InvocationTargetException | MalformedURLException e) {
throw new BundleException("Error adding extension content.", e); //$NON-NLS-1$
}
}
}
- try {
- // initialize the new urls
- CL.loadClass("thisIsNotAClass"); //$NON-NLS-1$
- } catch (ClassNotFoundException e) {
- // do nothing
+ if (CL != null) {
+ try {
+ // initialize the new urls
+ CL.loadClass("thisIsNotAClass"); //$NON-NLS-1$
+ } catch (ClassNotFoundException e) {
+ // do nothing
+ }
}
if (systemModule != null) {
BundleContext systemContext = systemModule.getBundle().getBundleContext();
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 1470c85e6..796c89437 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2018 IBM Corporation and others.
+ * Copyright (c) 2012, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Christoph Laeubrich - Bug 527175 - Storage#getSystemContent() should first make the file absolute
*******************************************************************************/
package org.eclipse.osgi.storage;
@@ -1641,7 +1642,7 @@ public class Storage {
return null;
}
// TODO assumes the location is a file URL
- File result = new File(frameworkValue.substring(5));
+ File result = new File(frameworkValue.substring(5)).getAbsoluteFile();
if (!result.exists()) {
throw new IllegalStateException("Configured framework location does not exist: " + result.getAbsolutePath()); //$NON-NLS-1$
}

Back to the top