Skip to content
Merged
Changes from 4 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
10 changes: 7 additions & 3 deletions jmh/src/main/java/com/uber/nullaway/jmh/NullawayJavac.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ private NullawayJavac(
}
String processorPath =
System.getProperty("java.class.path") + File.pathSeparator + extraProcessorPath;
String allErrorProneArgs =
String.format(
"-Xplugin:ErrorProne -XepDisableAllChecks -Xep:NullAway:ERROR -XepOpt:NullAway:AnnotatedPackages=%s %s",
annotatedPackages, String.join(" ", extraErrorProneArgs));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

The concatenation fix correctly addresses the missing space bug.

The use of String.format with space-separated %s placeholders ensures Error Prone arguments are properly spaced, resolving the issue described in the PR.

One minor edge case: when extraErrorProneArgs is empty, the format produces a trailing space (e.g., "...AnnotatedPackages=com.uber "). While benign for command-line parsing, you could avoid it with:

-    String allErrorProneArgs =
-        String.format(
-            "-Xplugin:ErrorProne -XepDisableAllChecks -Xep:NullAway:ERROR -XepOpt:NullAway:AnnotatedPackages=%s %s",
-            annotatedPackages, String.join(" ", extraErrorProneArgs));
+    String allErrorProneArgs =
+        String.format(
+            "-Xplugin:ErrorProne -XepDisableAllChecks -Xep:NullAway:ERROR -XepOpt:NullAway:AnnotatedPackages=%s%s",
+            annotatedPackages, 
+            extraErrorProneArgs.isEmpty() ? "" : " " + String.join(" ", extraErrorProneArgs));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
String allErrorProneArgs =
String.format(
"-Xplugin:ErrorProne -XepDisableAllChecks -Xep:NullAway:ERROR -XepOpt:NullAway:AnnotatedPackages=%s %s",
annotatedPackages, String.join(" ", extraErrorProneArgs));
String allErrorProneArgs =
String.format(
"-Xplugin:ErrorProne -XepDisableAllChecks -Xep:NullAway:ERROR -XepOpt:NullAway:AnnotatedPackages=%s%s",
annotatedPackages,
extraErrorProneArgs.isEmpty() ? "" : " " + String.join(" ", extraErrorProneArgs));
🤖 Prompt for AI Agents
In jmh/src/main/java/com/uber/nullaway/jmh/NullawayJavac.java around lines 182
to 185, the formatted string can produce a trailing space when
extraErrorProneArgs is empty; change the construction so you only append a
leading space plus joined extraErrorProneArgs when extraErrorProneArgs is
non-empty (or trim the final string) so the resulting Error Prone argument
string never has an unnecessary trailing space.

options.addAll(
Arrays.asList(
"-processorpath",
Expand All @@ -187,9 +191,7 @@ private NullawayJavac(
outputDir.toAbsolutePath().toString(),
"-XDcompilePolicy=simple",
"--should-stop=ifError=FLOW",
"-Xplugin:ErrorProne -XepDisableAllChecks -Xep:NullAway:ERROR -XepOpt:NullAway:AnnotatedPackages="
+ annotatedPackages
+ String.join(" ", extraErrorProneArgs)));
allErrorProneArgs));
// add these options since we have at least one benchmark that only compiles with access to
// javac-internal APIs
options.addAll(
Expand All @@ -205,6 +207,8 @@ private NullawayJavac(
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.source.tree=ALL-UNNAMED"));
// for JSpecify mode (benign outside JSpecify mode)
options.add("-XDaddTypeAnnotationsToSymbol=true");
}

/**
Expand Down