Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed could not use param java.net.URLClassLoader@64d2d351 #445 #464

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/main/java/org/reflections/util/ConfigurationBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ public static ConfigurationBuilder build(Object... params) {
// flatten
List<Object> parameters = new ArrayList<>();
for (Object param : params) {
if (param.getClass().isArray()) { for (Object p : (Object[]) param) parameters.add(p); }
else if (param instanceof Iterable) { for (Object p : (Iterable) param) parameters.add(p); }
else parameters.add(param);
if (param != null) {
if (param.getClass().isArray()) { for (Object p : (Object[]) param) parameters.add(p); }
else if (param instanceof Iterable) { for (Object p : (Iterable) param) parameters.add(p); }
else parameters.add(param);
}

}

ClassLoader[] loaders = Stream.of(params).filter(p -> p instanceof ClassLoader).distinct().toArray(ClassLoader[]::new);
Expand All @@ -97,7 +100,8 @@ public static ConfigurationBuilder build(Object... params) {
catch (Exception e) { throw new RuntimeException(e); }
} else if (param instanceof Predicate) {
builder.filterInputsBy((Predicate<String>) param);
} else throw new ReflectionsException("could not use param '" + param + "'");
} else if (param instanceof ClassLoader) { /* already taken care */ }
else throw new ReflectionsException("could not use param '" + param + "'");
}

if (builder.getUrls().isEmpty()) {
Expand Down