Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2006-08-10 12:04:04 -0400
committerThomas Watson2006-08-10 12:04:04 -0400
commit61b3228a4122ced2fb9af6fd6d7b286c38046e0e (patch)
tree1b95000cde543ccd606348f434090ebb5b493e42
parent718486e706a7674eb03ca21e45751f9793c4b82a (diff)
downloadrt.equinox.framework-61b3228a4122ced2fb9af6fd6d7b286c38046e0e.tar.gz
rt.equinox.framework-61b3228a4122ced2fb9af6fd6d7b286c38046e0e.tar.xz
rt.equinox.framework-61b3228a4122ced2fb9af6fd6d7b286c38046e0e.zip
Bug 146281 getResources method returns to many entries (in devmode)
-rw-r--r--bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/DevClassLoadingHook.java28
1 files changed, 25 insertions, 3 deletions
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/DevClassLoadingHook.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/DevClassLoadingHook.java
index b0befb8f8..43e2b8553 100644
--- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/DevClassLoadingHook.java
+++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/DevClassLoadingHook.java
@@ -19,8 +19,11 @@ import org.eclipse.osgi.baseadaptor.hooks.ClassLoadingHook;
import org.eclipse.osgi.baseadaptor.loader.*;
import org.eclipse.osgi.framework.adaptor.BundleProtectionDomain;
import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
+import org.eclipse.osgi.framework.util.KeyedElement;
-public class DevClassLoadingHook implements ClassLoadingHook, HookConfigurator {
+public class DevClassLoadingHook implements ClassLoadingHook, HookConfigurator, KeyedElement {
+ public static final String KEY = DevClassLoadingHook.class.getName();
+ public static final int HASHCODE = KEY.hashCode();
public byte[] processClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager) {
// Do nothing
@@ -28,9 +31,13 @@ public class DevClassLoadingHook implements ClassLoadingHook, HookConfigurator {
}
public boolean addClassPathEntry(ArrayList cpEntries, String cp, ClasspathManager hostmanager, BaseData sourcedata, ProtectionDomain sourcedomain) {
+ // first check that we are in devmode for this sourcedata
String[] devClassPath = !DevClassPathHelper.inDevelopmentMode() ? null : DevClassPathHelper.getDevClassPath(sourcedata.getSymbolicName());
if (devClassPath == null || devClassPath.length == 0)
return false; // not in dev mode return
+ // check that dev classpath entries have not already been added; we mark this in the first entry below
+ if (cpEntries.size() > 0 && ((ClasspathEntry) cpEntries.get(0)).getUserObject(KEY) != null)
+ return false; // this source has already had its dev classpath entries added.
boolean result = false;
for (int i = 0; i < devClassPath.length; i++) {
if (ClasspathManager.addClassPathEntry(cpEntries, devClassPath[i], hostmanager, sourcedata, sourcedomain))
@@ -38,13 +45,16 @@ public class DevClassLoadingHook implements ClassLoadingHook, HookConfigurator {
else {
// if in dev mode, try using the cp as an absolute path
ClasspathEntry entry = hostmanager.getExternalClassPath(devClassPath[i], sourcedata, sourcedomain);
- if (entry != null){
+ if (entry != null) {
cpEntries.add(entry);
result = true;
}
}
}
-
+ // mark the first entry of the list.
+ // This way we can quickly tell that dev classpath entries have been added to the list
+ if (result && cpEntries.size() > 0)
+ ((ClasspathEntry) cpEntries.get(0)).addUserObject(this);
return result;
}
@@ -73,4 +83,16 @@ public class DevClassLoadingHook implements ClassLoadingHook, HookConfigurator {
hookRegistry.addClassLoadingHook(new DevClassLoadingHook());
}
+
+ public boolean compare(KeyedElement other) {
+ return other.getKey() == KEY;
+ }
+
+ public Object getKey() {
+ return KEY;
+ }
+
+ public int getKeyHashCode() {
+ return HASHCODE;
+ }
}

Back to the top