Handles the case where a class loader is dropped.
325042
public void environmentStop(EnvironmentClassLoader loader)
  {
    Object obj = _objRef.get();
    if (obj == null)
      return;
    
    try {
      _preDestroy.invoke(obj, (Object []) null);
    } catch (Throwable e) {
      log.log(Level.WARNING, e.toString(), e);
    }
  }
1045790
public void handleLoadInstruction(LoadInstruction obj) {
        int numProduced = obj.produceStack(cpg);
        if (numProduced == Const.UNPREDICTABLE) {
            throw new InvalidBytecodeException("Unpredictable stack production");
        }

        int index = obj.getIndex() + numProduced;

        // Load values from locals in reverse order.
        // This restores them to the stack in a way consistent
        // with visitStoreInstruction().
        while (numProduced-- > 0) {
            Value value = frame.getValue(--index);
            frame.pushValue(value);
        }
    }
973537
def _handle_streamer_finished(self, index, succeeded, highest_ack):
        """"""

        self._logger.debug("Rolling back streamer %d after streaming, highest ack from streaming subsystem was %d", index, highest_ack)
        self.acknowledge_streamer(index, highest_ack, False)
34890
Class<?> loadClass(String requestedClass, boolean initialize) throws ClassNotFoundException {
    String binaryName = requestedClass;
    while (true) {
      try {
        return Class.forName(binaryName, initialize, classLoader);
      } catch (ClassNotFoundException e) {
        if (!binaryName.contains(".")) {
          throw e;
        } else {
          binaryName = replaceLastPeriodWithDollar(binaryName);
        }
      }
    }
  }
1050886
public static Class get(String clazzname, ClassLoader loader) throws ClassNotFoundException {
        return Util.loadClass(clazzname, loader != null? loader : ClassConfigurator.class.getClassLoader());
    }
1264393
public static void findClassLoaderOrder(final ClassLoader classLoader,
            final ClassLoaderOrder classLoaderOrder) {
        // The Restart classloader is a parent-last classloader, so need to delegate to the context
        // classloader(s) before the parent.
        classLoaderOrder.delegateTo(Thread.currentThread().getContextClassLoader(), /* isParent = */ false);
        classLoaderOrder.delegateTo(ClassGraph.class.getClassLoader(), /* isParent = */ false);
        // Also delegate to system classloader, in case the above two are actually the same as `classLoader`
        classLoaderOrder.delegateTo(ClassLoader.getSystemClassLoader(), /* isParent = */ true);
        // Finally delegate to the parent of the RestartClassLoader, in case that is different from
        // SystemClassLoader
        classLoaderOrder.delegateTo(classLoader.getParent(), /* isParent = */ true);
    }
127615
private void deploy(ClassLoader cl, String name) throws Throwable
   {
      if (cl == null)
         throw new IllegalArgumentException("ClassLoader is null");

      if (name == null)
         throw new IllegalArgumentException("Name is null");

      URL url = cl.getResource(name);

      if (url == null)
         throw new IllegalArgumentException("Resource is null");

      log.debugf("Deploying: %s", url);

      kernel.getMainDeployer().deploy(url);
   }
402609
public void handleLostConnection() {
        try {
            clientEngine.applySelector(ClientSelectors.any());
        } catch (Exception e) {
            LOGGER.warning("Could not clean up client B/W list filtering.", e);
        }
    }
