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

Add check for scanner output #239

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
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 @@ -40,6 +40,11 @@ public class ModuleConfiguration {
public final Path scannerConfig;
/** Directory where all serialized data from checkers are located. */
public final Path dir;
/**
* Global unique ID for this module. 0 is for the target module, and the i-th module is for the
* i-th downstream dependency.
*/
public final int id;

/**
* Creates an instance of {@link ModuleConfiguration} from the given json object.
Expand All @@ -63,6 +68,7 @@ public static ModuleConfiguration buildFromJson(int id, Path globalDir, JSONObje
public ModuleConfiguration(int id, Path globalDir, Path checkerConfig, Path scannerConfig) {
this.checkerConfig = checkerConfig;
this.scannerConfig = scannerConfig;
this.id = id;
this.dir = globalDir.resolve(String.valueOf(id));
try {
Files.deleteIfExists(this.dir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
import edu.ucr.cs.riple.core.util.Utility;
import edu.ucr.cs.riple.injector.location.Location;
import edu.ucr.cs.riple.injector.location.OnClass;
import edu.ucr.cs.riple.scanner.Serializer;
import edu.ucr.cs.riple.scanner.generatedcode.SourceType;
import java.nio.file.Path;

/** This class is used to store the code structural information about the module. */
public class ModuleInfo {
Expand Down Expand Up @@ -87,6 +89,7 @@ public ModuleInfo(
// Build with scanner checker activated to generate required files to create the moduleInfo.
context.checker.prepareConfigFilesForBuild(configurations);
Utility.runScannerChecker(context, configurations, buildCommand);
checkScannerConfiguration();
this.nonnullStore = new NonnullStore(configurations, context);
this.fieldRegistry = new FieldRegistry(configurations, context);
this.methodRegistry = new MethodRegistry(context);
Expand Down Expand Up @@ -202,4 +205,31 @@ public CompoundRegionRegistry getRegionRegistry() {
public ImmutableSet<AnnotationProcessorHandler> getAnnotationProcessorHandlers() {
return annotationProcessorHandlers;
}

/** Checks if AnnotatorScanner is executed correctly for the modules. */
private void checkScannerConfiguration() {
for (ModuleConfiguration config : configurations) {
if (config.scannerConfig == null) {
throw new IllegalArgumentException(
"AnnotatorScanner configuration is not set for module: " + config);
}
// check for existence of one of the serialized files from Scanner. In this case we chose
// NON_NULL_ELEMENTS_FILE_NAME but any other file would work.
Path pathToNonnull = config.dir.resolve(Serializer.NON_NULL_ELEMENTS_FILE_NAME);
if (!pathToNonnull.toFile().exists()) {
String moduleName = config.id == 0 ? "target" : "dependency " + config.id;
throw new IllegalArgumentException(
"AnnotatorScanner is not correctly configured for the module: "
+ moduleName
+ ".\n"
+ "Please verify that the path specified for AnnotatorScanner on line "
+ config.id
+ " in the configuration file matches the path provided in file with -cp/--config-paths, "
+ "and that it is identical to the path specified with -XepOpt:AnnotatorScanner:ConfigPath."
+ "\n"
+ "If the path is set correctly, rerun annotator with -rboserr/--redirect-build-output-stderr flag "
+ "and check compilation output and ensure NullAway and AnnotatorScanner is executing properly.");
}
}
}
}
Loading