package net.md_5.bungee.api.plugin;

import java.net.URL;
import java.net.URLClassLoader;
import java.util.HashSet;
import java.util.Set;

public class PluginClassloader extends URLClassLoader
{

    private static final Set<PluginClassloader> allLoaders = new HashSet<>();

    public PluginClassloader(URL[] urls)
    {
        super( urls );
        allLoaders.add( this );
    }

    @Override
    protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
    {
        return loadClass0( name, resolve, true );
    }

    private Class<?> loadClass0(String name, boolean resolve, boolean checkOther) throws ClassNotFoundException
    {
        try
        {
            return super.loadClass( name, resolve );
        } catch ( ClassNotFoundException ex )
        {
        }
        if ( checkOther )
        {
            for ( PluginClassloader loader : allLoaders )
            {
                if ( loader != this )
                {
                    try
                    {
                        return loader.loadClass0( name, resolve, false );
                    } catch ( ClassNotFoundException ex )
                    {
                    }
                }
            }
        }
        throw new ClassNotFoundException( name );
    }
}

@@ -100,20 +100,16 @@
 va.util.
-Hash
 Set;%0Aimp
@@ -118,24 +118,51 @@
 t java.util.
+concurrent.CopyOnWriteArray
 Set;%0A%0Apublic
@@ -281,20 +281,105 @@
 new 
-HashSet%3C%3E();
+CopyOnWriteArraySet%3C%3E();%0A%0A    static%0A    %7B%0A        ClassLoader.registerAsParallelCapable();%0A    %7D
 %0A%0A  

Use Java 7 API to make classloader thread safe. Closes #516