537791
public static final void destroy() {
		if (CClassLoader.rootLoader == null) {
			return;
		}
		System.out.println("Destroying YAHP ClassLoader Tree");

		CClassLoader.urlLoader = null;

		try {
			Field f = Class.forName("java.lang.Shutdown").getDeclaredField(
					"hooks");
			f.setAccessible(true);
			ArrayList l = (ArrayList) f.get(null);
			for (Iterator it = l.iterator(); it.hasNext();) {
				Object o = it.next();
				if ((o != null)
						&& (o.getClass().getClassLoader() != null)
						&& (o.getClass().getClassLoader().getClass() == CClassLoader.class)) {
					it.remove();
				}
			}
		} catch (Throwable ignore) {
		}

		try {
			Field f = Class.forName("java.lang.ApplicationShutdownHooks")
					.getDeclaredField("hooks");
			f.setAccessible(true);
			IdentityHashMap l = (IdentityHashMap) f.get(null);
			for (Iterator it = l.entrySet().iterator(); it.hasNext();) {
				Entry e = (Entry) it.next();
				Thread o = (Thread) e.getKey();
				if ((o != null)
						&& (o.getClass().getClassLoader() != null)
						&& (o.getClass().getClassLoader().getClass() == CClassLoader.class)) {
					it.remove();
					continue;
				}
				o = (Thread) e.getValue();
				if ((o != null)
						&& (o.getClass().getClassLoader() != null)
						&& (o.getClass().getClassLoader().getClass() == CClassLoader.class)) {
					it.remove();
				}
			}
		} catch (Throwable ignore) {
		}

		try {
			if ((UIManager.getLookAndFeel() != null)
					&& (UIManager.getLookAndFeel().getClass().getClassLoader() != null)
					&& (UIManager.getLookAndFeel().getClass().getClassLoader()
							.getClass() == CClassLoader.class)) {
				UIManager.setLookAndFeel((LookAndFeel) null);
			}
			Field f = UIManager.class.getDeclaredField("currentLAFState");
			f.setAccessible(true);
			Object lafstate = f.get(null);
			if (lafstate != null) {
				Field fmultiUIDefaults = lafstate.getClass().getDeclaredField(
						"multiUIDefaults");
				fmultiUIDefaults.setAccessible(true);
				Object multiUIDefaults = fmultiUIDefaults.get(lafstate);
				Method clear = multiUIDefaults.getClass().getDeclaredMethod(
						"clear", (Class[]) null);
				clear.setAccessible(true);
				clear.invoke(multiUIDefaults, (Object[]) null);
				Field tbl = lafstate.getClass().getDeclaredField("tables");
				tbl.setAccessible(true);
				Hashtable[] tables = (Hashtable[]) tbl.get(lafstate);
				if (tables != null) {
					for (int i = 0; i < tables.length; i++) {
						Hashtable element = tables[i];
						if (element != null) {
							element.clear();
						}
					}
				}
			}
		} catch (Throwable ignore) {
		}

		try {
			Hashtable tb = UIManager.getDefaults();
			Object cl = tb.get("ClassLoader");
			if (cl.getClass() == CClassLoader.class) {
				tb.put("ClassLoader", CClassLoader.rootLoader.getParent());
			}
		} catch (Throwable ignore) {
		}

		Method logFactoryRelease = null;

		try {
			logFactoryRelease = CClassLoader.rootLoader.loadClass(
					"org.apache.commons.logging.LogFactory").getMethod(
					"release", new Class[] { ClassLoader.class });
		} catch (final Throwable ignore) {
		}

		CClassLoader.rootLoader._destroy(logFactoryRelease);
		CClassLoader.mandatoryLoadersMap.clear();
		CClassLoader.rootLoader = null;

		// deregister any sql driver loaded
		try {
			final List deregisterList = new ArrayList();
			for (final Enumeration it = DriverManager.getDrivers(); it
					.hasMoreElements();) {
				final Driver d = (Driver) it.nextElement();

				if ((d != null)
						&& (d.getClass().getClassLoader() != null)
						&& (d.getClass().getClassLoader().getClass() == CClassLoader.class)) {
					deregisterList.add(d);
				}
			}

			for (int i = 0; i < deregisterList.size(); i++) {
				final Driver driver = (Driver) deregisterList.get(i);
				DriverManager.deregisterDriver(driver);
			}
		} catch (final Throwable ignore) {
		}

		// stop dandling thread created with this classloader
		// tested only on sun jdk
		ThreadGroup tg = Thread.currentThread().getThreadGroup();
		while ((tg != null) && (tg.getParent() != null)) {
			tg = tg.getParent();
		}
		List ltg = new ArrayList();
		ltg.add(tg);
		CClassLoader.getThreadGroups(tg, ltg);
		for (int ii = 0; ii < ltg.size(); ii++) {
			try {
				final ThreadGroup g = (ThreadGroup) ltg.get(ii);
				final Field fthreads = ThreadGroup.class
						.getDeclaredField("threads");
				fthreads.setAccessible(true);

				final List toStop = new ArrayList();
				Object threads[] = null;

				if (fthreads.getType() == Vector.class) {
					// in gnu classpath
					threads = ((Vector) fthreads.get(g)).toArray();
				} else {
					// sun
					threads = (Object[]) fthreads.get(g);
				}

				for (int i = 0; i < threads.length; i++) {
					if (threads[i] == null) {
						continue;
					}
					if ((threads[i] != null)
							&& (((Thread) threads[i]).getContextClassLoader() != null)
							&& (((Thread) threads[i]).getContextClassLoader()
									.getClass() == CClassLoader.class)) {
						((Thread) threads[i]).setContextClassLoader(null);
					}
					if ((threads[i] != null)
							&& (threads[i].getClass().getClassLoader() != null)
							&& (threads[i].getClass().getClassLoader()
									.getClass() == CClassLoader.class)) {
						toStop.add((Thread) threads[i]);
					}

					// remove any object in threadLocal referring an object
					// loaded
					// by this classloader tree
					try {
						final Field fthreadLocals = Thread.class
								.getDeclaredField("threadLocals");
						fthreadLocals.setAccessible(true);

						final Object threadLocals = fthreadLocals
								.get(threads[i]);
						if (threadLocals != null) {
							final Field ftable = threadLocals.getClass()
									.getDeclaredField("table");
							ftable.setAccessible(true);

							final Object table[] = (Object[]) ftable
									.get(threadLocals);

							for (int kk = 0; kk < table.length; kk++) {
								final Object element = table[kk];
								if (element != null) {
									final Field fvalue = element.getClass()
											.getDeclaredField("value");
									fvalue.setAccessible(true);

									final Object value = fvalue.get(element);

									if ((value != null)
											&& (value.getClass()
													.getClassLoader() != null)
											&& (value.getClass()
													.getClassLoader()
													.getClass() == CClassLoader.class)) {
										fvalue.set(element, null);
									}
									if (value instanceof Map) {
										clearMap((Map)value);
									} else if (value instanceof List) {
										clearList((List)value);
									} else if (value instanceof Set) {
										clearSet((Set)value);
									} else if (value instanceof Object[]) {
										clearArray((Object[])value);
									}

									fvalue.setAccessible(false);
								}
							}
							ftable.setAccessible(false);
						}
						fthreadLocals.setAccessible(false);
					} catch (final Throwable ignore) {
						ignore.printStackTrace();
					}

					// remove any object in threadLocal referring an object
					// loaded
					// by this classloader tree
					try {
						final Field fthreadLocals = Thread.class
								.getDeclaredField("inheritableThreadLocals");
						fthreadLocals.setAccessible(true);

						final Object threadLocals = fthreadLocals
								.get(threads[i]);
						if (threadLocals != null) {
							final Field ftable = threadLocals.getClass()
									.getDeclaredField("table");
							ftable.setAccessible(true);

							final Object table[] = (Object[]) ftable
									.get(threadLocals);

							for (int kk = 0; kk < table.length; kk++) {
								final Object element = table[kk];
								if (element != null) {
									final Field fvalue = element.getClass()
											.getDeclaredField("value");
									fvalue.setAccessible(true);

									final Object value = fvalue.get(element);

									if ((value != null)
											&& (value.getClass()
													.getClassLoader() != null)
											&& (value.getClass()
													.getClassLoader()
													.getClass() == CClassLoader.class)) {
										fvalue.set(element, null);
									}
									if (value instanceof Map) {
										clearMap((Map)value);
									} else if (value instanceof List) {
										clearList((List)value);
									} else if (value instanceof Set) {
										clearSet((Set)value);
									} else if (value instanceof Object[]) {
										clearArray((Object[])value);
									}

									fvalue.setAccessible(false);
								}
							}

							ftable.setAccessible(false);
						}
						fthreadLocals.setAccessible(false);
					} catch (final Throwable ignore) {
						ignore.printStackTrace();
					}

					// remove any protection domain referring this loader tree
					try {
						final Field finheritedAccessControlContext = Thread.class
								.getDeclaredField("inheritedAccessControlContext");
						finheritedAccessControlContext.setAccessible(true);

						final Object inheritedAccessControlContext = finheritedAccessControlContext
								.get(threads[i]);

						if (inheritedAccessControlContext != null) {
							final Field fcontext = AccessControlContext.class
									.getDeclaredField("context");
							fcontext.setAccessible(true);

							final Object context[] = (Object[]) fcontext
									.get(inheritedAccessControlContext);

							if (context != null) {
								for (int k = 0; k < context.length; k++) {
									if (context[k] == null) continue;
									final Field fclassloader = ProtectionDomain.class
											.getDeclaredField("classloader");
									fclassloader.setAccessible(true);

									final Object classloader = fclassloader
											.get(context[k]);

									if ((classloader != null)
											&& (classloader.getClass() == CClassLoader.class)) {
										context[k] = null;
									}

									fclassloader.setAccessible(false);
								}
							}

							fcontext.setAccessible(false);
						}

						finheritedAccessControlContext.setAccessible(false);
					} catch (final Throwable ignore) {
						ignore.printStackTrace();
					}
				}

				fthreads.setAccessible(false);
				for (int i = 0; i < toStop.size(); i++) {
					try {
						final Thread t = (Thread) toStop.get(i);
						final Method stop = t.getClass().getMethod("stop",
								(Class[]) null);
						stop.invoke(t, (Object[]) null);
					} catch (final Throwable ignore) {
					}
				}
			} catch (final Throwable ignore) {
			}
		}
		try{CThreadContext.destroy();}catch(Throwable ignore){}
		System.runFinalization();
		System.gc();
		Introspector.flushCaches();
		System.out.println("Destroying YAHP ClassLoader Tree : done");
	}
