Here you can find the source of getClassLoaders(ClassLoader baseClassLoader)
private static Collection<URLClassLoader> getClassLoaders(ClassLoader baseClassLoader)
//package com.java2s; //License from project: Apache License import java.net.URLClassLoader; import java.util.*; public class Main { private static Collection<URLClassLoader> getClassLoaders(ClassLoader baseClassLoader) { Collection<URLClassLoader> loaders = new ArrayList<URLClassLoader>(8); ClassLoader loader = baseClassLoader; while (loader != null) { if ("sun.misc.Launcher$ExtClassLoader".equals(loader.getClass().getName())) { break; }// w ww . ja v a 2 s . c o m if (loader instanceof URLClassLoader) { loaders.add((URLClassLoader) loader); } loader = loader.getParent(); } return loaders; } }