Skip to content

Commit

Permalink
Remove Java 7 type inference workarounds and TODOs
Browse files Browse the repository at this point in the history
Found by searching for TODOs mentioning "Java 7". There are plenty of other instances where we can simplify, but I don't want to be responsible for a large blast radius. At least in these cases we're fixing outdated comments.

RELNOTES: None
PiperOrigin-RevId: 161570189
  • Loading branch information
brandjon authored and laszlocsomor committed Jul 12, 2017
1 parent 3b038b9 commit ed24961
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public class AnalysisPhaseCompleteEvent {
public AnalysisPhaseCompleteEvent(Collection<? extends ConfiguredTarget> topLevelTargets,
int targetsVisited, long timeInMs) {
this.timeInMs = timeInMs;
// Do not remove <ConfiguredTarget>: workaround for Java 7 type inference.
this.topLevelTargets = ImmutableList.<ConfiguredTarget>copyOf(topLevelTargets);
this.topLevelTargets = ImmutableList.copyOf(topLevelTargets);
this.targetsVisited = targetsVisited;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,8 @@ private AnalysisResult createResult(
Collection<ConfiguredTarget> allTargetsToTest = null;
if (testsToRun != null) {
// Determine the subset of configured targets that are meant to be run as tests.
// Do not remove <ConfiguredTarget>: workaround for Java 7 type inference.
allTargetsToTest =
Lists.<ConfiguredTarget>newArrayList(
filterTestsByTargets(configuredTargets, Sets.newHashSet(testsToRun)));
Lists.newArrayList(filterTestsByTargets(configuredTargets, Sets.newHashSet(testsToRun)));
}

Set<Artifact> artifactsToBuild = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public final class BuildInfoCollection {

public BuildInfoCollection(List<? extends ActionAnalysisMetadata> actions,
List<Artifact> stampedBuildInfo, List<Artifact> redactedBuildInfo) {
// Do not remove <Action>: workaround for Java 7 type inference.
this.actions = ImmutableList.<ActionAnalysisMetadata>copyOf(actions);
this.actions = ImmutableList.copyOf(actions);
this.stampedBuildInfo = ImmutableList.copyOf(stampedBuildInfo);
this.redactedBuildInfo = ImmutableList.copyOf(redactedBuildInfo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,7 @@ public Transitions(BuildConfiguration configuration,

this.configuration = configuration;
this.transitionTable = ImmutableMap.copyOf(transitionTable);
// Do not remove <SplitTransition<?>, BuildConfiguration>:
// workaround for Java 7 type inference.
this.splitTransitionTable =
ImmutableListMultimap.<SplitTransition<?>, BuildConfiguration>copyOf(
splitTransitionTable);
this.splitTransitionTable = ImmutableListMultimap.copyOf(splitTransitionTable);
}

public Map<? extends Transition, ConfigurationHolder> getTransitionTable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public class ExecutionStartingEvent {
* @param targets Remaining active targets.
*/
public ExecutionStartingEvent(Collection<? extends TransitiveInfoCollection> targets) {
// Do not remove <TransitiveInfoCollection>: workaround for Java 7 type inference.
this.targets = ImmutableList.<TransitiveInfoCollection>copyOf(targets);
this.targets = ImmutableList.copyOf(targets);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,8 @@ public class TestFilteringCompleteEvent {
public TestFilteringCompleteEvent(
Collection<? extends ConfiguredTarget> targets,
Collection<? extends ConfiguredTarget> testTargets) {
// Do not remove <ConfiguredTarget>: workaround for Java 7 type inference.
this.targets = ImmutableList.<ConfiguredTarget>copyOf(targets);
this.testTargets =
testTargets == null
? null
// Do not remove <ConfiguredTarget>: workaround for Java 7 type inference.
: ImmutableList.<ConfiguredTarget>copyOf(testTargets);
this.targets = ImmutableList.copyOf(targets);
this.testTargets = testTargets == null ? null : ImmutableList.copyOf(testTargets);
if (testTargets == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1049,9 +1049,7 @@ private static <T> Collection<Node<T>> maybeOrderCollection(
return unordered;
}
List<Node<T>> result = new ArrayList<>(unordered);
// Do not inline this variable: a workaround for Java 7 type inference.
Comparator<Node<T>> nodeComparator = makeNodeComparator(comparator);
Collections.sort(result, nodeComparator);
Collections.sort(result, makeNodeComparator(comparator));
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,7 @@ public <T> AllowedValueSet(T... values) {
public AllowedValueSet(Iterable<?> values) {
Preconditions.checkNotNull(values);
Preconditions.checkArgument(!Iterables.isEmpty(values));
// Do not remove <Object>: workaround for Java 7 type inference.
allowedValues = ImmutableSet.<Object>copyOf(values);
allowedValues = ImmutableSet.copyOf(values);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ public ConfiguredTarget create(RuleContext ruleContext)
JavaCompilationHelper helper = new JavaCompilationHelper(
ruleContext, semantics, common.getJavacOpts(), attributesBuilder);
List<TransitiveInfoCollection> deps =
// Do not remove <TransitiveInfoCollection>: workaround for Java 7 type inference.
Lists.<TransitiveInfoCollection>newArrayList(
common.targetsTreatedAsDeps(ClasspathType.COMPILE_ONLY));
Lists.newArrayList(common.targetsTreatedAsDeps(ClasspathType.COMPILE_ONLY));
helper.addLibrariesToAttributes(deps);
attributesBuilder.addNativeLibraries(
collectNativeLibraries(common.targetsTreatedAsDeps(ClasspathType.BOTH)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,7 @@ public static List<TransitiveInfoCollection> getExports(RuleContext ruleContext)
// We need to check here because there are classes inheriting from this class that implement
// rules that don't have this attribute.
if (ruleContext.attributes().has("exports", BuildType.LABEL_LIST)) {
// Do not remove <SplitTransition<?>, BuildConfiguration>:
// workaround for Java 7 type inference.
return ImmutableList.<TransitiveInfoCollection>copyOf(
return ImmutableList.copyOf(
ruleContext.getPrerequisites("exports", Mode.TARGET));
} else {
return ImmutableList.of();
Expand Down Expand Up @@ -562,8 +560,7 @@ private static List<TransitiveInfoCollection> getRuntimeDeps(RuleContext ruleCon
// We need to check here because there are classes inheriting from this class that implement
// rules that don't have this attribute.
if (ruleContext.attributes().has("runtime_deps", BuildType.LABEL_LIST)) {
// Do not remove <TransitiveInfoCollection>: workaround for Java 7 type inference.
return ImmutableList.<TransitiveInfoCollection>copyOf(
return ImmutableList.copyOf(
ruleContext.getPrerequisites("runtime_deps", Mode.TARGET));
} else {
return ImmutableList.of();
Expand Down

0 comments on commit ed24961

Please sign in to comment.