154131
public void environmentStop(EnvironmentClassLoader loader)
  {
    Object resource = _resourceRef.get();
    if (resource == null)
      return;
    
    Method destroy = getStopMethod(resource.getClass());

    if (destroy == null)
      return;
    
    try {
      destroy.invoke(resource, (Object []) null);
    } catch (Throwable e) {
      log.log(Level.WARNING, e.toString(), e);
    }
  }
787334
@SuppressWarnings("unused")
    private static void releaseRenderer() 
    {
        if (log.isLoggable(Level.FINEST))
        {
            log.finest("releaseRenderer rendererMap -> " + delegateRendererMap.toString());
        }
        
        
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        
        if (log.isLoggable(Level.FINEST))
        {
            log.finest("releaseRenderer classLoader -> " + classLoader.toString() );
            log.finest("releaseRenderer renderer -> " + delegateRendererMap.get(classLoader));
        }
        
        
        delegateRendererMap.remove(classLoader);
        
        if (log.isLoggable(Level.FINEST))
        {
            log.finest("releaseRenderer renderMap -> " + delegateRendererMap.toString());
        }
        
    }
519828
def dropped(self, component, event):
        
        if isinstance(component, AbstractStimulusComponent):
            row, col = self.splitAt(event.pos())
            index = self.model().createIndex(row, col, component)
            
            self.model().insertComponent(index, component)

            if isinstance(event.source(), DragLabel):
                if component.__class__.__name__ in self._componentDefaults:
                    component.loadState(self._componentDefaults[component.__class__.__name__])
                self.edit(index)

            self._viewIsDirty = True
            self.viewport().update()
