package org.eclipse.osgi.internal.loader.classpath;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
import org.eclipse.osgi.container.Module;
import org.eclipse.osgi.container.ModuleCapability;
import org.eclipse.osgi.container.ModuleContainerAdaptor.ContainerEvent;
import org.eclipse.osgi.container.ModuleRevision;
import org.eclipse.osgi.container.ModuleWire;
import org.eclipse.osgi.container.namespaces.EquinoxModuleDataNamespace;
import org.eclipse.osgi.framework.util.ArrayMap;
import org.eclipse.osgi.internal.debug.Debug;
import org.eclipse.osgi.internal.framework.EquinoxConfiguration;
import org.eclipse.osgi.internal.hookregistry.ClassLoaderHook;
import org.eclipse.osgi.internal.hookregistry.HookRegistry;
import org.eclipse.osgi.internal.loader.ModuleClassLoader;
import org.eclipse.osgi.internal.loader.ModuleClassLoader.DefineClassResult;
import org.eclipse.osgi.internal.messages.Msg;
import org.eclipse.osgi.internal.weaving.WeavingHookConfigurator;
import org.eclipse.osgi.storage.BundleInfo.Generation;
import org.eclipse.osgi.storage.NativeCodeFinder;
import org.eclipse.osgi.storage.Storage;
import org.eclipse.osgi.storage.bundlefile.BundleEntry;
import org.eclipse.osgi.storage.bundlefile.BundleFile;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleException;
import org.osgi.framework.namespace.HostNamespace;
public class ClasspathManager {
private static final FragmentClasspath[] emptyFragments = new FragmentClasspath[0];
private static final String[] DEFAULT_CLASSPATH = new String[] {"."};
@SuppressWarnings("unchecked")
private static final Enumeration<URL> EMPTY_ENUMERATION = Collections.enumeration(Collections.EMPTY_LIST);
private final Generation generation;
private final ModuleClassLoader classloader;
private final HookRegistry hookRegistry;
private final Debug debug;
private final ClasspathEntry[] entries;
private volatile FragmentClasspath[] fragments;
private ArrayMap<String, String> loadedLibraries = null;
private ThreadLocal<DefineContext> currentDefineContext = new ThreadLocal<>();
public ClasspathManager(Generation generation, ModuleClassLoader classloader) {
EquinoxConfiguration configuration = generation.getBundleInfo().getStorage().getConfiguration();
this.debug = configuration.getDebug();
this.hookRegistry = configuration.getHookRegistry();
this.generation = generation;
this.classloader = classloader;
String[] cp = getClassPath(generation.getRevision());
this.fragments = buildFragmentClasspaths(this.classloader, this);
this.entries = buildClasspath(cp, this, this.generation);
}
private static String[] getClassPath(ModuleRevision revision) {
List<ModuleCapability> moduleDatas = revision.getModuleCapabilities(EquinoxModuleDataNamespace.MODULE_DATA_NAMESPACE);
@SuppressWarnings("unchecked")
List<String> cp = moduleDatas.isEmpty() ? null : (List<String>) moduleDatas.get(0).getAttributes().get(EquinoxModuleDataNamespace.CAPABILITY_CLASSPATH);
return cp == null ? DEFAULT_CLASSPATH : cp.toArray(new String[cp.size()]);
}
private FragmentClasspath[] buildFragmentClasspaths(ModuleClassLoader hostloader, ClasspathManager manager) {
if (hostloader == null) {
return emptyFragments;
}
List<ModuleWire> fragmentWires = hostloader.getBundleLoader().getWiring().getProvidedModuleWires(HostNamespace.HOST_NAMESPACE);
if (fragmentWires == null || fragmentWires.isEmpty()) {
return emptyFragments;
}
List<FragmentClasspath> result = new ArrayList<>(fragmentWires.size());
for (ModuleWire fragmentWire : fragmentWires) {
ModuleRevision revision = fragmentWire.getRequirer();
Generation fragGeneration = (Generation) revision.getRevisionInfo();
String[] cp = getClassPath(revision);
ClasspathEntry[] fragEntries = buildClasspath(cp, manager, fragGeneration);
FragmentClasspath fragClasspath = new FragmentClasspath(fragGeneration, fragEntries);
insertFragment(fragClasspath, result);
}
return result.toArray(new FragmentClasspath[result.size()]);
}
private static void insertFragment(FragmentClasspath fragClasspath, List<FragmentClasspath> existing) {
long fragID = fragClasspath.getGeneration().getRevision().getRevisions().getModule().getId();
for (ListIterator<FragmentClasspath> iExisting = existing.listIterator(); iExisting.hasNext();) {
long otherID = iExisting.next().getGeneration().getRevision().getRevisions().getModule().getId();
if (fragID < otherID) {
iExisting.previous();
iExisting.add(fragClasspath);
return;
}
}
existing.add(fragClasspath);
}
public void close() {
for (ClasspathEntry entry : entries) {
if (entry != null) {
try {
entry.close();
}catch (IOException e) {
generation.getBundleInfo().getStorage().getAdaptor().publishContainerEvent(ContainerEvent.ERROR, generation.getRevision().getRevisions().getModule(), e);
}
}
}
FragmentClasspath[] currentFragments = getFragmentClasspaths();
for (FragmentClasspath currentFragment : currentFragments) {
currentFragment.close();
}
}
private ClasspathEntry[] buildClasspath(String[] cp, ClasspathManager hostloader, Generation source) {
ArrayList<ClasspathEntry> result = new ArrayList<>(cp.length);
for (String cpEntry : cp) {
findClassPathEntry(result, cpEntry, hostloader, source);
}
return result.toArray(new ClasspathEntry[result.size()]);
}
private void findClassPathEntry(ArrayList<ClasspathEntry> result, String cp, ClasspathManager hostloader, Generation sourceGeneration) {
List<ClassLoaderHook> loaderHooks = hookRegistry.getClassLoaderHooks();
boolean hookAdded = false;
for (ClassLoaderHook hook : loaderHooks) {
hookAdded |= hook.addClassPathEntry(result, cp, hostloader, sourceGeneration);
}
if (!addClassPathEntry(result, cp, hostloader, sourceGeneration) && !hookAdded) {
BundleException be = new BundleException(NLS.bind(Msg.BUNDLE_CLASSPATH_ENTRY_NOT_FOUND_EXCEPTION, cp, sourceGeneration.getRevision().toString()), BundleException.MANIFEST_ERROR);
sourceGeneration.getBundleInfo().getStorage().getAdaptor().publishContainerEvent(ContainerEvent.INFO, sourceGeneration.getRevision().getRevisions().getModule(), be);
}
}
public boolean addClassPathEntry(ArrayList<ClasspathEntry> result, String cp, ClasspathManager hostManager, Generation source) {
return addStandardClassPathEntry(result, cp, hostManager, source) || addEclipseClassPathEntry(result, cp, hostManager, source);
}
public static boolean addStandardClassPathEntry(ArrayList<ClasspathEntry> result, String cp, ClasspathManager hostManager, Generation generation) {
if (cp.equals(".")) {
result.add(hostManager.createClassPathEntry(generation.getBundleFile(), generation));
return true;
}
ClasspathEntry element = hostManager.getClasspath(cp, generation);
if (element != null) {
result.add(element);
return true;
}
if (hostManager.generation == generation) {
FragmentClasspath[] hostFrags = hostManager.getFragmentClasspaths();
for (FragmentClasspath fragCP : hostFrags) {
element = hostManager.getClasspath(cp, fragCP.getGeneration());
if (element != null) {
result.add(element);
return true;
}
}
}
return false;
}
private boolean addEclipseClassPathEntry(ArrayList<ClasspathEntry> result, String cp, ClasspathManager hostManager, Generation source) {
String var = hasPrefix(cp);
if (var != null)
return addInternalClassPath(var, result, cp, hostManager, source);
if (cp.startsWith(NativeCodeFinder.EXTERNAL_LIB_PREFIX)) {
cp = cp.substring(NativeCodeFinder.EXTERNAL_LIB_PREFIX.length());
ClasspathEntry cpEntry = hostManager.getExternalClassPath(source.getBundleInfo().getStorage().getConfiguration().substituteVars(cp), source);
if (cpEntry != null) {
result.add(cpEntry);
return true;
}
}
return false;
}
private boolean addInternalClassPath(String var, ArrayList<ClasspathEntry> cpEntries, String cp, ClasspathManager hostManager, Generation source) {
EquinoxConfiguration configuration = source.getBundleInfo().getStorage().getConfiguration();
if (var.equals("ws"))
return ClasspathManager.addStandardClassPathEntry(cpEntries, "ws/" + configuration.getWS() + cp.substring(4), hostManager, source);
if (var.equals("os"))
return ClasspathManager.addStandardClassPathEntry(cpEntries, "os/" + configuration.getOS() + cp.substring(4), hostManager, source);
if (var.equals("nl")) {
cp = cp.substring(4);
List<String> NL_JAR_VARIANTS = source.getBundleInfo().getStorage().getConfiguration().ECLIPSE_NL_JAR_VARIANTS;
for (String nlVariant : NL_JAR_VARIANTS) {
if (ClasspathManager.addStandardClassPathEntry(cpEntries, "nl/" + nlVariant + cp, hostManager, source))
return true;
}
}
return false;
}
private static String hasPrefix(String libPath) {
if (libPath.startsWith("$ws$"))
return "ws";
if (libPath.startsWith("$os$"))
return "os";
if (libPath.startsWith("$nl$"))
return "nl";
return null;
}
public ClasspathEntry getClasspath(String cp, Generation cpGeneration) {
BundleFile bundlefile = null;
File file;
BundleEntry cpEntry = cpGeneration.getBundleFile().getEntry(cp);
if (cpEntry != null && cpEntry.getName().endsWith("/"))
bundlefile = createBundleFile(cp, cpGeneration);
else if ((file = cpGeneration.getBundleFile().getFile(cp, false)) != null)
bundlefile = createBundleFile(file, cpGeneration);
if (bundlefile != null)
return createClassPathEntry(bundlefile, cpGeneration);
return null;
}
public ClasspathEntry getExternalClassPath(String cp, Generation cpGeneration) {
File file = new File(cp);
if (!file.isAbsolute())
return null;
BundleFile bundlefile = createBundleFile(file, cpGeneration);
if (bundlefile != null)
return createClassPathEntry(bundlefile, cpGeneration);
return null;
}
public synchronized void loadFragments(Collection<ModuleRevision> addedFragments) {
List<FragmentClasspath> result = new ArrayList<>(Arrays.asList(fragments));
for (ModuleRevision addedFragment : addedFragments) {
Generation fragGeneration = (Generation) addedFragment.getRevisionInfo();
String[] cp = getClassPath(addedFragment);
ClasspathEntry[] fragEntries = buildClasspath(cp, this, fragGeneration);
FragmentClasspath fragClasspath = new FragmentClasspath(fragGeneration, fragEntries);
insertFragment(fragClasspath, result);
}
fragments = result.toArray(new FragmentClasspath[result.size()]);
}
private static BundleFile createBundleFile(File content, Generation generation) {
if (!content.exists()) {
return null;
}
return generation.getBundleInfo().getStorage().createBundleFile(content, generation, content.isDirectory(), false);
}
private static BundleFile createBundleFile(String nestedDir, Generation generation) {
return generation.getBundleInfo().getStorage().createNestedBundleFile(nestedDir, generation.getBundleFile(), generation);
}
private ClasspathEntry createClassPathEntry(BundleFile bundlefile, Generation source) {
ClasspathEntry entry;
if (classloader != null)
entry = classloader.createClassPathEntry(bundlefile, source);
else
entry = new ClasspathEntry(bundlefile, source.getDomain(), source);
return entry;
}
public URL findLocalResource(String resource) {
List<ClassLoaderHook> hooks = hookRegistry.getClassLoaderHooks();
boolean hookFailed = false;
for (ClassLoaderHook hook : hooks) {
try {
hook.preFindLocalResource(resource, this);
} catch (NoSuchElementException e) {
hookFailed = true;
}
}
URL result = null;
try {
if (!hookFailed) {
result = findLocalResourceImpl(resource, -1);
}
} finally {
for (ClassLoaderHook hook : hooks) {
try {
hook.postFindLocalResource(resource, result, this);
} catch (NoSuchElementException e) {
result = null;
}
}
}
return result;
}
private URL findLocalResourceImpl(String resource, int classPathIndex) {
Module m = generation.getRevision().getRevisions().getModule();
URL result = null;
int[] curIndex = {0};
for (ClassLoaderHook hook : hookRegistry.getClassLoaderHooks()) {
ClasspathEntry[] hookEntries = hook.getClassPathEntries(resource, this);
if (hookEntries != null) {
return findLocalResourceImpl(resource, hookEntries, m, classPathIndex, curIndex);
}
}
curIndex[0] = 0;
result = findLocalResourceImpl(resource, entries, m, classPathIndex, curIndex);
if (result != null) {
return result;
}
for (FragmentClasspath fragCP : getFragmentClasspaths()) {
result = findLocalResourceImpl(resource, fragCP.getEntries(), m, classPathIndex, curIndex);
if (result != null) {
return result;
}
}
return null;
}
private URL findLocalResourceImpl(String resource, ClasspathEntry[] cpEntries, Module m, int classPathIndex, int[] curIndex) {
URL result;
for (ClasspathEntry cpEntry : cpEntries) {
if (cpEntry != null) {
result = cpEntry.findResource(resource, m, curIndex[0]);
if (result != null && (classPathIndex == -1 || classPathIndex == curIndex[0])) {
return result;
}
}
curIndex[0]++;
}
return null;
}
public Enumeration<URL> findLocalResources(String resource) {
Module m = generation.getRevision().getRevisions().getModule();
List<URL> resources = new ArrayList<>(6);
int[] classPathIndex = {0};
for (ClassLoaderHook hook : hookRegistry.getClassLoaderHooks()) {
ClasspathEntry[] hookEntries = hook.getClassPathEntries(resource, this);
if (hookEntries != null) {
findLocalResources(resource, hookEntries, m, classPathIndex, resources);
return resources.size() > 0 ? Collections.enumeration(resources) : EMPTY_ENUMERATION;
}
}
classPathIndex[0] = 0;
findLocalResources(resource, entries, m, classPathIndex, resources);
for (FragmentClasspath fragCP : getFragmentClasspaths()) {
findLocalResources(resource, fragCP.getEntries(), m, classPathIndex, resources);
}
if (resources.size() > 0)
return Collections.enumeration(resources);
return EMPTY_ENUMERATION;
}
private void findLocalResources(String resource, ClasspathEntry[] cpEntries, Module m, int[] classPathIndex, List<URL> resources) {
for (ClasspathEntry cpEntry : cpEntries) {
if (cpEntry != null) {
URL url = cpEntry.findResource(resource, m, classPathIndex[0]);
if (url != null) {
resources.add(url);
}
}
classPathIndex[0]++;
}
}
public BundleEntry findLocalEntry(String path) {
return findLocalEntry(path, -1);
}
public BundleEntry findLocalEntry(String path, int classPathIndex) {
BundleEntry result = null;
int[] curIndex = {0};
for (ClassLoaderHook hook : hookRegistry.getClassLoaderHooks()) {
ClasspathEntry[] hookEntries = hook.getClassPathEntries(path, this);
if (hookEntries != null) {
return findLocalEntry(path, hookEntries, classPathIndex, curIndex);
}
}
curIndex[0] = 0;
result = findLocalEntry(path, entries, classPathIndex, curIndex);
if (result != null) {
return result;
}
for (FragmentClasspath fragCP : getFragmentClasspaths()) {
result = findLocalEntry(path, fragCP.getEntries(), classPathIndex, curIndex);
if (result != null) {
return result;
}
}
return null;
}
private BundleEntry findLocalEntry(String path, ClasspathEntry[] cpEntries, int classPathIndex, int[] curIndex) {
BundleEntry result = null;
for (ClasspathEntry cpEntry : cpEntries) {
if (cpEntry != null) {
result = cpEntry.findEntry(path);
if (result != null && (classPathIndex == -1 || classPathIndex == curIndex[0])) {
return result;
}
}
curIndex[0]++;
}
return result;
}
public Class<?> findLocalClass(String classname) throws ClassNotFoundException {
Class<?> result = null;
List<ClassLoaderHook> hooks = hookRegistry.getClassLoaderHooks();
try {
for (ClassLoaderHook hook : hooks) {
hook.preFindLocalClass(classname, this);
}
result = classloader.publicFindLoaded(classname);
if (result != null)
return result;
result = findLocalClassImpl(classname, hooks);
return result;
} finally {
for (ClassLoaderHook hook : hooks) {
hook.postFindLocalClass(classname, result, this);
}
}
}
private Class<?> findLocalClassImpl(String classname, List<ClassLoaderHook> hooks) throws ClassNotFoundException {
Class<?> result;
for (ClassLoaderHook hook : hookRegistry.getClassLoaderHooks()) {
ClasspathEntry[] hookEntries = hook.getClassPathEntries(classname, this);
if (hookEntries != null) {
return findLocalClassImpl(classname, hookEntries, hooks);
}
}
result = findLocalClassImpl(classname, entries, hooks);
if (result != null) {
return result;
}
for (FragmentClasspath fragCP : getFragmentClasspaths()) {
result = findLocalClassImpl(classname, fragCP.getEntries(), hooks);
if (result != null) {
return result;
}
}
throw new ClassNotFoundException(classname);
}
private Class<?> findLocalClassImpl(String classname, ClasspathEntry[] cpEntries, List<ClassLoaderHook> hooks) {
Class<?> result;
for (ClasspathEntry cpEntry : cpEntries) {
if (cpEntry != null) {
result = findClassImpl(classname, cpEntry, hooks);
if (result != null) {
return result;
}
}
}
return null;
}
private Class<?> findClassImpl(String name, ClasspathEntry classpathEntry, List<ClassLoaderHook> hooks) {
if (debug.DEBUG_LOADER)
Debug.println("ModuleClassLoader[" + classloader.getBundleLoader() + " - " + classpathEntry.getBundleFile() + "].findClassImpl(" + name + ")");
String filename = name.replace('.', '/').concat(".class");
BundleEntry entry = classpathEntry.findEntry(filename);
if (entry == null)
return null;
byte[] classbytes;
try {
classbytes = entry.getBytes();
} catch (IOException e) {
if (debug.DEBUG_LOADER)
Debug.println(" IOException reading " + filename + " from " + classpathEntry.getBundleFile());
throw (LinkageError) new LinkageError("Error reading class bytes: " + name).initCause(e);
}
if (debug.DEBUG_LOADER) {
Debug.println(" read " + classbytes.length + " bytes from " + classpathEntry.getBundleFile() + "!/" + filename);
Debug.println(" defining class " + name);
}
try {
return defineClass(name, classbytes, classpathEntry, entry, hooks);
} catch (Error e) {
if (debug.DEBUG_LOADER)
Debug.println(" error defining class " + name);
throw e;
}
}
static class DefineContext {
Collection<String> currentlyProcessing = new ArrayList<>(5);
Collection<String> currentlyDefining = new ArrayList<>(5);
}
private Class<?> defineClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, List<ClassLoaderHook> hooks) {
DefineClassResult result = null;
boolean recursionDetected = false;
try {
definePackage(name, classpathEntry);
DefineContext context = currentDefineContext.get();
if (context == null) {
context = new DefineContext();
currentDefineContext.set(context);
}
if (!hookRegistry.getContainer().isProcessClassRecursionSupportedByAll()) {
if (context.currentlyProcessing.contains(name)) {
recursionDetected = true;
return null;
}
context.currentlyProcessing.add(name);
try {
for (ClassLoaderHook hook : hooks) {
if (!hook.isProcessClassRecursionSupported()) {
classbytes = processClass(hook, name, classbytes, classpathEntry, entry, this, hooks);
}
}
} finally {
context.currentlyProcessing.remove(name);
}
}
for (ClassLoaderHook hook : hooks) {
if (hook.isProcessClassRecursionSupported()) {
classbytes = processClass(hook, name, classbytes, classpathEntry, entry, this, hooks);
}
}
if (context.currentlyDefining.contains(name)) {
return null;
}
context.currentlyDefining.add(name);
try {
result = classloader.defineClass(name, classbytes, classpathEntry);
} finally {
context.currentlyDefining.remove(name);
}
} finally {
if (!recursionDetected) {
Class<?> defined = result != null && result.defined ? result.clazz : null;
for (ClassLoaderHook hook : hooks) {
hook.recordClassDefine(name, defined, classbytes, classpathEntry, entry, this);
}
}
}
return result == null ? null : result.clazz;
}
private byte[] processClass(ClassLoaderHook hook, String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager classpathManager, List<ClassLoaderHook> hooks) {
byte[] modifiedBytes = hook.processClass(name, classbytes, classpathEntry, entry, this);
if (modifiedBytes != null) {
if (!(hook instanceof WeavingHookConfigurator)) {
for (ClassLoaderHook rejectHook : hooks) {
if (rejectHook.rejectTransformation(name, modifiedBytes, classpathEntry, entry, this)) {
modifiedBytes = null;
break;
}
}
}
if (modifiedBytes != null) {
classbytes = modifiedBytes;
}
}
return classbytes;
}
private void definePackage(String name, ClasspathEntry classpathEntry) {
int lastIndex = name.lastIndexOf('.');
if (lastIndex < 0) {
return;
}
String packageName = name.substring(0, lastIndex);
Object pkg = classloader.publicGetPackage(packageName);
if (pkg != null) {
return;
}
String specTitle = null, specVersion = null, specVendor = null, implTitle = null, implVersion = null, implVendor = null;
if (generation.getBundleInfo().getStorage().getConfiguration().DEFINE_PACKAGE_ATTRIBUTES) {
ManifestPackageAttributes manifestPackageAttributes = classpathEntry.manifestPackageAttributesFor(packageName);
TitleVersionVendor specification = manifestPackageAttributes.getSpecification();
TitleVersionVendor implementation = manifestPackageAttributes.getImplementation();
specTitle = specification.getTitle();
specVersion = specification.getVersion();
specVendor = specification.getVendor();
implTitle = implementation.getTitle();
implVersion = implementation.getVersion();
implVendor = implementation.getVendor();
}
classloader.publicDefinePackage(packageName, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, null);
}
public FragmentClasspath[] getFragmentClasspaths() {
return fragments;
}
public ClasspathEntry[] getHostClasspathEntries() {
return entries;
}
public String findLibrary(String libname) {
synchronized (this) {
if (loadedLibraries == null)
loadedLibraries = new ArrayMap<>(1);
}
synchronized (loadedLibraries) {
String libpath = loadedLibraries.get(libname);
if (libpath != null)
return libpath;
libpath = findLibrary0(libname);
if (libpath != null)
loadedLibraries.put(libname, libpath);
return libpath;
}
}
private String findLibrary0(String libname) {
List<ClassLoaderHook> hooks = hookRegistry.getClassLoaderHooks();
String result = null;
for (ClassLoaderHook hook : hooks) {
try {
result = hook.preFindLibrary(libname, classloader);
if (result != null) {
return result;
}
} catch (FileNotFoundException e) {
return null;
}
}
result = generation.findLibrary(libname);
if (result != null) {
return result;
}
FragmentClasspath[] currentFragments = getFragmentClasspaths();
for (FragmentClasspath fragment : currentFragments) {
result = fragment.getGeneration().findLibrary(libname);
if (result != null) {
return result;
}
}
for (ClassLoaderHook hook : hooks) {
result = hook.postFindLibrary(libname, classloader);
if (result != null) {
return result;
}
}
return result;
}
public List<URL> findEntries(String path, String filePattern, int options) {
List<Generation> generations = new ArrayList<>();
generations.add(generation);
FragmentClasspath[] currentFragments = getFragmentClasspaths();
for (FragmentClasspath fragmentClasspath : currentFragments)
generations.add(fragmentClasspath.getGeneration());
List<URL> result = Collections.<URL> emptyList();
Enumeration<URL> eURLs = Storage.findEntries(generations, path, filePattern, options);
if (eURLs == null)
return result;
result = new ArrayList<>();
while (eURLs.hasMoreElements())
result.add(eURLs.nextElement());
return Collections.unmodifiableList(result);
}
public Collection<String> listLocalResources(String path, String filePattern, int options) {
List<BundleFile> bundleFiles = new ArrayList<>();
for (ClassLoaderHook hook : hookRegistry.getClassLoaderHooks()) {
ClasspathEntry[] hookEntries = hook.getClassPathEntries(path, this);
if (hookEntries != null) {
for (ClasspathEntry cpEntry : hookEntries) {
cpEntry.addBundleFiles(bundleFiles);
}
return Storage.listEntryPaths(bundleFiles, path, filePattern, options);
}
}
ClasspathEntry[] cpEntries = getHostClasspathEntries();
for (ClasspathEntry cpEntry : cpEntries) {
cpEntry.addBundleFiles(bundleFiles);
}
for (FragmentClasspath fragmentClasspath : getFragmentClasspaths()) {
for (ClasspathEntry cpEntry : fragmentClasspath.getEntries()) {
cpEntry.addBundleFiles(bundleFiles);
}
}
return Storage.listEntryPaths(bundleFiles, path, filePattern, options);
}
public Generation getGeneration() {
return generation;
}
public ModuleClassLoader getClassLoader() {
return classloader;
}
}