Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2018-11-27 09:46:39 -0500
committerThomas Watson2018-11-27 09:46:39 -0500
commit2c1856c0aa73d33f15b0e6ade7c85728338b03bd (patch)
treecd96379f2cf58e6dde814458891bf417db827efc
parent04612c2b5b2ad02cefce7d96e625355298273088 (diff)
downloadrt.equinox.framework-I20181127-1800.tar.gz
rt.equinox.framework-I20181127-1800.tar.xz
rt.equinox.framework-I20181127-1800.zip
Change-Id: Ia07e253c2bf0dcfd2dbcc8c893a65cb806d40d7f Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java10
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ClassLoaderHookTests.java34
2 files changed, 40 insertions, 4 deletions
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java b/bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java
index 75bf704d5..61e86e9a0 100644
--- a/bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2017 IBM Corporation and others.
+ * Copyright (c) 2013, 2018 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -26,6 +26,7 @@ public class TestHookConfigurator implements HookConfigurator {
private static final String BAD_TRANSFORM_PROP = "classloader.hooks.a.bad.transform";
private static final String RECURSION_LOAD = "classloader.hooks.a.recursion.load";
private static final String RECURSION_LOAD_SUPPORTED = "classloader.hooks.a.recursion.load.supported";
+ private static final String FILTER_CLASS_PATHS = "classloader.hooks.a.filter.class.paths";
final ThreadLocal<Boolean> doingRecursionLoad = new ThreadLocal<Boolean>() {
protected Boolean initialValue() {
return false;
@@ -73,6 +74,13 @@ public class TestHookConfigurator implements HookConfigurator {
return Boolean.getBoolean(RECURSION_LOAD_SUPPORTED);
}
+ @Override
+ public ClasspathEntry[] getClassPathEntries(String name, ClasspathManager manager) {
+ if (Boolean.getBoolean(FILTER_CLASS_PATHS)) {
+ return new ClasspathEntry[0];
+ }
+ return super.getClassPathEntries(name, manager);
+ }
});
}
}
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ClassLoaderHookTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ClassLoaderHookTests.java
index abef0cf64..131d77a03 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ClassLoaderHookTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/hooks/framework/ClassLoaderHookTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2017 IBM Corporation and others.
+ * Copyright (c) 2013, 2018 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,12 +15,18 @@ package org.eclipse.osgi.tests.hooks.framework;
import java.io.File;
import java.net.URL;
-import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.eclipse.osgi.internal.hookregistry.HookRegistry;
import org.eclipse.osgi.tests.OSGiTestsActivator;
-import org.osgi.framework.*;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
import org.osgi.framework.hooks.weaving.WeavingHook;
import org.osgi.framework.hooks.weaving.WovenClass;
import org.osgi.framework.launch.Framework;
@@ -37,6 +43,7 @@ public class ClassLoaderHookTests extends AbstractFrameworkHookTests {
private static final String BAD_TRANSFORM_PROP = "classloader.hooks.a.bad.transform";
private static final String RECURSION_LOAD = "classloader.hooks.a.recursion.load";
private static final String RECURSION_LOAD_SUPPORTED = "classloader.hooks.a.recursion.load.supported";
+ private static final String FILTER_CLASS_PATHS = "classloader.hooks.a.filter.class.paths";
private Map<String, String> configuration;
private Framework framework;
@@ -48,6 +55,7 @@ public class ClassLoaderHookTests extends AbstractFrameworkHookTests {
setBadTransform(false);
setRecursionLoad(false);
setRecursionLoadSupported(false);
+ setFilterClassPaths(false);
String loc = bundleInstaller.getBundleLocation(HOOK_CONFIGURATOR_BUNDLE);
loc = loc.substring(loc.indexOf("file:"));
classLoader.addURL(new URL(loc));
@@ -88,6 +96,10 @@ public class ClassLoaderHookTests extends AbstractFrameworkHookTests {
System.setProperty(RECURSION_LOAD_SUPPORTED, Boolean.toString(value));
}
+ private void setFilterClassPaths(boolean value) {
+ System.setProperty(FILTER_CLASS_PATHS, Boolean.toString(value));
+ }
+
public void testRejectTransformationFromWeavingHook() throws Exception {
setRejectTransformation(true);
initAndStartFramework();
@@ -165,4 +177,20 @@ public class ClassLoaderHookTests extends AbstractFrameworkHookTests {
});
refreshSignal.await(30, TimeUnit.SECONDS);
}
+
+ public void testFilterClassPaths() throws Exception {
+ setFilterClassPaths(false);
+ initAndStartFramework();
+ Bundle b = installBundle();
+ b.loadClass(TEST_CLASSNAME);
+
+ setFilterClassPaths(true);
+ refreshBundles(Collections.singleton(b));
+ try {
+ b.loadClass(TEST_CLASSNAME);
+ fail("Expected a ClassNotFoundException.");
+ } catch (ClassNotFoundException e) {
+ // expected
+ }
+ }
}

Back to the top