Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2019-02-17 06:30:30 -0500
committerTill Brychcy2019-02-17 09:46:15 -0500
commitda6ee5f46781db27c9775f765ebffcc30bac036f (patch)
treef8ca2dd154f881094290d1b2d39e6657ce7a1ece
parentd2f437ed4a8c6a879ff92cc6a8e9594b6f6c18bd (diff)
downloadm2e-core-da6ee5f46781db27c9775f765ebffcc30bac036f.tar.gz
m2e-core-da6ee5f46781db27c9775f765ebffcc30bac036f.tar.xz
m2e-core-da6ee5f46781db27c9775f765ebffcc30bac036f.zip
Bug 543766 - Java module not found at runtime even with requires
transitive Change-Id: I84d0b62445b1230040f1cf58e91cd535bda404b8 Signed-off-by: Till Brychcy <register.eclipse@brychcy.de>
-rw-r--r--org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/InternalModuleSupport.java37
1 files changed, 18 insertions, 19 deletions
diff --git a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/InternalModuleSupport.java b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/InternalModuleSupport.java
index 4198b40d..3d916866 100644
--- a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/InternalModuleSupport.java
+++ b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/InternalModuleSupport.java
@@ -16,7 +16,6 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -132,41 +131,41 @@ class InternalModuleSupport {
descriptorsMap.put(entry, moduleName);
}
- Set<String> visitedModules = new HashSet<>(entryDescriptors.size());
- collectTransitiveRequiredModules(requiredModules, visitedModules, moduleMap, monitor, targetCompliance);
+ Set<String> transitiveRequiredModules = collectTransitiveRequiredModules(requiredModules, moduleMap, monitor,
+ targetCompliance);
if(monitor.isCanceled()) {
return;
}
descriptorsMap.forEach((entry, module) -> {
- if(requiredModules.contains(module)) {
+ if(transitiveRequiredModules.contains(module)) {
entry.setClasspathAttribute(IClasspathAttribute.MODULE, Boolean.TRUE.toString());
}
});
}
- private static void collectTransitiveRequiredModules(Set<String> requiredModules, Set<String> visitedModules,
+ private static Set<String> collectTransitiveRequiredModules(Set<String> requiredModules,
Map<String, IClasspathEntryDescriptor> moduleMap, IProgressMonitor monitor, int targetCompliance)
throws JavaModelException {
if(monitor.isCanceled() || requiredModules.isEmpty()) {
- return;
+ return requiredModules;
}
- Set<String> transitiveModules = new LinkedHashSet<>();
- for(String req : requiredModules) {
- if(visitedModules.contains(req)) {
- //already checked that module
- continue;
+ Set<String> result = new LinkedHashSet<>();
+ Set<String> todo = requiredModules;
+ while(!todo.isEmpty()) {
+ Set<String> transitiveModules = new LinkedHashSet<>();
+ for(String req : todo) {
+ if(result.add(req)) {
+ Set<String> modules = getRequiredModules(moduleMap.get(req), monitor, targetCompliance);
+ transitiveModules.addAll(modules);
+ } else {
+ //already checked that module
+ }
}
- Set<String> modules = getRequiredModules(moduleMap.get(req), monitor, targetCompliance);
- transitiveModules.addAll(modules);
- visitedModules.add(req);
- }
- transitiveModules.removeAll(visitedModules);
- if(!transitiveModules.isEmpty()) {
- requiredModules.addAll(transitiveModules);
- collectTransitiveRequiredModules(transitiveModules, visitedModules, moduleMap, monitor, targetCompliance);
+ todo = transitiveModules;
}
+ return result;
}
private static Set<String> getRequiredModules(IClasspathEntryDescriptor entry, IProgressMonitor monitor,

Back to the top