1360731
@Override
  public void classLoaderDestroy(DynamicClassLoader loader)
  {
    removeLoader(loader);

    _localHandlers.remove(loader);

    HandlerEntry ownHandlers = _ownHandlers.getLevel(loader);
    if (ownHandlers != null)
      _ownHandlers.remove(loader);

    if (ownHandlers != null)
      ownHandlers.destroy();

    if (_localLevel != null)
      _localLevel.remove(loader);

    updateEffectiveLevel(_systemClassLoader);
  }
1085735
public static void destroy() {
		try {
			countMutex.acquire();
			for (int i=0;i<fileToDeleteOnDestroy.size();i++) {
				File f = (File)fileToDeleteOnDestroy.get(i);
				if (f != null && f.exists())
					try{f.delete();}catch(Exception ignore){}
			}
			CClassLoader.destroy();
		} // end try
		finally {
			countInstance = 0;

			try {
				countMutex.release();
			} // end try
			catch (final Exception e) {}
		} // end finally
	}
1179722
public function handleFatalError()
    {
        unset($this->_memoryReserve);

        // load ErrorException manually here because autoloading them will not work
        // when error occurs while autoloading a class
        if (!class_exists(ErrorException::class, false)) {
            require_once __DIR__ . '/../exceptions/ErrorException.php';
        }

        $error = error_get_last();

        if (ErrorException::isFatalError($error)) {
            $exception = new ErrorException($error['message'], $error['type'], $error['type'], $error['file'], $error['line']);
            $this->exception = $exception;

            $this->logException($exception);

            if ($this->discardExistingOutput) {
                $this->clearOutput();
            }
            $this->renderException($exception);

            // need to explicitly flush logs because exit() next will terminate the app immediately
            $this->profiler->flush();
            $this->flushLogger();
            exit(1);
        }
    }
