Fix some Java style problems.
RELNOTES: None.
PiperOrigin-RevId: 316094372
diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerOptions.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerOptions.java
index 8495b89..7eaf64e 100644
--- a/src/main/java/com/google/devtools/build/lib/worker/WorkerOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerOptions.java
@@ -27,26 +27,23 @@
import java.util.Map;
import java.util.Map.Entry;
-/**
- * Options related to worker processes.
- */
+/** Options related to worker processes. */
public class WorkerOptions extends OptionsBase {
public static final WorkerOptions DEFAULTS = Options.getDefaults(WorkerOptions.class);
@Option(
- name = "experimental_persistent_javac",
- defaultValue = "null",
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.UNKNOWN},
- help = "Enable the experimental persistent Java compiler.",
- expansion = {
- "--strategy=Javac=worker",
- "--strategy=JavaIjar=local",
- "--strategy=JavaDeployJar=local",
- "--strategy=JavaSourceJar=local",
- "--strategy=Turbine=local"
- }
- )
+ name = "experimental_persistent_javac",
+ defaultValue = "null",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
+ help = "Enable the experimental persistent Java compiler.",
+ expansion = {
+ "--strategy=Javac=worker",
+ "--strategy=JavaIjar=local",
+ "--strategy=JavaDeployJar=local",
+ "--strategy=JavaSourceJar=local",
+ "--strategy=Turbine=local"
+ })
public Void experimentalPersistentJavac;
/**
@@ -57,13 +54,10 @@
*/
public static class MultiResourceConverter implements Converter<Entry<String, Integer>> {
- static ResourceConverter valueConverter;
-
public static final int DEFAULT_VALUE = 4;
- public MultiResourceConverter() {
- valueConverter = new ResourceConverter(() -> DEFAULT_VALUE, 0, Integer.MAX_VALUE);
- }
+ static ResourceConverter valueConverter =
+ new ResourceConverter(() -> DEFAULT_VALUE, 0, Integer.MAX_VALUE);
@Override
public Map.Entry<String, Integer> convert(String input) throws OptionsParsingException {
@@ -111,21 +105,19 @@
public List<String> highPriorityWorkers;
@Option(
- name = "worker_quit_after_build",
- defaultValue = "false",
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.UNKNOWN},
- help = "If enabled, all workers quit after a build is done."
- )
+ name = "worker_quit_after_build",
+ defaultValue = "false",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
+ help = "If enabled, all workers quit after a build is done.")
public boolean workerQuitAfterBuild;
@Option(
- name = "worker_verbose",
- defaultValue = "false",
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.UNKNOWN},
- help = "If enabled, prints verbose messages when workers are started, shutdown, ..."
- )
+ name = "worker_verbose",
+ defaultValue = "false",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
+ help = "If enabled, prints verbose messages when workers are started, shutdown, ...")
public boolean workerVerbose;
@Option(
@@ -141,12 +133,10 @@
public List<Map.Entry<String, String>> workerExtraFlags;
@Option(
- name = "worker_sandboxing",
- defaultValue = "false",
- documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
- effectTags = {OptionEffectTag.UNKNOWN},
- help = "If enabled, workers will be executed in a sandboxed environment."
- )
+ name = "worker_sandboxing",
+ defaultValue = "false",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN},
+ help = "If enabled, workers will be executed in a sandboxed environment.")
public boolean workerSandboxing;
-
}
diff --git a/src/main/java/com/google/devtools/common/options/OptionDefinition.java b/src/main/java/com/google/devtools/common/options/OptionDefinition.java
index b527e6f..ef32dc4 100644
--- a/src/main/java/com/google/devtools/common/options/OptionDefinition.java
+++ b/src/main/java/com/google/devtools/common/options/OptionDefinition.java
@@ -14,13 +14,13 @@
package com.google.devtools.common.options;
+import com.google.common.collect.ImmutableList;
import com.google.devtools.common.options.OptionsParser.ConstructionException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -267,8 +267,7 @@
}
if (isSpecialNullDefault()) {
- // TODO(b/138573276): fix style warnings separately from behavioral changes
- return allowsMultiple() ? Collections.emptyList() : null;
+ return allowsMultiple() ? ImmutableList.of() : null;
}
Converter<?> converter = getConverter();
diff --git a/src/main/java/com/google/devtools/common/options/processor/OptionProcessor.java b/src/main/java/com/google/devtools/common/options/processor/OptionProcessor.java
index 74626f9..2f251f6 100644
--- a/src/main/java/com/google/devtools/common/options/processor/OptionProcessor.java
+++ b/src/main/java/com/google/devtools/common/options/processor/OptionProcessor.java
@@ -489,7 +489,7 @@
}
}
- private boolean hasSpecialNullDefaultValue(Option annotation) {
+ private static boolean hasSpecialNullDefaultValue(Option annotation) {
return OptionDefinition.SPECIAL_NULL_DEFAULT_VALUE.equals(annotation.defaultValue());
}
@@ -510,11 +510,11 @@
"flaky_test_attempts",
"worker_max_instances");
- private boolean isMultipleOptionDefaultValueException(Option annotation) {
+ private static boolean isMultipleOptionDefaultValueException(Option annotation) {
return MULTIPLE_OPTIONS_DEFAULT_VALUE_EXCEPTIONS.contains(annotation.name());
}
- private void checkNoDefaultValueForMultipleOption(VariableElement optionField)
+ private static void checkNoDefaultValueForMultipleOption(VariableElement optionField)
throws OptionProcessorException {
Option annotation = optionField.getAnnotation(Option.class);