Skip to content

Commit 9d783ab

Browse files
authored
Add SecureModuleFinder.of(Iterable) allows for passing in a collection rather then an array (#5)
1 parent e7f217d commit 9d783ab

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/main/java/cpw/mods/jarhandling/impl/Jar.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ private Set<String> gatherPackages() {
357357
var ret = new HashSet<String>();
358358
for (var file : files) {
359359
int idx = file.lastIndexOf('/');
360-
if (!file.endsWith(".class") || idx == -1)
360+
if (idx == -1 || !file.endsWith(".class"))
361361
continue;
362362
ret.add(file.substring(0, idx).replace('/', '.'));
363363
}

src/main/java/net/minecraftforge/securemodules/SecureModuleFinder.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
public class SecureModuleFinder implements ModuleFinder {
2525
private final Map<String, ModuleReference> references = new HashMap<>();
2626

27-
protected SecureModuleFinder(final SecureJar... jars) {
27+
protected SecureModuleFinder(final Iterable<SecureJar> jars) {
2828
for (var jar : jars) {
2929
var data = jar.moduleDataProvider();
3030
if (references.containsKey(data.name()))
@@ -34,6 +34,10 @@ protected SecureModuleFinder(final SecureJar... jars) {
3434
}
3535
}
3636

37+
protected SecureModuleFinder(final SecureJar... jars) {
38+
this(Arrays.asList(jars));
39+
}
40+
3741
@Override
3842
public Optional<ModuleReference> find(final String name) {
3943
return Optional.ofNullable(references.get(name));
@@ -48,6 +52,10 @@ public static SecureModuleFinder of(SecureJar... jars) {
4852
return new SecureModuleFinder(jars);
4953
}
5054

55+
public static SecureModuleFinder of(Iterable<SecureJar> jars) {
56+
return new SecureModuleFinder(jars);
57+
}
58+
5159
private static class Reference extends SecureModuleReference {
5260
private final SecureJar.ModuleDataProvider jar;
5361
private final Manifest manifest;

0 commit comments

Comments
 (0)