SHA256
1
0
forked from pool/aqute-bnd
aqute-bnd/reproducible-element-order.patch

795 lines
30 KiB
Diff

diff --git a/biz.aQute.bndlib/src/aQute/bnd/header/Parameters.java b/biz.aQute.bndlib/src/aQute/bnd/header/Parameters.java
index d3916f63..ae84ca14 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/header/Parameters.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/header/Parameters.java
@@ -4,10 +4,10 @@ import static aQute.bnd.osgi.Constants.DUPLICATE_MARKER;
import static java.util.stream.Collectors.toList;
import java.util.Collection;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.TreeMap;
import java.util.stream.Collector;
import aQute.bnd.stream.MapStream;
@@ -19,7 +19,7 @@ public class Parameters implements Map<String, Attrs> {
public Parameters(boolean allowDuplicateAttributes) {
this.allowDuplicateAttributes = allowDuplicateAttributes;
- map = new LinkedHashMap<>();
+ map = new TreeMap<>();
}
public Parameters() {
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/ActivelyClosingClassLoader.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/ActivelyClosingClassLoader.java
index 761f48ef..4c9b3efd 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/ActivelyClosingClassLoader.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/ActivelyClosingClassLoader.java
@@ -14,10 +14,10 @@ import java.net.URLClassLoader;
import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.util.Enumeration;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.TreeMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -35,7 +35,7 @@ import aQute.lib.io.IO;
* This class loader can load classes from JAR files.
*/
class ActivelyClosingClassLoader extends URLClassLoader implements Closeable {
- final AtomicReference<Map<File, Wrapper>> wrappers = new AtomicReference<>(new LinkedHashMap<>());
+ final AtomicReference<Map<File, Wrapper>> wrappers = new AtomicReference<>(new TreeMap<>());
final AtomicBoolean open = new AtomicBoolean(true);
final Processor processor;
ScheduledFuture<?> schedule;
@@ -89,7 +89,7 @@ class ActivelyClosingClassLoader extends URLClassLoader implements Closeable {
throw new IllegalStateException("Already closed");
}
wrappers.updateAndGet(map -> {
- Map<File, Wrapper> copy = new LinkedHashMap<>(map);
+ Map<File, Wrapper> copy = new TreeMap<>(map);
copy.computeIfAbsent(file, Wrapper::new);
return copy;
});
@@ -183,7 +183,7 @@ class ActivelyClosingClassLoader extends URLClassLoader implements Closeable {
if (schedule != null) {
schedule.cancel(true);
}
- wrappers.getAndSet(new LinkedHashMap<>())
+ wrappers.getAndSet(new TreeMap<>())
.values()
.forEach(Wrapper::close);
}
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java
index bf5029ae..533eea3d 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java
@@ -43,7 +43,6 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -2144,7 +2143,7 @@ public class Analyzer extends Processor {
.distinct()
.filter(this::isProvider)
.map(TypeRef::getPackageRef)
- .collect(toCollection(LinkedHashSet<PackageRef>::new));
+ .collect(toCollection(TreeSet<PackageRef>::new));
return providers;
}
@@ -2686,7 +2685,7 @@ public class Analyzer extends Processor {
// Look at the referred packages
// and copy them to our baseline
- Set<PackageRef> refs = new LinkedHashSet<>(clazz.getReferred());
+ Set<PackageRef> refs = new TreeSet<>(clazz.getReferred());
refs.addAll(referencesByAnnotation(clazz));
for (PackageRef p : refs) {
referred.put(p);
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/Annotation.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/Annotation.java
index 685c92e1..c3f10b29 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Annotation.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Annotation.java
@@ -6,9 +6,9 @@ import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
-import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.TreeMap;
import java.util.Set;
import java.util.stream.Stream;
@@ -150,7 +150,7 @@ public class Annotation {
public void put(String string, Object v) {
if (elements == null) {
- elements = new LinkedHashMap<>();
+ elements = new TreeMap<>();
}
elements.put(string, v);
}
@@ -193,7 +193,7 @@ public class Annotation {
public <T extends java.lang.annotation.Annotation> T getAnnotation(Class<T> c) throws Exception {
if (elements == null) {
- elements = new LinkedHashMap<>();
+ elements = new TreeMap<>();
}
return CONVERTER.convert(c, elements);
}
@@ -211,7 +211,7 @@ public class Annotation {
return;
}
if (elements == null) {
- elements = new LinkedHashMap<>(map);
+ elements = new TreeMap<>(map);
} else {
map.forEach(elements::putIfAbsent);
}
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/AnnotationHeaders.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/AnnotationHeaders.java
index 7ee4b2a5..ade0577c 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/AnnotationHeaders.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/AnnotationHeaders.java
@@ -8,7 +8,6 @@ import java.io.IOException;
import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Optional;
@@ -151,7 +150,7 @@ class AnnotationHeaders extends ClassDataCollector implements Closeable {
// The annotations we could not load. used to avoid repeatedly logging the
// same missing annotation for the same project. Note that this should not
// be reset for each #classStart(Clazz).
- final Set<String> loggedMissing = new HashSet<>();
+ final Set<String> loggedMissing = new TreeSet<>();
final Instructions instructions;
// we parse the annotations separately at the end
@@ -394,7 +393,7 @@ class AnnotationHeaders extends ClassDataCollector implements Closeable {
handleAttributeOrDirective(a);
break;
default :
- Set<String> processed = new HashSet<>(this.processed);
+ Set<String> processed = new TreeSet<>(this.processed);
processed.add(c.getFQN());
doAnnotatedAnnotation(a, a.getName(), processed, attributesAndDirectives);
break;
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/Builder.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/Builder.java
index cbeb4452..9b03e520 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Builder.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Builder.java
@@ -14,13 +14,13 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
+import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.jar.Manifest;
import java.util.regex.Matcher;
@@ -489,7 +489,7 @@ public class Builder extends Analyzer {
.toStringWithoutQualifier();
}
}
- Set<String> visited = new HashSet<>();
+ Set<String> visited = new TreeSet<>();
for (Map.Entry<PackageRef, Attrs> entry : packages.entrySet()) {
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/Clazz.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/Clazz.java
index b97251b5..a3f8644f 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Clazz.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Clazz.java
@@ -31,8 +31,7 @@ import java.util.Comparator;
import java.util.Deque;
import java.util.EnumSet;
import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
+import java.util.TreeSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -40,6 +39,7 @@ import java.util.Properties;
import java.util.Set;
import java.util.Spliterator;
import java.util.Spliterators.AbstractSpliterator;
+import java.util.TreeMap;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
@@ -735,7 +735,7 @@ public class Clazz {
private boolean hasDefaultConstructor;
private Set<PackageRef> imports = Create.set();
- private Set<TypeRef> xref = new HashSet<>();
+ private Set<TypeRef> xref = new TreeSet<>();
private Set<TypeRef> annotations;
private int forName = 0;
private int class$ = 0;
@@ -803,7 +803,7 @@ public class Clazz {
referred = new HashMap<>(constantPool.size());
if (classDef.isPublic()) {
- api = new HashSet<>();
+ api = new TreeSet<>();
}
if (!classDef.isModule()) {
referTo(classDef.getType(), Modifier.PUBLIC);
@@ -1430,7 +1430,7 @@ public class Clazz {
private void processAnnotation(AnnotationInfo annotationInfo, ElementType elementType, RetentionPolicy policy,
int access_flags) {
if (annotations == null) {
- annotations = new HashSet<>();
+ annotations = new TreeSet<>();
}
String typeName = annotationInfo.type;
@@ -1478,7 +1478,7 @@ public class Clazz {
private Map<String, Object> annotationValues(ElementValueInfo[] values, ElementType elementType,
RetentionPolicy policy, int access_flags) {
- Map<String, Object> elements = new LinkedHashMap<>();
+ Map<String, Object> elements = new TreeMap<>();
for (ElementValueInfo elementValueInfo : values) {
String element = elementValueInfo.name;
Object value = newElementValue(elementValueInfo.value, elementType, policy, access_flags);
@@ -1706,7 +1706,7 @@ public class Clazz {
Spliterator<TypeRef> spliterator = new AbstractSpliterator<TypeRef>(Long.MAX_VALUE,
Spliterator.DISTINCT | Spliterator.ORDERED | Spliterator.NONNULL) {
private final Deque<TypeRef> queue = new ArrayDeque<>(func.apply(Clazz.this));
- private final Set<TypeRef> seen = (visited != null) ? visited : new HashSet<>();
+ private final Set<TypeRef> seen = (visited != null) ? visited : new TreeSet<>();
@Override
public boolean tryAdvance(Consumer<? super TypeRef> action) {
@@ -1758,7 +1758,7 @@ public class Clazz {
case IMPLEMENTS : {
requireNonNull(instr);
- Set<TypeRef> visited = new HashSet<>();
+ Set<TypeRef> visited = new TreeSet<>();
return hierarchyStream(analyzer).flatMap(c -> c.typeStream(analyzer, Clazz::interfaces, visited))
.map(TypeRef::getDottedOnly)
.anyMatch(instr::matches) ^ instr.isNegated();
@@ -1787,7 +1787,7 @@ public class Clazz {
case INDIRECTLY_ANNOTATED : {
requireNonNull(instr);
- return typeStream(analyzer, Clazz::annotations, new HashSet<>()) //
+ return typeStream(analyzer, Clazz::annotations, new TreeSet<>()) //
.map(TypeRef::getFQN)
.anyMatch(instr::matches) ^ instr.isNegated();
}
@@ -1802,7 +1802,7 @@ public class Clazz {
case HIERARCHY_INDIRECTLY_ANNOTATED : {
requireNonNull(instr);
- Set<TypeRef> visited = new HashSet<>();
+ Set<TypeRef> visited = new TreeSet<>();
return hierarchyStream(analyzer) //
.flatMap(c -> c.typeStream(analyzer, Clazz::annotations, visited))
.map(TypeRef::getFQN)
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/Jar.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/Jar.java
index 3576bd87..d86ce7c1 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Jar.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Jar.java
@@ -27,7 +27,6 @@ import java.util.Arrays;
import java.util.Calendar;
import java.util.EnumSet;
import java.util.GregorianCalendar;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
@@ -548,9 +547,9 @@ public class Jar implements Closeable {
// default is DEFLATED
}
- Set<String> done = new HashSet<>();
+ Set<String> done = new TreeSet<>();
- Set<String> directories = new HashSet<>();
+ Set<String> directories = new TreeSet<>();
if (doNotTouchManifest) {
Resource r = getResource(manifestName);
if (r != null) {
@@ -588,7 +587,7 @@ public class Jar implements Closeable {
check();
- Set<String> done = new HashSet<>();
+ Set<String> done = new TreeSet<>();
if (doNotTouchManifest) {
Resource r = getResource(manifestName);
@@ -1281,7 +1280,7 @@ public class Jar implements Closeable {
public void stripSignatures() {
Map<String, Resource> map = getDirectory("META-INF");
if (map != null) {
- for (String file : new HashSet<>(map.keySet())) {
+ for (String file : new TreeSet<>(map.keySet())) {
if (SIGNER_FILES_P.matcher(file)
.matches())
remove(file);
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/Macro.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/Macro.java
index 47312379..f9996bd8 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Macro.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Macro.java
@@ -29,7 +29,6 @@ import java.util.Date;
import java.util.Deque;
import java.util.Formatter;
import java.util.Iterator;
-import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
@@ -42,6 +41,7 @@ import java.util.Random;
import java.util.Set;
import java.util.TimeZone;
import java.util.TreeMap;
+import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiFunction;
import java.util.function.Function;
@@ -2166,7 +2166,7 @@ public class Macro {
* @return a map with commands and their help
*/
public Map<String, String> getCommands() {
- Set<Object> targets = new LinkedHashSet<>();
+ Set<Object> targets = new TreeSet<>();
Collections.addAll(targets, this.targets);
Processor rover = domain;
while (rover != null) {
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/Packages.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/Packages.java
index 6e0cd11d..6bd42dcd 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Packages.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Packages.java
@@ -1,9 +1,9 @@
package aQute.bnd.osgi;
import java.util.Collection;
-import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
+import java.util.TreeMap;
import aQute.bnd.header.Attrs;
import aQute.bnd.osgi.Descriptors.PackageRef;
@@ -21,11 +21,11 @@ public class Packages implements Map<PackageRef, Attrs> {
}
public Packages(Packages other) {
- map = new LinkedHashMap<>(other.map);
+ map = new TreeMap<>(other.map);
}
public Packages() {
- map = new LinkedHashMap<>();
+ map = new TreeMap<>();
}
@Override
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/PermissionGenerator.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/PermissionGenerator.java
index e7721390..c9f654df 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/PermissionGenerator.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/PermissionGenerator.java
@@ -4,7 +4,6 @@ import static java.util.stream.Collectors.toCollection;
import java.util.Collections;
import java.util.EnumSet;
-import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
@@ -150,7 +149,7 @@ public class PermissionGenerator {
@Override
public Set<String> visit(Or expr) {
- Set<String> matches = new HashSet<>();
+ Set<String> matches = new TreeSet<>();
for (Expression expression : expr.getExpressions()) {
matches.addAll(expression.visit(this));
}
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/Processor.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/Processor.java
index ca5d496d..c65c493e 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Processor.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Processor.java
@@ -31,7 +31,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -41,6 +40,7 @@ import java.util.Properties;
import java.util.Random;
import java.util.Set;
import java.util.Spliterator;
+import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
@@ -942,11 +942,11 @@ public class Processor extends Domain implements Reporter, Registry, Constants,
}
public static <K, V> Map<K, V> newMap() {
- return new LinkedHashMap<>();
+ return new TreeMap<>();
}
public static <K, V> Map<K, V> newHashMap() {
- return new LinkedHashMap<>();
+ return new TreeMap<>();
}
public <T> List<T> newList(Collection<T> t) {
@@ -958,7 +958,7 @@ public class Processor extends Domain implements Reporter, Registry, Constants,
}
public <K, V> Map<K, V> newMap(Map<K, V> t) {
- return new LinkedHashMap<>(t);
+ return new TreeMap<>(t);
}
@Override
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/Verifier.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/Verifier.java
index 982e229b..5ea80f10 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Verifier.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Verifier.java
@@ -4,7 +4,6 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Formatter;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -565,7 +564,7 @@ public class Verifier extends Processor {
if (!unresolvedReferences.isEmpty()) {
// Now we want to know the
// classes that are the culprits
- Set<String> culprits = new HashSet<>();
+ Set<String> culprits = new TreeSet<>();
for (Clazz clazz : analyzer.getClassspace()
.values()) {
if (hasOverlap(unresolvedReferences, clazz.getReferred()))
@@ -674,7 +673,7 @@ public class Verifier extends Processor {
if (!since(About._2_3))
return;
- Set<String> invalidPaths = new HashSet<>();
+ Set<String> invalidPaths = new TreeSet<>();
Pattern pattern = ReservedFileNames;
setProperty("@", ReservedFileNames.pattern());
String p = getProperty(INVALIDFILENAMES);
@@ -690,7 +689,7 @@ public class Verifier extends Processor {
}
}
- Set<String> segments = new HashSet<>();
+ Set<String> segments = new TreeSet<>();
for (String path : dot.getResources()
.keySet()) {
String parts[] = path.split("/");
@@ -717,8 +716,8 @@ public class Verifier extends Processor {
if (isStrict()) {
Parameters map = parseHeader(manifest.getMainAttributes()
.getValue(Constants.IMPORT_PACKAGE));
- Set<String> noimports = new HashSet<>();
- Set<String> toobroadimports = new HashSet<>();
+ Set<String> noimports = new TreeSet<>();
+ Set<String> toobroadimports = new TreeSet<>();
for (Entry<String, Attrs> e : map.entrySet()) {
@@ -791,7 +790,7 @@ public class Verifier extends Processor {
if (isStrict()) {
Parameters map = parseHeader(manifest.getMainAttributes()
.getValue(Constants.EXPORT_PACKAGE));
- Set<String> noexports = new HashSet<>();
+ Set<String> noexports = new TreeSet<>();
for (Entry<String, Attrs> e : map.entrySet()) {
@@ -837,7 +836,7 @@ public class Verifier extends Processor {
String mandatory = e.getValue()
.get(Constants.MANDATORY_DIRECTIVE);
if (mandatory != null) {
- Set<String> missing = new HashSet<>(split(mandatory));
+ Set<String> missing = new TreeSet<>(split(mandatory));
missing.removeAll(e.getValue()
.keySet());
if (!missing.isEmpty()) {
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/eclipse/EclipseClasspath.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/eclipse/EclipseClasspath.java
index 3f9a2be9..2daf737c 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/eclipse/EclipseClasspath.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/eclipse/EclipseClasspath.java
@@ -5,11 +5,11 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
+import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -34,18 +34,18 @@ public class EclipseClasspath {
static final DocumentBuilderFactory documentBuilderFactory = XML.newDocumentBuilderFactory();
File project;
File workspace;
- Set<File> sources = new LinkedHashSet<>();
- Set<File> allSources = new LinkedHashSet<>();
+ Set<File> sources = new TreeSet<>();
+ Set<File> allSources = new TreeSet<>();
- Set<File> classpath = new LinkedHashSet<>();
+ Set<File> classpath = new TreeSet<>();
List<File> dependents = new ArrayList<>();
File output;
boolean recurse = true;
- Set<File> exports = new LinkedHashSet<>();
+ Set<File> exports = new TreeSet<>();
Map<String, String> properties = new HashMap<>();
Reporter reporter;
int options;
- Set<File> bootclasspath = new LinkedHashSet<>();
+ Set<File> bootclasspath = new TreeSet<>();
public final static int DO_VARIABLES = 1;
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/BaseRepository.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/BaseRepository.java
index c4853157..f334a26e 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/BaseRepository.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/BaseRepository.java
@@ -3,11 +3,11 @@ package aQute.bnd.osgi.repository;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.TreeSet;
import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;
@@ -42,7 +42,7 @@ public abstract class BaseRepository implements Repository {
@Override
public Promise<Collection<Resource>> findProviders(RequirementExpression expression) {
- Set<Resource> providers = new HashSet<>();
+ Set<Resource> providers = new TreeSet<>();
dispatch(expression, providers);
@@ -72,7 +72,7 @@ public abstract class BaseRepository implements Repository {
return;
}
- Set<Resource> subset = new HashSet<>();
+ Set<Resource> subset = new TreeSet<>();
dispatch(requirementExpressions.get(0), subset);
for (int i = 1; i < requirementExpressions.size(); i++) {
@@ -93,7 +93,7 @@ public abstract class BaseRepository implements Repository {
}
providers.addAll(subset);
} else if (expression instanceof NotExpression) {
- Set<Resource> allSet = new HashSet<>();
+ Set<Resource> allSet = new TreeSet<>();
dispatch(all, allSet);
RequirementExpression re = ((NotExpression) expression).getRequirementExpression();
for (Iterator<Resource> it = allSet.iterator(); it.hasNext();) {
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/BridgeRepository.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/BridgeRepository.java
index e5356c59..39e9b55f 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/BridgeRepository.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/BridgeRepository.java
@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -196,7 +195,7 @@ public class BridgeRepository {
public BridgeRepository(Repository repository) {
this.repository = repository;
- Set<Resource> resources = new HashSet<>();
+ Set<Resource> resources = new TreeSet<>();
find(resources, allIdentity);
find(resources, allBndInfo);
resources.forEach(this::index);
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/ResourcesRepository.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/ResourcesRepository.java
index 4cf286bc..8ef64202 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/ResourcesRepository.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/ResourcesRepository.java
@@ -5,10 +5,10 @@ import static java.util.stream.Collectors.toMap;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Predicate;
import java.util.stream.Collector;
@@ -24,7 +24,7 @@ public class ResourcesRepository extends BaseRepository {
private final Map<String, Predicate<Map<String, Object>>> cache;
public ResourcesRepository() {
- resources = new LinkedHashSet<>();
+ resources = new TreeSet<>();
cache = new ConcurrentHashMap<>();
}
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/SimpleIndexer.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/SimpleIndexer.java
index 9ac735f6..6e022641 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/SimpleIndexer.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/SimpleIndexer.java
@@ -9,10 +9,10 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.util.Collection;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
+import java.util.TreeSet;
import java.util.stream.Collectors;
import org.osgi.resource.Resource;
@@ -67,7 +67,7 @@ public class SimpleIndexer {
void analyzeFile(File file, ResourceBuilder resourceBuilder) throws Exception;
}
- private final Set<File> files = new LinkedHashSet<>();
+ private final Set<File> files = new TreeSet<>();
private Path base;
private boolean compress = false;
private String name;
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/XMLResourceGenerator.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/XMLResourceGenerator.java
index 08398185..5928ea97 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/XMLResourceGenerator.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/XMLResourceGenerator.java
@@ -28,11 +28,11 @@ import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+import java.util.TreeSet;
import java.util.zip.GZIPOutputStream;
import org.osgi.resource.Capability;
@@ -55,7 +55,7 @@ import aQute.lib.tag.Tag;
public class XMLResourceGenerator {
private Tag repository = new Tag(TAG_REPOSITORY);
- private Set<Resource> visited = new HashSet<>();
+ private Set<Resource> visited = new TreeSet<>();
private int indent = 0;
private boolean compress = false;
private URI base;
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/XMLResourceParser.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/XMLResourceParser.java
index a45738d7..50701ae9 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/XMLResourceParser.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/repository/XMLResourceParser.java
@@ -22,9 +22,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.TreeSet;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
@@ -94,7 +94,7 @@ public class XMLResourceParser extends Processor {
}
public XMLResourceParser(InputStream in, String what, URI uri) throws Exception {
- this(in, what, 100, new HashSet<>(), uri);
+ this(in, what, 100, new TreeSet<>(), uri);
}
public void setDepth(int n) {
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/resource/PersistentResource.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/resource/PersistentResource.java
index 89a82456..b0566f08 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/resource/PersistentResource.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/resource/PersistentResource.java
@@ -3,10 +3,10 @@ package aQute.bnd.osgi.resource;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.TreeSet;
import java.util.stream.Stream;
import org.osgi.framework.Version;
@@ -125,7 +125,7 @@ public class PersistentResource extends DTO implements Resource {
for (Requirement req : resource.getRequirements(null))
reqMap.add(req.getNamespace(), req);
- Set<String> names = new HashSet<>(capMap.keySet());
+ Set<String> names = new TreeSet<>(capMap.keySet());
names.addAll(reqMap.keySet());
namespaces = new Namespace[names.size()];
diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/resource/ResourceBuilder.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/resource/ResourceBuilder.java
index ebb8463a..e624009c 100644
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/resource/ResourceBuilder.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/resource/ResourceBuilder.java
@@ -11,8 +11,6 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -20,6 +18,7 @@ import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
+import java.util.TreeSet;
import java.util.function.Supplier;
import java.util.jar.Manifest;
@@ -101,7 +100,7 @@ public class ResourceBuilder {
}
private static <CR> void add(Map<String, Set<CR>> map, String namespace, CR capreq) {
- map.computeIfAbsent(namespace, k -> new LinkedHashSet<>())
+ map.computeIfAbsent(namespace, k -> new TreeSet<>())
.add(capreq);
}
@@ -672,7 +671,7 @@ public class ResourceBuilder {
}
public Map<Capability, Capability> from(Resource bundle) {
- Map<Capability, Capability> mapping = new LinkedHashMap<>();
+ Map<Capability, Capability> mapping = new TreeMap<>();
addRequirements(bundle.getRequirements(null));