Skip to content

Commit

Permalink
further fixing of #229: Fix org.objectweb.asm version collision
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
S1artie committed Feb 25, 2019
1 parent 4206b27 commit 08d118f
Showing 1 changed file with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -135,9 +137,23 @@ private void addToList(List<IClasspathEntry> 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<Bundle> 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) {
Expand All @@ -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;
}

Expand Down

0 comments on commit 08d118f

Please sign in to comment.