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

Also load local restrictions from old index location #54

Merged
merged 2 commits into from
Jul 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;

/**
* Enforces the {@link Restricted} access modifier annotations.
Expand Down Expand Up @@ -74,6 +75,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
dependencies.add(a.getFile().toURI().toURL());
URL outputURL = outputDir.toURI().toURL();
dependencies.add(outputURL);
getLog().debug("inspecting\n" + dependencies.stream().map(URL::toString).collect(Collectors.joining("\n")));

final boolean[] failed = new boolean[1];
Checker checker = new Checker(new URLClassLoader(dependencies.toArray(new URL[dependencies.size()]), getClass().getClassLoader()),
Expand All @@ -93,11 +95,15 @@ public void onWarning(Throwable t, Location loc, String msg) {
}
}, properties != null ? properties : new Properties(), getLog());

{// if there's restriction list in the inspected module itself, load it as well
// If there is a restriction list in the inspected module itself, load it as well:
for (String prefix : new String[] {"META-INF/services/annotations/", "META-INF/annotations/"}) {
URL local = new URL(outputURL, prefix + Restricted.class.getName());
InputStream self = null;
try {
self = new URL(outputURL, "META-INF/services/annotations/" + Restricted.class.getName()).openStream();
self = local.openStream();
getLog().debug("loaded local index " + local);
} catch (IOException e) {
getLog().debug("could not load local index " + local, e);
}
if (self!=null)
checker.loadRestrictions(self, true);
Expand Down