diff --git a/src/org/rascalmpl/uri/classloaders/SourceLocationClassLoader.java b/src/org/rascalmpl/uri/classloaders/SourceLocationClassLoader.java index 5459bba761e..307ba73b23b 100644 --- a/src/org/rascalmpl/uri/classloaders/SourceLocationClassLoader.java +++ b/src/org/rascalmpl/uri/classloaders/SourceLocationClassLoader.java @@ -160,10 +160,23 @@ public URL getResource(String name) { public Enumeration getResources(String name) throws IOException { List result = new ArrayList<>(path.size()); + for (ClassLoader l : path) { - Enumeration e = l.getResources(name); - while (e.hasMoreElements()) { - result.add(e.nextElement()); + SearchItem item = new SearchItem(l, name); + + if (stack.contains(item)) { + continue; + } + try { + stack.push(item); + + Enumeration e = l.getResources(name); + while (e.hasMoreElements()) { + result.add(e.nextElement()); + } + } + finally { + stack.pop(); } }