From 08d118f9aa6ac675d034969d3fc777cbe517590e Mon Sep 17 00:00:00 2001 From: Rene Schneider Date: Mon, 25 Feb 2019 18:04:25 +0100 Subject: [PATCH] further fixing of #229: Fix org.objectweb.asm version collision It appears as if xtext.common.types 2.16.x updated its org.objectweb.asm dependency to 7.0.0, so if we have both available in an Eclipse install, we should use the newer version. --- .../IntegrityClasspathContainer.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/de.gebit.integrity.eclipse/src/de/gebit/integrity/eclipse/classpath/IntegrityClasspathContainer.java b/de.gebit.integrity.eclipse/src/de/gebit/integrity/eclipse/classpath/IntegrityClasspathContainer.java index 636dc7702..b833d1bcc 100644 --- a/de.gebit.integrity.eclipse/src/de/gebit/integrity/eclipse/classpath/IntegrityClasspathContainer.java +++ b/de.gebit.integrity.eclipse/src/de/gebit/integrity/eclipse/classpath/IntegrityClasspathContainer.java @@ -8,7 +8,9 @@ package de.gebit.integrity.eclipse.classpath; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; @@ -135,9 +137,23 @@ private void addToList(List aList, String[][] someBundleNames) } private Bundle findBundle(String aSymbolicName) { + return findBundleRecursive(aSymbolicName, FrameworkUtil.getBundle(JavaCore.class), new HashSet<>()); + } + + private Bundle findBundleRecursive(String aSymbolicName, Bundle aRootBundle, Set someSeenBundles) { Bundle tempBundleMatch = null; - for (Bundle tempBundleCandidate : FrameworkUtil.getBundle(JavaCore.class).getBundleContext().getBundles()) { + if (aRootBundle.getBundleContext() == null) { + return null; + } + + for (Bundle tempBundleCandidate : aRootBundle.getBundleContext().getBundles()) { + if (someSeenBundles.contains(tempBundleCandidate)) { + continue; + } else { + someSeenBundles.add(tempBundleCandidate); + } + if (tempBundleCandidate.getSymbolicName().equals(aSymbolicName)) { if (tempBundleMatch != null) { if (tempBundleMatch.getVersion().compareTo(tempBundleCandidate.getVersion()) < 0) { @@ -147,8 +163,22 @@ private Bundle findBundle(String aSymbolicName) { } tempBundleMatch = tempBundleCandidate; + } else { + Bundle tempRecursionCandidate + = findBundleRecursive(aSymbolicName, tempBundleCandidate, someSeenBundles); + + if (tempRecursionCandidate != null) { + if (tempBundleMatch != null) { + if (tempBundleMatch.getVersion().compareTo(tempBundleCandidate.getVersion()) < 0) { + // already-found matches' version is less than candidates' version + continue; + } + } + tempBundleMatch = tempRecursionCandidate; + } } } + return tempBundleMatch; }