Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.List;

/**
Expand All @@ -25,4 +26,7 @@ public abstract class FlexyClassLoader extends ClassLoader {

public abstract List<FlexyClassLoader> getSubClassLoaders();

public abstract List<URL> getClassLoaderResources();

public abstract List<URL> getAllResources();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ public interface IndexDB {

public boolean contains(String name);

List<URL> getResources();

}
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,18 @@ public List<FlexyClassLoaderImpl> graphResourcesOwnerResolution(KlassLoadRequest
return result;
}

@Override
public List<URL> getClassLoaderResources() {
return classpathResources.getResources();
}

@Override
public List<URL> getAllResources() {
List<URL> allResources = new ArrayList<URL>();
for (FlexyClassLoader classLoader : subClassLoaders) {
allResources.addAll(classLoader.getAllResources());
Copy link
Copy Markdown
Owner

@dukeboard dukeboard Feb 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have a risk of loop. FlexyClassLoader are linked using graph topology.
Therefore, the resolution should leverage a loop-breaking solution (usually with a map of already traversed FCL). This is the only potential problem is saw in the code.

}
allResources.addAll(getClassLoaderResources());
return allResources;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ public List<URL> get(String name) {
return jarContentURLs.get(name);
}

@Override
public List<URL> getResources() {
List<URL> result = new ArrayList<URL>();
for (List<URL> list : jarContentURLs.values()) {
result.addAll(list);
}
return result;
}

public void loadJar(JarFile jarInput, File origin) throws IOException {
final Enumeration<JarEntry> entries = jarInput.entries();
Expand Down