diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/JavacUtils.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/JavacUtils.java index 2519461b97c..6bddf58d0f7 100644 --- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/JavacUtils.java +++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/javac/JavacUtils.java @@ -12,6 +12,7 @@ import java.io.File; import java.lang.Runtime.Version; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; @@ -355,6 +356,7 @@ public static boolean isEmpty(List list) { private static Collection classpathEntriesToFiles(JavaProject project, Predicate select) { try { LinkedHashSet res = new LinkedHashSet<>(); + ArrayList seen = new ArrayList<>(); Queue toProcess = new LinkedList<>(); toProcess.addAll(Arrays.asList(project.resolveClasspath(project.getExpandedClasspath()))); while (!toProcess.isEmpty()) { @@ -373,14 +375,16 @@ private static Collection classpathEntriesToFiles(JavaProject project, Pre if (moduleDescription == null) { IPath path = referencedJavaProject.getOutputLocation(); addPath(referencedJavaProject, path, res); - for (IClasspathEntry transitiveEntry : referencedJavaProject.resolveClasspath(referencedJavaProject.getExpandedClasspath()) ) { + IClasspathEntry[] resolved = referencedJavaProject.resolveClasspath(referencedJavaProject.getExpandedClasspath()); + for (IClasspathEntry transitiveEntry : resolved ) { if (transitiveEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath outputLocation = transitiveEntry.getOutputLocation(); if (outputLocation != null && select.test(transitiveEntry)) { addPath(referencedJavaProject, outputLocation, res); } - } else if (transitiveEntry.isExported()) { + } else if (transitiveEntry.isExported() && !seen.contains(transitiveEntry)) { toProcess.add(transitiveEntry); + seen.add(transitiveEntry); } } }