Skip to content

Commit

Permalink
include java/ files in output if they are targeted (#344)
Browse files Browse the repository at this point in the history
In na-97, where we target a `java/` file, the targeted file
(`java/util/atomic/concurrent/Striped64.java`, I believe) was being
excluded from the output because of these lines in `SpeciminRunner`:

```java
if (target.getKey().startsWith("java/")) {
    continue;
}
```

The reason it worked on Windows was probably because Windows uses
backslashes, and it didn't work on Unix because of the forward slash
comparison here. I changed it so that the target file is preserved in
the output no matter what, even if it starts with `java/` (or `java\`).
This should make na-97 work on both OSes.

I didn't include a test case for this, since NullAway bugs are now in
the evaluation script, but if you'd like, I could add one. Thanks!
  • Loading branch information
theron-wang authored Jul 29, 2024
1 parent ac2a699 commit 3d3a414
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/main/java/org/checkerframework/specimin/SpeciminRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,20 @@ private static void performMinimizationImpl(

// cache to avoid called Files.createDirectories repeatedly with the same arguments
Set<Path> createdDirectories = new HashSet<>();
Set<String> targetFilesAbsolutePaths = new HashSet<>();

for (String target : targetFiles) {
File targetFile = new File(target);
// Convert to absolute path for comparison
targetFilesAbsolutePaths.add(targetFile.getAbsolutePath());
}

for (Entry<String, CompilationUnit> target : parsedTargetFiles.entrySet()) {
// ignore classes from the Java package.
if (target.getKey().startsWith("java/")) {
// ignore classes from the Java package, unless we are targeting a JDK file.
// However, all related java/ files should not be included (as in used, but not targeted)
String absolutePath = new File(target.getKey()).getAbsolutePath();
if (!targetFilesAbsolutePaths.contains(absolutePath)
&& (target.getKey().startsWith("java/") || target.getKey().startsWith("java\\"))) {
continue;
}
// If a compilation output's entire body has been removed and the related class is not used by
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/preservation_status.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"jdk-8319461": "PASS",
"jdk-8288590": "PASS",
"na-89": "FAIL",
"na-97": "FAIL",
"na-97": "PASS",
"na-102": "PASS",
"na-103": "PASS",
"na-176": "FAIL",
Expand Down

0 comments on commit 3d3a414

Please sign in to comment.