Overlay the entire path with a new class loader.
Set the base path to the user path + base path.

No point in including the boot class path (can't reload thos).
978197
@Override
    public void reloadAllClasses() throws ClassPathException
    {
        BshClassPath bcp = new BshClassPath("temp");
        bcp.addComponent( baseClassPath );
        bcp.addComponent( BshClassPath.getUserClassPath() );
        setClassPath( bcp.getPathComponents() );
    }
915687
public void expandClasspath(File... files) {
        ClassLoader classLoader = ClassLoader.getSystemClassLoader();
        Class<URLClassLoader> urlClass = URLClassLoader.class;
        for (File file: files) {
            LOGGER.info("Expanding classpath to include: " + file.getAbsolutePath());
            URI fileUri = file.toURI();
            try {
                Method method = urlClass.getDeclaredMethod("addURL", URL.class);
                method.setAccessible(true);
                method.invoke(classLoader, fileUri.toURL());
            } catch (MalformedURLException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
                LOGGER.error("Error expanding classpath", e);
            }
        }
    }
705955
def add_path(self, path):
        

        if os.path.exists(path):
            self.paths.add(path)
            return path
        else:
            #logger.debug('Path {} doesn\'t exist'.format(path))
            return None
1201989
public function setup_from_path() {
		$this->file = basename( $this->basefile );
		$dir        = dirname( $this->basefile );
		$this->slug = basename( $dir );
		$exts       = explode( '.', $this->basefile );
		$ext        = $exts[ count( $exts ) - 1 ];
		if ( 'css' === $ext ) {
			$this->type = 'theme';
		}
		if ( 'php' === $ext ) {
			$this->type = 'plugin';
		}
		$this->key = self::key_ready_name( $this->slug );
	}
77344
public static DynamicClassLoader create(ClassLoader parent,
                                          PathImpl path)
  {
    DynamicClassLoader loader = new DynamicClassLoader(parent, false, false);

    loader.addLoader(new SimpleLoader(loader, path));

    loader.init();
    
    return loader;
  }
288387
def load_target(cls, scheme, path, fragment, username,
                    password, hostname, port, query,
                    load_method, **kwargs):
        
        raise NotImplementedError("load_target must be overridden")
836350
private Path relPathToRoot(Path fullPath, Path root) {
    // just take some effort to do it 
    // rather than just using substring 
    // so that we do not break sometime later
    Path justRoot = new Path(Path.SEPARATOR);
    if (fullPath.depth() == root.depth()) {
      return justRoot;
    }
    else if (fullPath.depth() > root.depth()) {
      Path retPath = new Path(fullPath.getName());
      Path parent = fullPath.getParent();
      for (int i=0; i < (fullPath.depth() - root.depth() -1); i++) {
        retPath = new Path(parent.getName(), retPath);
        parent = parent.getParent();
      }
      return new Path(justRoot, retPath);
    }
    return null;
  }
399756
def __load_paths(self, base_path=None):
        
        if base_path is None:
            base_path = dirname(dirname(dirname(__file__)))
        if not base_path.endswith(sep):
            base_path += sep
        self.__paths = {
            'base': base_path,
            'cert': base_path + 'certs' + sep,
            'lib': base_path + 'lib' + sep,
            'extlib': base_path + 'extlib' + sep,
        }
324822
def register_path(self, path):
        
        self._paths.insert(0, os.path.abspath(path))
19213
def set_path (self, path):
        
        assert isinstance(path, basestring)
        self.path_ = os.path.normpath(path)
375331
def path_expand(cls, path):
        
        current_dir = "." + os.path.sep
        if path.startswith(current_dir):
            cwd = str(os.getcwd())
            path = path.replace(current_dir, cwd, 1)
        location = os.path.expandvars(os.path.expanduser(path))
        return location
1183949
public static DynamicClassLoader create(ClassLoader parent,
                                          PathImpl path,
                                          String prefix)
  {
    DynamicClassLoader loader = new DynamicClassLoader(parent, false, true);

    SimpleLoader simpleLoader = new SimpleLoader(loader, path, prefix);
    simpleLoader.init();
    
    loader.addLoader(simpleLoader);

    loader.init();

    return loader;
  }
710486
private void setClassPath() throws IOException {
    String fullPath = file.getAbsolutePath();
    String rootPath = fullPath.substring(0, fullPath.lastIndexOf(classFile.getRelativePath()));
    List<File> classPath = new ArrayList<>();
    classPath.add(new File(rootPath));
    parserEnv.fileManager().setLocation(StandardLocation.CLASS_PATH, classPath);
  }
1371259
public ClassFinder addClasspath() {
    try {
      String path = System.getProperty("java.class.path");
      StringTokenizer tok = new StringTokenizer(path, File.pathSeparator);
      while (tok.hasMoreTokens())
        add(new File(tok.nextToken()));
    } catch (Exception ex) {
      log.error("Unable to get class path", ex);
    }
    return this;
  }
939370
def load_config(path, opts = {})
    opts.reverse_merge! :reconnect => true
    new_config = self.class.parse_config_file(path)
    update_config(new_config[:config]) if new_config and new_config[:config]
    reconnect(@config[:base_url], @config[:username], @config[:password]) if opts[:reconnect] and connection_info_loaded?
    @config
  end
1354536
def add_path(self, path):
        """"""
        if not os.path.exists(path):
            raise RuntimeError('Path does not exists: %s.' % path)
        self.paths.append(path)
473183
def _add_current_codedir(self, path):
        
        dirpath = self.tramp.dirname(path)
        if dirpath not in self.basepaths:
            self.basepaths.append(dirpath)
            self.rescan()