1240266
public function handleShutdown()
	{
		$error = error_get_last();

		// If an error has occurred that has not been displayed, we will create a fatal
		// error exception instance and pass it into the regular exception handling
		// code so it can be displayed back out to the developer for information.
		if ( ! is_null($error))
		{
			extract($error);

			if ( ! $this->isFatal($type)) return;

			$this->handleException(new FatalError($message, $type, 0, $file, $line))->send();
		}
	}
11451
private static void handleResourceLoader(final Object resourceLoader, final ClassLoader classLoader,
            final ClasspathOrder classpathOrderOut, final ScanSpec scanSpec, final LogNode log) {
        if (resourceLoader == null) {
            return;
        }
        // PathResourceLoader has root field, which is a Path object
        final Object root = ReflectionUtils.getFieldVal(resourceLoader, "root", false);
        // type VirtualFile
        final File physicalFile = (File) ReflectionUtils.invokeMethod(root, "getPhysicalFile", false);
        String path = null;
        if (physicalFile != null) {
            final String name = (String) ReflectionUtils.invokeMethod(root, "getName", false);
            if (name != null) {
                // getParentFile() removes "contents" directory
                final File file = new File(physicalFile.getParentFile(), name);
                if (FileUtils.canRead(file)) {
                    path = file.getAbsolutePath();
                } else {
                    // This is an exploded jar or classpath directory
                    path = physicalFile.getAbsolutePath();
                }
            } else {
                path = physicalFile.getAbsolutePath();
            }
        } else {
            path = (String) ReflectionUtils.invokeMethod(root, "getPathName", false);
            if (path == null) {
                // Try Path or File
                final File file = root instanceof Path ? ((Path) root).toFile()
                        : root instanceof File ? (File) root : null;
                if (file != null) {
                    path = file.getAbsolutePath();
                }
            }
        }
        if (path == null) {
            final File file = (File) ReflectionUtils.getFieldVal(resourceLoader, "fileOfJar", false);
            if (file != null) {
                path = file.getAbsolutePath();
            }
        }
        if (path != null) {
            classpathOrderOut.addClasspathEntry(path, classLoader, scanSpec, log);
        } else {
            if (log != null) {
                log.log("Could not determine classpath for ResourceLoader: " + resourceLoader);
            }
        }
    }