diff options
| author | Thomas Watson | 2011-10-24 14:25:16 +0000 |
|---|---|---|
| committer | Thomas Watson | 2011-10-24 14:25:16 +0000 |
| commit | 5b71981bc75234281d9606dfa0b9e373f6c756cf (patch) | |
| tree | 4d756c25e18fb8bb5784759100f35b9bd28b9b15 | |
| parent | 01d803316a3b0303b207ff50068e67752f157510 (diff) | |
| download | rt.equinox.framework-5b71981bc75234281d9606dfa0b9e373f6c756cf.tar.gz rt.equinox.framework-5b71981bc75234281d9606dfa0b9e373f6c756cf.tar.xz rt.equinox.framework-5b71981bc75234281d9606dfa0b9e373f6c756cf.zip | |
Bug 361806 - remove support for osgi.classloader.singleThreadLoadsv20111024-1601
option
| -rw-r--r-- | bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java | 103 |
1 files changed, 2 insertions, 101 deletions
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java index fb84e7b4c..f972160de 100644 --- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java +++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/loader/BundleLoader.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -62,11 +62,6 @@ public class BundleLoader implements ClassLoaderDelegate { private static final int PRE_LIBRARY = 7; private static final int POST_LIBRARY = 8; - private static final boolean USE_GLOBAL_DEADLOCK_AVOIDANCE_LOCK = "true".equals(BundleLoaderProxy.secureAction.getProperty("osgi.classloader.singleThreadLoads")); //$NON-NLS-1$//$NON-NLS-2$ - private static final List<Object[]> waitingList = USE_GLOBAL_DEADLOCK_AVOIDANCE_LOCK ? new ArrayList<Object[]>(0) : null; - private static Object lockThread; - private static int lockCount = 0; - /* the proxy */ final private BundleLoaderProxy proxy; /* Bundle object */ @@ -423,14 +418,7 @@ public class BundleLoader implements ClassLoaderDelegate { // 1) if startsWith "java." delegate to parent and terminate search // we want to throw ClassNotFoundExceptions if a java.* class cannot be loaded from the parent. return parentCL.loadClass(name); - try { - if (USE_GLOBAL_DEADLOCK_AVOIDANCE_LOCK) - lock(createClassLoader()); - return findClassInternal(name, checkParent, parentCL); - } finally { - if (USE_GLOBAL_DEADLOCK_AVOIDANCE_LOCK) - unlock(); - } + return findClassInternal(name, checkParent, parentCL); } private Class<?> findClassInternal(String name, boolean checkParent, ClassLoader parentCL) throws ClassNotFoundException { @@ -1264,93 +1252,6 @@ public class BundleLoader implements ClassLoaderDelegate { } } - /* - * see bug 121737 - * To ensure that we do not enter a deadly embrace between classloader cycles - * we attempt to obtain a global lock before do normal osgi delegation. - * This approach ensures that only one thread has a classloader locked at a time - */ - private static void lock(Object loader) { - Thread currentThread = Thread.currentThread(); - boolean interrupted = false; - synchronized (loader) { - if (tryLock(currentThread, loader)) - return; // this thread has the lock - - do { - try { - // we wait on the loader object here to release its lock incase we have it. - // we do not way to wait while holding this lock because that will cause deadlock - loader.wait(); - } catch (InterruptedException e) { - interrupted = true; - // we still want to try again - } - } while (!tryLock(currentThread)); - } - if (interrupted) - currentThread.interrupt(); - } - - /* - * returns true if this thread can obtain the global lock or already has the lock; - * otherwise this loader and thread are added to the waitingList - */ - private synchronized static boolean tryLock(Thread currentThread, Object loader) { - if (lockThread == currentThread) { - lockCount++; - return true; - } - if (lockThread == null) { - lockCount++; - lockThread = currentThread; - return true; - } - waitingList.add(new Object[] {currentThread, loader}); - return false; - } - - /* - * returns true if this thread already has the global lock - */ - private synchronized static boolean tryLock(Thread currentThread) { - if (lockThread == currentThread) { - lockCount++; - return true; - } - return false; - } - - /* - * unlocks the global lock and notifies the first waiting thread that they - * now have the lock - */ - private static void unlock() { - Thread waitingThread = null; - Object loader = null; - synchronized (BundleLoader.class) { - lockCount--; - if (lockCount != 0) - return; - - if (waitingList.isEmpty()) { - lockThread = null; - return; - } - - Object[] waiting = waitingList.get(0); - waitingThread = (Thread) waiting[0]; - loader = waiting[1]; - } - synchronized (loader) { - synchronized (BundleLoader.class) { - lockThread = waitingThread; - waitingList.remove(0); - loader.notifyAll(); - } - } - } - static public void closeBundleLoader(BundleLoaderProxy proxy) { if (proxy == null) return; |
