aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java
diff options
context:
space:
mode:
authorGravatar Dmitry Lomov <dslomov@google.com>2015-10-21 19:16:30 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2015-10-22 15:15:53 +0000
commit8ff064545b5c286209c07a66eee430747a401a0e (patch)
treeef58094d7c6c0f8210dd12d825a53089b4ea3446 /src/main/java
parent908f4c91b4b5c1f996f1b177ab5886b1468cb6a9 (diff)
Introduce an AspectClass: a representation of a class of aspects.
For native aspects, AspectClass is a facade for Class<AspectFactory<...>>. -- MOS_MIGRATED_REVID=105986390
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/AspectWithParameters.java24
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/BuildView.java5
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java19
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/AspectClass.java33
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/AspectDefinition.java14
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/AspectFactory.java9
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/Attribute.java20
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/NativeAspectClass.java56
-rw-r--r--src/main/java/com/google/devtools/build/lib/packages/Rule.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/query2/output/ConservativeAspectResolver.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/query2/output/PreciseAspectResolver.java31
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java24
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java14
13 files changed, 171 insertions, 83 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/AspectWithParameters.java b/src/main/java/com/google/devtools/build/lib/analysis/AspectWithParameters.java
index 5ce5fa1b8b..0d35c98e6a 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/AspectWithParameters.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/AspectWithParameters.java
@@ -14,6 +14,7 @@
package com.google.devtools.build.lib.analysis;
import com.google.common.base.Preconditions;
+import com.google.devtools.build.lib.packages.AspectClass;
import com.google.devtools.build.lib.packages.AspectParameters;
import java.util.Objects;
@@ -27,26 +28,25 @@ public final class AspectWithParameters {
// TODO(bazel-team): class objects are not really hashable or comparable for equality other than
// by reference. We should identify the aspect here in a way that does not rely on comparison
// by reference so that keys can be serialized and deserialized properly.
- private final Class<? extends ConfiguredAspectFactory> aspectFactory;
+ private final AspectClass aspectClass;
private final AspectParameters parameters;
- public AspectWithParameters(
- Class<? extends ConfiguredAspectFactory> aspect, AspectParameters parameters) {
+ public AspectWithParameters(AspectClass aspect, AspectParameters parameters) {
Preconditions.checkNotNull(parameters);
- this.aspectFactory = aspect;
+ this.aspectClass = aspect;
this.parameters = parameters;
}
- public AspectWithParameters(Class<? extends ConfiguredAspectFactory> aspect) {
- this.aspectFactory = aspect;
+ public AspectWithParameters(AspectClass aspect) {
+ this.aspectClass = aspect;
this.parameters = AspectParameters.EMPTY;
}
/**
- * Returns the aspectFactory required for building the aspect.
+ * Returns the aspectClass required for building the aspect.
*/
- public Class<? extends ConfiguredAspectFactory> getAspectFactory() {
- return aspectFactory;
+ public AspectClass getAspectClass() {
+ return aspectClass;
}
/**
@@ -65,17 +65,17 @@ public final class AspectWithParameters {
return false;
}
AspectWithParameters that = (AspectWithParameters) other;
- return Objects.equals(this.aspectFactory, that.aspectFactory)
+ return Objects.equals(this.aspectClass, that.aspectClass)
&& Objects.equals(this.parameters, that.parameters);
}
@Override
public int hashCode() {
- return Objects.hash(aspectFactory, parameters);
+ return Objects.hash(aspectClass, parameters);
}
@Override
public String toString() {
- return String.format("AspectWithParameters %s(%s)", aspectFactory, parameters);
+ return String.format("AspectWithParameters %s(%s)", aspectClass, parameters);
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
index e05dd596d9..3d47a22739 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/BuildView.java
@@ -54,6 +54,7 @@ import com.google.devtools.build.lib.events.StoredEventHandler;
import com.google.devtools.build.lib.packages.AspectParameters;
import com.google.devtools.build.lib.packages.Attribute;
import com.google.devtools.build.lib.packages.BuildType;
+import com.google.devtools.build.lib.packages.NativeAspectClass;
import com.google.devtools.build.lib.packages.NoSuchThingException;
import com.google.devtools.build.lib.packages.PackageSpecification;
import com.google.devtools.build.lib.packages.RawAttributeMapper;
@@ -484,7 +485,9 @@ public class BuildView {
for (ConfiguredTargetKey targetSpec : targetSpecs) {
aspectKeys.add(
AspectValue.createAspectKey(
- targetSpec.getLabel(), targetSpec.getConfiguration(), aspectFactoryClass));
+ targetSpec.getLabel(),
+ targetSpec.getConfiguration(),
+ new NativeAspectClass(aspectFactoryClass)));
}
} else {
throw new ViewCreationFailedException("Aspect '" + aspect + "' is unknown");
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java b/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java
index 63e90125fa..8d77bee428 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java
@@ -25,6 +25,7 @@ import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.analysis.config.ConfigMatchingProvider;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.ImmutableSortedKeyListMultimap;
+import com.google.devtools.build.lib.packages.AspectClass;
import com.google.devtools.build.lib.packages.AspectDefinition;
import com.google.devtools.build.lib.packages.AspectFactory;
import com.google.devtools.build.lib.packages.AspectParameters;
@@ -560,7 +561,7 @@ public abstract class DependencyResolver {
ImmutableSet.Builder<AspectWithParameters> result = ImmutableSet.builder();
for (AspectWithParameters candidateClass : aspectCandidates) {
ConfiguredAspectFactory candidate =
- (ConfiguredAspectFactory) AspectFactory.Util.create(candidateClass.getAspectFactory());
+ (ConfiguredAspectFactory) AspectFactory.Util.create(candidateClass.getAspectClass());
if (Sets.difference(
candidate.getDefinition().getRequiredProviders(),
ruleClass.getAdvertisedProviders()).isEmpty()) {
@@ -578,18 +579,14 @@ public abstract class DependencyResolver {
// turn influences which aspect takes precedence if two emit the same provider (maybe this
// should be an error)
Set<AspectWithParameters> aspectCandidates = new LinkedHashSet<>();
- for (Map.Entry<Class<? extends AspectFactory<?, ?, ?>>, AspectParameters> aspectWithParameters :
- attribute.getAspectsWithParameters(originalRule).entrySet()) {
- aspectCandidates.add(new AspectWithParameters(
- aspectWithParameters.getKey().asSubclass(ConfiguredAspectFactory.class),
- aspectWithParameters.getValue()));
+ for (Map.Entry<AspectClass, AspectParameters> aspectWithParameters :
+ attribute.getAspectsWithParameters(originalRule).entrySet()) {
+ aspectCandidates.add(
+ new AspectWithParameters(aspectWithParameters.getKey(), aspectWithParameters.getValue()));
}
if (aspectDefinition != null) {
- for (Class<? extends AspectFactory<?, ?, ?>> aspect :
- aspectDefinition.getAttributeAspects().get(attribute.getName())) {
- aspectCandidates.add(new AspectWithParameters(
- aspect.asSubclass(ConfiguredAspectFactory.class),
- aspectParameters));
+ for (AspectClass aspect : aspectDefinition.getAttributeAspects().get(attribute.getName())) {
+ aspectCandidates.add(new AspectWithParameters(aspect, aspectParameters));
}
}
return aspectCandidates;
diff --git a/src/main/java/com/google/devtools/build/lib/packages/AspectClass.java b/src/main/java/com/google/devtools/build/lib/packages/AspectClass.java
new file mode 100644
index 0000000000..9c829221b1
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/packages/AspectClass.java
@@ -0,0 +1,33 @@
+// Copyright 2015 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.devtools.build.lib.packages;
+
+/**
+ * A class of aspects.
+ *
+ * <p>This interface serves as a factory for {@link AspectFactory}.
+ */
+public interface AspectClass {
+
+ /**
+ * Returns an aspect name.
+ */
+ String getName();
+
+ /**
+ * Instantiates an {@link AspectFactory} for this aspect class.
+ */
+ AspectFactory<?, ?, ?> newInstance();
+}
diff --git a/src/main/java/com/google/devtools/build/lib/packages/AspectDefinition.java b/src/main/java/com/google/devtools/build/lib/packages/AspectDefinition.java
index 9bacb4ac87..a9c75d7811 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/AspectDefinition.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/AspectDefinition.java
@@ -55,13 +55,13 @@ public final class AspectDefinition {
private final ImmutableSet<Class<?>> requiredProviders;
private final ImmutableSet<String> requiredProviderNames;
private final ImmutableMap<String, Attribute> attributes;
- private final ImmutableMultimap<String, Class<? extends AspectFactory<?, ?, ?>>> attributeAspects;
+ private final ImmutableMultimap<String, AspectClass> attributeAspects;
private AspectDefinition(
String name,
ImmutableSet<Class<?>> requiredProviders,
ImmutableMap<String, Attribute> attributes,
- ImmutableMultimap<String, Class<? extends AspectFactory<?, ?, ?>>> attributeAspects) {
+ ImmutableMultimap<String, AspectClass> attributeAspects) {
this.name = name;
this.requiredProviders = requiredProviders;
this.requiredProviderNames = toStringSet(requiredProviders);
@@ -116,7 +116,7 @@ public final class AspectDefinition {
* <p>Note that the map actually contains {@link AspectFactory}
* instances, except that we cannot reference that class here.
*/
- public ImmutableMultimap<String, Class<? extends AspectFactory<?, ?, ?>>> getAttributeAspects() {
+ public ImmutableMultimap<String, AspectClass> getAttributeAspects() {
return attributeAspects;
}
@@ -144,7 +144,7 @@ public final class AspectDefinition {
}
LinkedHashMultimap<Attribute, Label> result = LinkedHashMultimap.create();
- for (Class<? extends AspectFactory<?, ?, ?>> candidateClass : attribute.getAspects()) {
+ for (AspectClass candidateClass : attribute.getAspects()) {
AspectFactory<?, ?, ?> candidate = AspectFactory.Util.create(candidateClass);
// Check if target satisfies condition for this aspect (has to provide all required
// TransitiveInfoProviders)
@@ -195,8 +195,7 @@ public final class AspectDefinition {
private final String name;
private final Map<String, Attribute> attributes = new LinkedHashMap<>();
private final Set<Class<?>> requiredProviders = new LinkedHashSet<>();
- private final Multimap<String, Class<? extends AspectFactory<?, ?, ?>>> attributeAspects =
- LinkedHashMultimap.create();
+ private final Multimap<String, AspectClass> attributeAspects = LinkedHashMultimap.create();
public Builder(String name) {
this.name = name;
@@ -223,7 +222,8 @@ public final class AspectDefinition {
String attribute, Class<? extends AspectFactory<?, ?, ?>>... aspectFactories) {
Preconditions.checkNotNull(attribute);
for (Class<? extends AspectFactory<?, ?, ?>> aspectFactory : aspectFactories) {
- this.attributeAspects.put(attribute, Preconditions.checkNotNull(aspectFactory));
+ this.attributeAspects.put(
+ attribute, new NativeAspectClass(Preconditions.checkNotNull(aspectFactory)));
}
return this;
}
diff --git a/src/main/java/com/google/devtools/build/lib/packages/AspectFactory.java b/src/main/java/com/google/devtools/build/lib/packages/AspectFactory.java
index cd7ba2c51f..bbc1fea1fd 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/AspectFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/AspectFactory.java
@@ -45,13 +45,10 @@ public interface AspectFactory<TConfiguredTarget, TRuleContext, TAspect> {
// Should never be instantiated
}
- public static AspectFactory<?, ?, ?> create(Class<? extends AspectFactory<?, ?, ?>> clazz) {
+ public static AspectFactory<?, ?, ?> create(AspectClass aspectClass) {
// TODO(bazel-team): This should be cached somehow, because this method is invoked quite often
- try {
- return clazz.newInstance();
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
+
+ return aspectClass.newInstance();
}
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/packages/Attribute.java b/src/main/java/com/google/devtools/build/lib/packages/Attribute.java
index 18dc41c32c..a987570736 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/Attribute.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/Attribute.java
@@ -61,17 +61,15 @@ public final class Attribute implements Comparable<Attribute> {
public static final Predicate<RuleClass> NO_RULE = Predicates.alwaysFalse();
private static final class RuleAspect {
- private final Class<? extends AspectFactory<?, ?, ?>> aspectFactory;
+ private final AspectClass aspectFactory;
private final Function<Rule, AspectParameters> parametersExtractor;
- RuleAspect(
- Class<? extends AspectFactory<?, ?, ?>> aspectFactory,
- Function<Rule, AspectParameters> parametersExtractor) {
+ RuleAspect(AspectClass aspectFactory, Function<Rule, AspectParameters> parametersExtractor) {
this.aspectFactory = aspectFactory;
this.parametersExtractor = parametersExtractor;
}
- Class<? extends AspectFactory<?, ?, ?>> getAspectFactory() {
+ AspectClass getAspectFactory() {
return aspectFactory;
}
@@ -701,7 +699,7 @@ public final class Attribute implements Comparable<Attribute> {
*/
public Builder<TYPE> aspect(Class<? extends AspectFactory<?, ?, ?>> aspect,
Function<Rule, AspectParameters> evaluator) {
- this.aspects.add(new RuleAspect(aspect, evaluator));
+ this.aspects.add(new RuleAspect(new NativeAspectClass(aspect), evaluator));
return this;
}
@@ -1312,8 +1310,8 @@ public final class Attribute implements Comparable<Attribute> {
/**
* Returns the set of aspects required for dependencies through this attribute.
*/
- public ImmutableSet<Class<? extends AspectFactory<?, ?, ?>>> getAspects() {
- ImmutableSet.Builder<Class<? extends AspectFactory<?, ?, ?>>> builder = ImmutableSet.builder();
+ public ImmutableSet<AspectClass> getAspects() {
+ ImmutableSet.Builder<AspectClass> builder = ImmutableSet.builder();
for (RuleAspect aspect : aspects) {
builder.add(aspect.getAspectFactory());
}
@@ -1323,10 +1321,8 @@ public final class Attribute implements Comparable<Attribute> {
/**
* Returns set of pairs of aspect factories and corresponding aspect parameters.
*/
- public ImmutableMap<Class<? extends AspectFactory<?, ?, ?>>, AspectParameters>
- getAspectsWithParameters(Rule rule) {
- ImmutableMap.Builder<Class<? extends AspectFactory<?, ?, ?>>, AspectParameters> builder =
- ImmutableMap.builder();
+ public ImmutableMap<AspectClass, AspectParameters> getAspectsWithParameters(Rule rule) {
+ ImmutableMap.Builder<AspectClass, AspectParameters> builder = ImmutableMap.builder();
for (RuleAspect aspect : aspects) {
builder.put(aspect.getAspectFactory(), aspect.getParametersExtractor().apply(rule));
}
diff --git a/src/main/java/com/google/devtools/build/lib/packages/NativeAspectClass.java b/src/main/java/com/google/devtools/build/lib/packages/NativeAspectClass.java
new file mode 100644
index 0000000000..66360c152b
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/packages/NativeAspectClass.java
@@ -0,0 +1,56 @@
+// Copyright 2015 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.devtools.build.lib.packages;
+
+/**
+ * A class of aspects that are implemented natively in Bazel.
+ *
+ * <p>This class just wraps a {@link java.lang.Class} implementing the
+ * aspect factory. All wrappers of the same class are
+ */
+public final class NativeAspectClass implements AspectClass {
+ private final Class<? extends AspectFactory<?, ?, ?>> nativeClass;
+
+ public NativeAspectClass(Class<? extends AspectFactory<?, ?, ?>> nativeClass) {
+ this.nativeClass = nativeClass;
+ }
+
+ @Override
+ public String getName() {
+ return nativeClass.getSimpleName();
+ }
+
+ @Override
+ public AspectFactory<?, ?, ?> newInstance() {
+ try {
+ return nativeClass.newInstance();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return nativeClass.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof NativeAspectClass)) {
+ return false;
+ }
+ return nativeClass.equals(((NativeAspectClass) obj).nativeClass);
+ }
+}
diff --git a/src/main/java/com/google/devtools/build/lib/packages/Rule.java b/src/main/java/com/google/devtools/build/lib/packages/Rule.java
index 24ed1f7a1a..1cc5f63c03 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/Rule.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/Rule.java
@@ -704,7 +704,7 @@ public final class Rule implements Target {
BinaryPredicate<Rule, Attribute> predicate) {
LinkedHashMultimap<Attribute, Label> labels = LinkedHashMultimap.create();
for (Attribute attribute : this.getAttributes()) {
- for (Class<? extends AspectFactory<?, ?, ?>> candidateClass : attribute.getAspects()) {
+ for (AspectClass candidateClass : attribute.getAspects()) {
AspectFactory<?, ?, ?> candidate = AspectFactory.Util.create(candidateClass);
AspectDefinition.addAllAttributesOfAspect(Rule.this, labels,
candidate.getDefinition(), predicate);
diff --git a/src/main/java/com/google/devtools/build/lib/query2/output/ConservativeAspectResolver.java b/src/main/java/com/google/devtools/build/lib/query2/output/ConservativeAspectResolver.java
index 944b0bce8c..c9f2321519 100644
--- a/src/main/java/com/google/devtools/build/lib/query2/output/ConservativeAspectResolver.java
+++ b/src/main/java/com/google/devtools/build/lib/query2/output/ConservativeAspectResolver.java
@@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
import com.google.devtools.build.lib.cmdline.Label;
+import com.google.devtools.build.lib.packages.AspectClass;
import com.google.devtools.build.lib.packages.AspectDefinition;
import com.google.devtools.build.lib.packages.AspectFactory;
import com.google.devtools.build.lib.packages.Attribute;
@@ -41,7 +42,7 @@ public class ConservativeAspectResolver implements AspectResolver {
Multimap<Attribute, Label> result = LinkedHashMultimap.create();
for (Attribute attribute : ((Rule) target).getAttributes()) {
- for (Class<? extends AspectFactory<?, ?, ?>> aspectFactory : attribute.getAspects()) {
+ for (AspectClass aspectFactory : attribute.getAspects()) {
AspectDefinition.addAllAttributesOfAspect(
(Rule) target,
result,
diff --git a/src/main/java/com/google/devtools/build/lib/query2/output/PreciseAspectResolver.java b/src/main/java/com/google/devtools/build/lib/query2/output/PreciseAspectResolver.java
index d499b44b4e..4a22d49591 100644
--- a/src/main/java/com/google/devtools/build/lib/query2/output/PreciseAspectResolver.java
+++ b/src/main/java/com/google/devtools/build/lib/query2/output/PreciseAspectResolver.java
@@ -20,6 +20,7 @@ import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.events.EventHandler;
+import com.google.devtools.build.lib.packages.AspectClass;
import com.google.devtools.build.lib.packages.AspectDefinition;
import com.google.devtools.build.lib.packages.AspectFactory;
import com.google.devtools.build.lib.packages.Attribute;
@@ -89,20 +90,24 @@ public class PreciseAspectResolver implements AspectResolver {
}
// ...figure out which direct dependencies can possibly have aspects attached to them...
- Multimap<Attribute, Label> depsWithPossibleAspects = ((Rule) target).getTransitions(
- new BinaryPredicate<Rule, Attribute>() {
- @Override
- public boolean apply(@Nullable Rule rule, @Nullable Attribute attribute) {
- for (Class<? extends AspectFactory<?, ?, ?>> aspectFactory : attribute.getAspects()) {
- if (!AspectFactory.Util.create(aspectFactory).getDefinition()
- .getAttributes().isEmpty()) {
- return true;
- }
- }
+ Multimap<Attribute, Label> depsWithPossibleAspects =
+ ((Rule) target)
+ .getTransitions(
+ new BinaryPredicate<Rule, Attribute>() {
+ @Override
+ public boolean apply(@Nullable Rule rule, @Nullable Attribute attribute) {
+ for (AspectClass aspectClass : attribute.getAspects()) {
+ if (!AspectFactory.Util.create(aspectClass)
+ .getDefinition()
+ .getAttributes()
+ .isEmpty()) {
+ return true;
+ }
+ }
- return false;
- }
- });
+ return false;
+ }
+ });
// ...and add the package of the aspect.
for (Label depLabel : depsWithPossibleAspects.values()) {
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java
index 884d5dbc72..336056fad1 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/AspectValue.java
@@ -19,12 +19,12 @@ import com.google.common.base.Preconditions;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.analysis.Aspect;
import com.google.devtools.build.lib.analysis.AspectWithParameters;
-import com.google.devtools.build.lib.analysis.ConfiguredAspectFactory;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.events.Location;
+import com.google.devtools.build.lib.packages.AspectClass;
import com.google.devtools.build.lib.packages.AspectParameters;
import com.google.devtools.build.lib.packages.Package;
import com.google.devtools.build.skyframe.SkyFunctionName;
@@ -72,15 +72,15 @@ public final class AspectValue extends ActionLookupValue {
private NativeAspectKey(
Label label,
BuildConfiguration configuration,
- Class<? extends ConfiguredAspectFactory> aspectFactory,
+ AspectClass aspectClass ,
AspectParameters parameters) {
super(label, configuration);
Preconditions.checkNotNull(parameters);
- this.aspect = new AspectWithParameters(aspectFactory, parameters);
+ this.aspect = new AspectWithParameters(aspectClass, parameters);
}
- public Class<? extends ConfiguredAspectFactory> getAspect() {
- return aspect.getAspectFactory();
+ public AspectClass getAspect() {
+ return aspect.getAspectClass();
}
@Override
@@ -91,7 +91,7 @@ public final class AspectValue extends ActionLookupValue {
@Override
public String getDescription() {
- return String.format("%s of %s", aspect.getAspectFactory().getName(), getLabel());
+ return String.format("%s of %s", aspect.getAspectClass().getName(), getLabel());
}
@Override
@@ -122,7 +122,7 @@ public final class AspectValue extends ActionLookupValue {
@Override
public String toString() {
- return label + "#" + aspect.getAspectFactory().getSimpleName() + " "
+ return label + "#" + aspect.getAspectClass().getName() + " "
+ (configuration == null ? "null" : configuration.checksum()) + " "
+ aspect.getParameters();
}
@@ -209,8 +209,10 @@ public final class AspectValue extends ActionLookupValue {
return transitivePackages;
}
- public static SkyKey key(Label label, BuildConfiguration configuration,
- Class<? extends ConfiguredAspectFactory> aspectFactory,
+ public static SkyKey key(
+ Label label,
+ BuildConfiguration configuration,
+ AspectClass aspectFactory,
AspectParameters additionalConfiguration) {
return new SkyKey(
SkyFunctions.NATIVE_ASPECT,
@@ -222,9 +224,7 @@ public final class AspectValue extends ActionLookupValue {
}
public static NativeAspectKey createAspectKey(
- Label label,
- BuildConfiguration configuration,
- Class<? extends ConfiguredAspectFactory> aspectFactory) {
+ Label label, BuildConfiguration configuration, AspectClass aspectFactory) {
return new NativeAspectKey(label, configuration, aspectFactory, AspectParameters.EMPTY);
}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
index addf514e77..237feea9d7 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ConfiguredTargetFunction.java
@@ -29,7 +29,6 @@ import com.google.devtools.build.lib.actions.MutableActionGraph.ActionConflictEx
import com.google.devtools.build.lib.analysis.Aspect;
import com.google.devtools.build.lib.analysis.AspectWithParameters;
import com.google.devtools.build.lib.analysis.CachingAnalysisEnvironment;
-import com.google.devtools.build.lib.analysis.ConfiguredAspectFactory;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.DependencyResolver.Dependency;
import com.google.devtools.build.lib.analysis.LabelAndConfiguration;
@@ -46,6 +45,7 @@ import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.StoredEventHandler;
+import com.google.devtools.build.lib.packages.AspectClass;
import com.google.devtools.build.lib.packages.AspectDefinition;
import com.google.devtools.build.lib.packages.AspectFactory;
import com.google.devtools.build.lib.packages.AspectParameters;
@@ -510,7 +510,7 @@ final class ConfiguredTargetFunction implements SkyFunction {
}
ConfiguredTarget depConfiguredTarget = configuredTargetMap.get(depKey);
for (AspectWithParameters depAspect : dep.getAspects()) {
- if (!aspectMatchesConfiguredTarget(depConfiguredTarget, depAspect.getAspectFactory())) {
+ if (!aspectMatchesConfiguredTarget(depConfiguredTarget, depAspect.getAspectClass())) {
continue;
}
@@ -523,7 +523,7 @@ final class ConfiguredTargetFunction implements SkyFunction {
throw new IllegalStateException(e);
} catch (NoSuchThingException e) {
AspectFactory<?, ?, ?> depAspectFactory =
- AspectFactory.Util.create(depAspect.getAspectFactory());
+ AspectFactory.Util.create(depAspect.getAspectClass());
throw new AspectCreationException(
String.format("Evaluation of aspect %s on %s failed: %s",
depAspectFactory.getDefinition().getName(), dep.getLabel(), e.toString()));
@@ -544,13 +544,13 @@ final class ConfiguredTargetFunction implements SkyFunction {
AspectWithParameters depAspect) {
return AspectValue.key(label,
buildConfiguration,
- depAspect.getAspectFactory(),
+ depAspect.getAspectClass(),
depAspect.getParameters());
}
- private static boolean aspectMatchesConfiguredTarget(ConfiguredTarget dep,
- Class<? extends ConfiguredAspectFactory> aspectFactory) {
- AspectDefinition aspectDefinition = AspectFactory.Util.create(aspectFactory).getDefinition();
+ private static boolean aspectMatchesConfiguredTarget(
+ ConfiguredTarget dep, AspectClass aspectClass) {
+ AspectDefinition aspectDefinition = AspectFactory.Util.create(aspectClass).getDefinition();
for (Class<?> provider : aspectDefinition.getRequiredProviders()) {
if (dep.getProvider(provider.asSubclass(TransitiveInfoProvider.class)) == null) {
return false;