diff options
author | 2015-09-14 13:35:34 +0000 | |
---|---|---|
committer | 2015-09-14 15:40:49 +0000 | |
commit | 4b67d4fed1f4ca8e4b1dd7dce47061b6b3779860 (patch) | |
tree | eb79083b8d1335d71b27e69d6003d7e7ef12ad72 /src/main | |
parent | 835ec9e63b9788b7d573cb78fa27b8cbfb5732d9 (diff) |
Prevented catching/wrapping of InterruptedExceptions, especially in BaseFunction.
--
MOS_MIGRATED_REVID=102988766
Diffstat (limited to 'src/main')
47 files changed, 203 insertions, 128 deletions
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 e966e7fb42..bf942365d1 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 @@ -350,18 +350,21 @@ public class BuildView { return getConfiguredTarget(packageManager.getLoadedTarget(label), config); } - public Iterable<ConfiguredTarget> getDirectPrerequisites(ConfiguredTarget ct) { + public Iterable<ConfiguredTarget> getDirectPrerequisites(ConfiguredTarget ct) + throws InterruptedException { return getDirectPrerequisites(ct, null); } public Iterable<ConfiguredTarget> getDirectPrerequisites( - ConfiguredTarget ct, @Nullable final LoadingCache<Label, Target> targetCache) { + ConfiguredTarget ct, @Nullable final LoadingCache<Label, Target> targetCache) + throws InterruptedException { return skyframeExecutor.getConfiguredTargets(ct.getConfiguration(), getDirectPrerequisiteDependencies(ct, targetCache), false); } public Iterable<Dependency> getDirectPrerequisiteDependencies( - ConfiguredTarget ct, @Nullable final LoadingCache<Label, Target> targetCache) { + ConfiguredTarget ct, @Nullable final LoadingCache<Label, Target> targetCache) + throws InterruptedException { if (!(ct.getTarget() instanceof Rule)) { return ImmutableList.of(); } @@ -858,7 +861,8 @@ public class BuildView { } @VisibleForTesting - ListMultimap<Attribute, ConfiguredTarget> getPrerequisiteMapForTesting(ConfiguredTarget target) { + ListMultimap<Attribute, ConfiguredTarget> getPrerequisiteMapForTesting(ConfiguredTarget target) + throws InterruptedException { DependencyResolver resolver = new DependencyResolver() { @Override protected void invalidVisibilityReferenceHook(TargetAndConfiguration node, Label label) { @@ -954,8 +958,8 @@ public class BuildView { * Returns a RuleContext which is the same as the original RuleContext of the target parameter. */ @VisibleForTesting - public RuleContext getRuleContextForTesting(ConfiguredTarget target, - StoredEventHandler eventHandler) { + public RuleContext getRuleContextForTesting( + ConfiguredTarget target, StoredEventHandler eventHandler) throws InterruptedException { BuildConfiguration config = target.getConfiguration(); CachingAnalysisEnvironment analysisEnvironment = new CachingAnalysisEnvironment(artifactFactory, @@ -977,7 +981,8 @@ public class BuildView { * given configured target. */ @VisibleForTesting - public RuleContext getRuleContextForTesting(ConfiguredTarget target, AnalysisEnvironment env) { + public RuleContext getRuleContextForTesting(ConfiguredTarget target, AnalysisEnvironment env) + throws InterruptedException { BuildConfiguration targetConfig = target.getConfiguration(); return new RuleContext.Builder( env, (Rule) target.getTarget(), targetConfig, configurations.getHostConfiguration(), @@ -996,7 +1001,8 @@ public class BuildView { */ @VisibleForTesting public ConfiguredTarget getPrerequisiteConfiguredTargetForTesting( - ConfiguredTarget dependentTarget, ConfiguredTarget desiredTarget) { + ConfiguredTarget dependentTarget, ConfiguredTarget desiredTarget) + throws InterruptedException { Collection<ConfiguredTarget> configuredTargets = getPrerequisiteMapForTesting(dependentTarget).values(); for (ConfiguredTarget ct : configuredTargets) { 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 debf6f4a98..05e302c0bc 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 @@ -219,7 +219,7 @@ public abstract class DependencyResolver { public final ListMultimap<Attribute, Dependency> dependentNodeMap( TargetAndConfiguration node, BuildConfiguration hostConfig, AspectDefinition aspect, AspectParameters aspectParameters, Set<ConfigMatchingProvider> configConditions) - throws EvalException { + throws EvalException, InterruptedException { Target target = node.getTarget(); BuildConfiguration config = node.getConfiguration(); ListMultimap<Attribute, Dependency> outgoingEdges = ArrayListMultimap.create(); @@ -250,7 +250,7 @@ public abstract class DependencyResolver { private ListMultimap<Attribute, LabelAndConfiguration> resolveAttributes( Rule rule, AspectDefinition aspect, BuildConfiguration configuration, BuildConfiguration hostConfiguration, Set<ConfigMatchingProvider> configConditions) - throws EvalException { + throws EvalException, InterruptedException { ConfiguredAttributeMapper attributeMap = ConfiguredAttributeMapper.of(rule, configConditions); attributeMap.validateAttributes(); List<Attribute> attributes; @@ -431,7 +431,7 @@ public abstract class DependencyResolver { AttributeMap attributeMap, Iterable<Attribute> attributes, ImmutableSortedKeyListMultimap.Builder<Attribute, LabelAndConfiguration> builder) - throws EvalException { + throws EvalException, InterruptedException { for (Attribute attribute : attributes) { if (!attribute.isLateBound() || !attribute.getCondition().apply(attributeMap)) { continue; @@ -501,7 +501,7 @@ public abstract class DependencyResolver { */ public final Collection<Dependency> dependentNodes( TargetAndConfiguration node, BuildConfiguration hostConfig, - Set<ConfigMatchingProvider> configConditions) { + Set<ConfigMatchingProvider> configConditions) throws InterruptedException { try { return ImmutableSet.copyOf(dependentNodeMap(node, hostConfig, /*aspect=*/null, AspectParameters.EMPTY, configConditions).values()); diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java index 0cfb114da0..74616c9c5d 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java @@ -1082,7 +1082,8 @@ public final class RuleContext extends TargetContext * Returns the implicit output artifact for a given template function. If multiple or no artifacts * can be found as a result of the template, an exception is thrown. */ - public Artifact getImplicitOutputArtifact(ImplicitOutputsFunction function) { + public Artifact getImplicitOutputArtifact(ImplicitOutputsFunction function) + throws InterruptedException { Iterable<String> result; try { result = function.getImplicitOutputs(RawAttributeMapper.of(rule)); 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 c181a7e156..1f30820ed8 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 @@ -865,7 +865,7 @@ public final class Attribute implements Comparable<Attribute> { * configuration. Note that configurations transitions are applied after the late-bound * attribute was evaluated. */ - Object getDefault(Rule rule, T o) throws EvalException; + Object getDefault(Rule rule, T o) throws EvalException, InterruptedException; } /** @@ -982,7 +982,7 @@ public final class Attribute implements Comparable<Attribute> { } @Override - public Object getDefault(Rule rule, Object o) throws EvalException { + public Object getDefault(Rule rule, Object o) throws EvalException, InterruptedException { Map<String, Object> attrValues = new HashMap<>(); // TODO(bazel-team): support configurable attributes here. RawAttributeMapper will throw // an exception on any instance of configurable attributes. diff --git a/src/main/java/com/google/devtools/build/lib/packages/ExternalPackage.java b/src/main/java/com/google/devtools/build/lib/packages/ExternalPackage.java index 49852ee747..cfb8143180 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/ExternalPackage.java +++ b/src/main/java/com/google/devtools/build/lib/packages/ExternalPackage.java @@ -111,7 +111,7 @@ public class ExternalPackage extends Package { public void addBindRule( RuleClass bindRuleClass, Label virtual, Label actual, Location location) - throws InvalidRuleException, NameConflictException { + throws InvalidRuleException, NameConflictException, InterruptedException { Map<String, Object> attributes = Maps.newHashMap(); // Bound rules don't have a name field, but this works because we don't want more than one @@ -133,7 +133,7 @@ public class ExternalPackage extends Package { */ public Builder createAndAddRepositoryRule(RuleClass ruleClass, RuleClass bindRuleClass, Map<String, Object> kwargs, FuncallExpression ast, Environment env) - throws InvalidRuleException, NameConflictException, SyntaxException { + throws InvalidRuleException, NameConflictException, SyntaxException, InterruptedException { StoredEventHandler eventHandler = new StoredEventHandler(); Rule tempRule = RuleFactory.createRule( this, ruleClass, kwargs, eventHandler, ast, ast.getLocation(), env); diff --git a/src/main/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunction.java b/src/main/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunction.java index 12d02c6d0c..eb3baddfa6 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunction.java +++ b/src/main/java/com/google/devtools/build/lib/packages/ImplicitOutputsFunction.java @@ -59,10 +59,11 @@ public abstract class ImplicitOutputsFunction { public abstract static class SkylarkImplicitOutputsFunction extends ImplicitOutputsFunction { public abstract ImmutableMap<String, String> calculateOutputs(AttributeMap map) - throws EvalException; + throws EvalException, InterruptedException; @Override - public Iterable<String> getImplicitOutputs(AttributeMap map) throws EvalException { + public Iterable<String> getImplicitOutputs(AttributeMap map) + throws EvalException, InterruptedException { return calculateOutputs(map).values(); } } @@ -83,7 +84,8 @@ public abstract class ImplicitOutputsFunction { } @Override - public ImmutableMap<String, String> calculateOutputs(AttributeMap map) throws EvalException { + public ImmutableMap<String, String> calculateOutputs(AttributeMap map) + throws EvalException, InterruptedException { Map<String, Object> attrValues = new HashMap<>(); for (String attrName : map.getAttributeNames()) { Type<?> attrType = map.getAttributeType(attrName); @@ -175,7 +177,8 @@ public abstract class ImplicitOutputsFunction { * Given a newly-constructed Rule instance (with attributes populated), * returns the list of output files that this rule produces implicitly. */ - public abstract Iterable<String> getImplicitOutputs(AttributeMap rule) throws EvalException; + public abstract Iterable<String> getImplicitOutputs(AttributeMap rule) + throws EvalException, InterruptedException; /** * The implicit output function that returns no files. diff --git a/src/main/java/com/google/devtools/build/lib/packages/Package.java b/src/main/java/com/google/devtools/build/lib/packages/Package.java index 2a6945c8ce..256aab09df 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/Package.java +++ b/src/main/java/com/google/devtools/build/lib/packages/Package.java @@ -240,7 +240,7 @@ public class Package implements Serializable { } } - private void readObject(ObjectInputStream in) throws IOException { + private void readObject(ObjectInputStream in) throws IOException, InterruptedException { try { deserializedPkg = new PackageDeserializer().deserialize(in); } catch (PackageDeserializationException e) { diff --git a/src/main/java/com/google/devtools/build/lib/packages/PackageDeserializer.java b/src/main/java/com/google/devtools/build/lib/packages/PackageDeserializer.java index 2537693f24..2f0715c139 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/PackageDeserializer.java +++ b/src/main/java/com/google/devtools/build/lib/packages/PackageDeserializer.java @@ -166,7 +166,7 @@ public class PackageDeserializer { } private void deserializeRule(DeserializationContext context, Build.Rule rulePb) - throws PackageDeserializationException { + throws PackageDeserializationException, InterruptedException { Location ruleLocation = EmptyLocation.INSTANCE; RuleClass ruleClass = packageDeserializationEnvironment.getRuleClass(rulePb, ruleLocation); Map<String, ParsedAttributeValue> attributeValues = new HashMap<>(); @@ -326,9 +326,11 @@ public class PackageDeserializer { * Deserialize a package from its representation as a protocol message. The inverse of * {@link PackageSerializer#serialize}. * @throws IOException + * @throws InterruptedException */ private void deserializeInternal(Build.Package packagePb, StoredEventHandler eventHandler, - Package.Builder builder, InputStream in) throws PackageDeserializationException, IOException { + Package.Builder builder, InputStream in) + throws PackageDeserializationException, IOException, InterruptedException { Path buildFile = packageDeserializationEnvironment.getPath(packagePb.getBuildFilePath()); Preconditions.checkNotNull(buildFile); DeserializationContext context = new DeserializationContext(builder); @@ -394,7 +396,7 @@ public class PackageDeserializer { } private void deserializeTargets(InputStream in, DeserializationContext context) - throws IOException, PackageDeserializationException { + throws IOException, PackageDeserializationException, InterruptedException { Build.TargetOrTerminator tot; while (!(tot = Build.TargetOrTerminator.parseDelimitedFrom(in)).getIsTerminator()) { Build.Target target = tot.getTarget(); @@ -428,8 +430,10 @@ public class PackageDeserializer { * @return a new {@link Package} as read from {@code in} * @throws PackageDeserializationException on failures deserializing the input * @throws IOException on failures reading from {@code in} + * @throws InterruptedException */ - public Package deserialize(InputStream in) throws PackageDeserializationException, IOException { + public Package deserialize(InputStream in) + throws PackageDeserializationException, IOException, InterruptedException { try { return deserializeInternal(in); } catch (PackageDeserializationException | RuntimeException e) { @@ -439,7 +443,7 @@ public class PackageDeserializer { } private Package deserializeInternal(InputStream in) - throws PackageDeserializationException, IOException { + throws PackageDeserializationException, IOException, InterruptedException { // Read the initial Package message so we have the data to initialize the builder. We will read // the Targets in individually later. Build.Package packagePb = Build.Package.parseDelimitedFrom(in); diff --git a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java index 6cb807f2c6..4fd5428153 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java +++ b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java @@ -900,7 +900,7 @@ public final class PackageFactory { Map<String, Object> kwargs, FuncallExpression ast, Environment env) - throws RuleFactory.InvalidRuleException, Package.NameConflictException { + throws RuleFactory.InvalidRuleException, Package.NameConflictException, InterruptedException { RuleClass ruleClass = getBuiltInRuleClass(ruleClassName, ruleFactory); RuleFactory.createAndAddRule(context, ruleClass, kwargs, ast, env); } @@ -938,7 +938,7 @@ public final class PackageFactory { @SuppressWarnings({"unchecked", "unused"}) public Runtime.NoneType invoke(Map<String, Object> kwargs, FuncallExpression ast, Environment env) - throws EvalException { + throws EvalException, InterruptedException { env.checkLoadingPhase(ruleClass, ast.getLocation()); try { addRule(ruleFactory, ruleClass, getContext(env, ast), kwargs, ast, env); 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 a4a46bcab9..da1c80494c 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 @@ -483,8 +483,8 @@ public final class Rule implements Target { * first, followed by any explicit files. Additionally both implicit and explicit output files * will retain the relative order in which they were declared. */ - void populateOutputFiles(EventHandler eventHandler, - Package.Builder pkgBuilder) throws SyntaxException { + void populateOutputFiles(EventHandler eventHandler, Package.Builder pkgBuilder) + throws SyntaxException, InterruptedException { Preconditions.checkState(outputFiles == null); // Order is important here: implicit before explicit outputFiles = Lists.newArrayList(); @@ -519,8 +519,8 @@ public final class Rule implements Target { * Implicit output files come from rule-specific patterns, and are a function * of the rule's "name", "srcs", and other attributes. */ - private void populateImplicitOutputFiles(EventHandler eventHandler, - Package.Builder pkgBuilder) { + private void populateImplicitOutputFiles(EventHandler eventHandler, Package.Builder pkgBuilder) + throws InterruptedException { try { for (String out : ruleClass.getImplicitOutputsFunction().getImplicitOutputs(attributeMap)) { try { diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java index 91723d0810..1e7dd2a46f 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java +++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java @@ -1315,7 +1315,7 @@ public final class RuleClass { */ Rule createRuleWithLabel(Package.Builder pkgBuilder, Label ruleLabel, Map<String, Object> attributeValues, EventHandler eventHandler, FuncallExpression ast, - Location location) throws SyntaxException { + Location location) throws SyntaxException, InterruptedException { Rule rule = pkgBuilder.newRuleWithLabel(ruleLabel, this, null, location); createRuleCommon(rule, pkgBuilder, attributeValues, eventHandler, ast); return rule; @@ -1323,7 +1323,7 @@ public final class RuleClass { private void createRuleCommon(Rule rule, Package.Builder pkgBuilder, Map<String, Object> attributeValues, EventHandler eventHandler, FuncallExpression ast) - throws SyntaxException { + throws SyntaxException, InterruptedException { populateRuleAttributeValues( rule, pkgBuilder, attributeValues, eventHandler, ast); rule.populateOutputFiles(eventHandler, pkgBuilder); @@ -1365,7 +1365,7 @@ public final class RuleClass { Rule createRuleWithParsedAttributeValues(Label label, Package.Builder pkgBuilder, Location ruleLocation, Map<String, ParsedAttributeValue> attributeValues, EventHandler eventHandler) - throws SyntaxException{ + throws SyntaxException, InterruptedException { Rule rule = pkgBuilder.newRuleWithLabel(label, this, null, ruleLocation); rule.checkValidityPredicate(eventHandler); @@ -1404,7 +1404,8 @@ public final class RuleClass { Package.Builder pkgBuilder, Map<String, Object> attributeValues, EventHandler eventHandler, - FuncallExpression ast) { + FuncallExpression ast) + throws InterruptedException { BitSet definedAttrs = new BitSet(); // set of attr indices for (Map.Entry<String, Object> entry : attributeValues.entrySet()) { diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleFactory.java b/src/main/java/com/google/devtools/build/lib/packages/RuleFactory.java index 8c073d2315..9c3516ee7e 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/RuleFactory.java +++ b/src/main/java/com/google/devtools/build/lib/packages/RuleFactory.java @@ -83,7 +83,7 @@ public class RuleFactory { FuncallExpression ast, Location location, @Nullable Environment env) - throws InvalidRuleException { + throws InvalidRuleException, InterruptedException { Preconditions.checkNotNull(ruleClass); String ruleClassName = ruleClass.getName(); Object nameObject = attributeValues.get("name"); @@ -149,7 +149,7 @@ public class RuleFactory { FuncallExpression ast, Location location, Environment env) - throws InvalidRuleException, NameConflictException { + throws InvalidRuleException, NameConflictException, InterruptedException { Rule rule = createRule( pkgBuilder, ruleClass, attributeValues, eventHandler, ast, location, env); pkgBuilder.addRule(rule); @@ -162,7 +162,7 @@ public class RuleFactory { Map<String, Object> attributeValues, FuncallExpression ast, Environment env) - throws InvalidRuleException, NameConflictException { + throws InvalidRuleException, NameConflictException, InterruptedException { return createAndAddRule( context.pkgBuilder, ruleClass, diff --git a/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactory.java b/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactory.java index abbbdf88d3..74def59324 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactory.java +++ b/src/main/java/com/google/devtools/build/lib/packages/WorkspaceFactory.java @@ -140,7 +140,7 @@ public class WorkspaceFactory { return new BuiltinFunction(ruleClassName, FunctionSignature.KWARGS, BuiltinFunction.USE_AST_ENV) { public Object invoke(Map<String, Object> kwargs, FuncallExpression ast, Environment env) - throws EvalException { + throws EvalException, InterruptedException { try { RuleClass ruleClass = ruleFactory.getRuleClass(ruleClassName); RuleClass bindRuleClass = ruleFactory.getRuleClass("bind"); diff --git a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleConfiguredTargetBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleConfiguredTargetBuilder.java index 3b1a24c41e..f2bb02c8dc 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleConfiguredTargetBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleConfiguredTargetBuilder.java @@ -52,8 +52,8 @@ public final class SkylarkRuleConfiguredTargetBuilder { /** * Create a Rule Configured Target from the ruleContext and the ruleImplementation. */ - public static ConfiguredTarget buildRule(RuleContext ruleContext, - BaseFunction ruleImplementation) { + public static ConfiguredTarget buildRule(RuleContext ruleContext, BaseFunction ruleImplementation) + throws InterruptedException { String expectFailure = ruleContext.attributes().get("expect_failure", Type.STRING); try (Mutability mutability = Mutability.create("configured target")) { SkylarkRuleContext skylarkRuleContext = new SkylarkRuleContext(ruleContext); @@ -81,9 +81,6 @@ public final class SkylarkRuleConfiguredTargetBuilder { ConfiguredTarget configuredTarget = createTarget(ruleContext, target); checkOrphanArtifacts(ruleContext); return configuredTarget; - } catch (InterruptedException e) { - ruleContext.ruleError(e.getMessage()); - return null; } catch (EvalException e) { addRuleToStackTrace(e, ruleContext.getRule(), ruleImplementation); // If the error was expected, return an empty target. diff --git a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java index 13a653398c..5c13375587 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java +++ b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleContext.java @@ -120,8 +120,9 @@ public final class SkylarkRuleContext { /** * Creates a new SkylarkRuleContext using ruleContext. + * @throws InterruptedException */ - public SkylarkRuleContext(RuleContext ruleContext) throws EvalException { + public SkylarkRuleContext(RuleContext ruleContext) throws EvalException, InterruptedException { this.ruleContext = Preconditions.checkNotNull(ruleContext); fragments = new FragmentCollection(ruleContext, ConfigurationTransition.NONE); hostFragments = new FragmentCollection(ruleContext, ConfigurationTransition.HOST); diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java index e65f28ff73..dc47023355 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java @@ -78,7 +78,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { protected abstract AndroidSemantics createAndroidSemantics(); @Override - public ConfiguredTarget create(RuleContext ruleContext) { + public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException { JavaSemantics javaSemantics = createJavaSemantics(); AndroidSemantics androidSemantics = createAndroidSemantics(); if (!AndroidSdkProvider.verifyPresence(ruleContext)) { @@ -118,7 +118,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { AndroidCommon androidCommon, JavaSemantics javaSemantics, AndroidSemantics androidSemantics, - List<String> depsAttributes) { + List<String> depsAttributes) throws InterruptedException { // TODO(bazel-team): Find a way to simplify this code. // treeKeys() means that the resulting map sorts the entries by key, which is necessary to // ensure determinism. @@ -297,7 +297,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { ResourceApk splitResourceApk, JavaTargetAttributes resourceClasses, ImmutableList<Artifact> apksUnderTest, - Artifact proguardMapping) { + Artifact proguardMapping) throws InterruptedException { ImmutableList<Artifact> proguardSpecs = getTransitiveProguardSpecs( @@ -712,7 +712,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { Artifact deployJarArtifact, NestedSetBuilder<Artifact> filesBuilder, ImmutableList<Artifact> proguardSpecs, - Artifact proguardMapping) { + Artifact proguardMapping) throws InterruptedException { Artifact proguardOutputJar = ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_BINARY_PROGUARD_JAR); @@ -731,8 +731,8 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { proguardSpecs, proguardMapping, sdk.getAndroidJar(), proguardOutputJar, filesBuilder); } - private static ProguardOutput createEmptyProguardAction( - RuleContext ruleContext, Artifact proguardOutputJar, Artifact deployJarArtifact) { + private static ProguardOutput createEmptyProguardAction(RuleContext ruleContext, + Artifact proguardOutputJar, Artifact deployJarArtifact) throws InterruptedException { ImmutableList.Builder<Artifact> failures = ImmutableList.<Artifact>builder().add(proguardOutputJar); if (ruleContext.attributes().get("proguard_generate_mapping", Type.BOOLEAN)) { @@ -751,7 +751,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { FilesToRunProvider proguard, Artifact jar, ImmutableList<Artifact> proguardSpecs, Artifact proguardMapping, Artifact androidJar, Artifact proguardOutputJar, - NestedSetBuilder<Artifact> filesBuilder) { + NestedSetBuilder<Artifact> filesBuilder) throws InterruptedException { Iterable<Artifact> libraryJars = NestedSetBuilder.<Artifact>naiveLinkOrder() .add(androidJar) .addTransitive(common.getTransitiveNeverLinkLibraries()) @@ -837,7 +837,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { /** Dexes the ProguardedJar to generate ClassesDex that has a reference classes.dex. */ static DexingOutput dex(RuleContext ruleContext, MultidexMode multidexMode, List<String> dexopts, Artifact deployJar, Artifact proguardedJar, AndroidCommon common, - JavaTargetAttributes attributes) { + JavaTargetAttributes attributes) throws InterruptedException { String classesDexFileName = getMultidexMode(ruleContext).getOutputDexFilename(); Artifact classesDex = AndroidBinary.getDxArtifact(ruleContext, classesDexFileName); if (!AndroidBinary.supportsMultidexMode(ruleContext, multidexMode)) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java index f90d2ad160..b65014dd5b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidCommon.java @@ -241,7 +241,7 @@ public class AndroidCommon { JavaCompilationArtifacts.Builder artifactsBuilder, JavaTargetAttributes.Builder attributes, NestedSet<ResourceContainer> resourceContainers, - ResourceContainer updatedResources) { + ResourceContainer updatedResources) throws InterruptedException { Artifact binaryResourcesJar = ruleContext.getImplicitOutputArtifact(JavaSemantics.JAVA_BINARY_CLASS_JAR); compileResourceJar(javaSemantics, binaryResourcesJar, updatedResources.getJavaSourceJar()); @@ -335,7 +335,7 @@ public class AndroidCommon { JavaSemantics javaSemantics, AndroidSemantics androidSemantics, ResourceApk resourceApk, AndroidIdlProvider transitiveIdlImportData, boolean addCoverageSupport, boolean collectJavaCompilationArgs, - SafeImplicitOutputsFunction genClassJarImplicitOutput) { + SafeImplicitOutputsFunction genClassJarImplicitOutput) throws InterruptedException { ImmutableList<Artifact> extraSources = resourceApk.isLegacy() || resourceApk.getResourceJavaSrcJar() == null ? ImmutableList.<Artifact>of() @@ -427,7 +427,8 @@ public class AndroidCommon { return (strict != DEFAULT && strict != STRICT) ? strict : ERROR; } - JackCompilationHelper initJack(JavaTargetAttributes attributes, JavaSemantics javaSemantics) { + JackCompilationHelper initJack(JavaTargetAttributes attributes, JavaSemantics javaSemantics) + throws InterruptedException { Map<PathFragment, Artifact> resourcesMap = new LinkedHashMap<>(); for (Artifact resource : attributes.getResources()) { resourcesMap.put(javaSemantics.getJavaResourcePath(resource.getRootRelativePath()), resource); @@ -459,7 +460,7 @@ public class AndroidCommon { JavaCompilationArtifacts.Builder javaArtifactsBuilder, boolean collectJavaCompilationArgs, @Nullable Artifact additionalSourceJar, - SafeImplicitOutputsFunction genClassJarImplicitOutput) { + SafeImplicitOutputsFunction genClassJarImplicitOutput) throws InterruptedException { NestedSetBuilder<Artifact> filesBuilder = NestedSetBuilder.<Artifact>stableOrder(); if (additionalSourceJar != null) { filesBuilder.add(additionalSourceJar); diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java index 2bacf57588..f6d113e7d3 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java @@ -57,7 +57,7 @@ public abstract class AndroidLibrary implements RuleConfiguredTargetFactory { protected abstract AndroidSemantics createAndroidSemantics(); @Override - public ConfiguredTarget create(RuleContext ruleContext) { + public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException { JavaSemantics javaSemantics = createJavaSemantics(); AndroidSemantics androidSemantics = createAndroidSemantics(); if (!AndroidSdkProvider.verifyPresence(ruleContext)) { @@ -261,8 +261,10 @@ public abstract class AndroidLibrary implements RuleConfiguredTargetFactory { } } - private static Artifact mergeJarsFromSrcs(RuleContext ruleContext, Artifact inputJar) { - ImmutableList<Artifact> jarSources = ruleContext + private static Artifact mergeJarsFromSrcs(RuleContext ruleContext, Artifact inputJar) + throws InterruptedException { + ImmutableList<Artifact> jarSources = + ruleContext .getPrerequisiteArtifacts("srcs", Mode.TARGET).filter(JavaSemantics.JAR).list(); if (jarSources.isEmpty()) { return inputJar; diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourceContainerBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourceContainerBuilder.java index 338e424703..89a5496d15 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourceContainerBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourceContainerBuilder.java @@ -53,8 +53,10 @@ public final class AndroidResourceContainerBuilder { return this; } - /** Creates a {@link ResourceContainer} from a {@link RuleContext}. */ - public ResourceContainer buildFromRule(RuleContext ruleContext, Artifact apk) { + /** Creates a {@link ResourceContainer} from a {@link RuleContext}. + * @throws InterruptedException */ + public ResourceContainer buildFromRule(RuleContext ruleContext, Artifact apk) + throws InterruptedException { Preconditions.checkNotNull(this.manifest); Preconditions.checkNotNull(this.data); return new AndroidResourcesProvider.ResourceContainer( diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSemantics.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSemantics.java index 343b6f11a9..f86fd57b14 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSemantics.java @@ -32,16 +32,18 @@ import com.google.devtools.build.lib.rules.java.JavaTargetAttributes; public interface AndroidSemantics { /** * Adds transitive info providers for {@code android_binary} and {@code android_library} rules. + * @throws InterruptedException */ void addTransitiveInfoProviders(RuleConfiguredTargetBuilder builder, RuleContext ruleContext, JavaCommon javaCommon, AndroidCommon androidCommon, Artifact jarWithAllClasses, ResourceApk resourceApk, Artifact zipAlignedApk, - Iterable<Artifact> apksUnderTest); + Iterable<Artifact> apksUnderTest) throws InterruptedException; /** * Returns the manifest to be used when compiling a given rule. + * @throws InterruptedException */ - ApplicationManifest getManifestForRule(RuleContext ruleContext); + ApplicationManifest getManifestForRule(RuleContext ruleContext) throws InterruptedException; /** * Returns the name of the file in which the file names of native dependencies are listed. @@ -71,8 +73,9 @@ public interface AndroidSemantics { /** * Add coverage instrumentation to the Java compilation of an Android binary. + * @throws InterruptedException */ void addCoverageSupport(RuleContext ruleContext, AndroidCommon common, - JavaSemantics javaSemantics, boolean forAndroidTest, - JavaTargetAttributes.Builder attributes, JavaCompilationArtifacts.Builder artifactsBuilder); + JavaSemantics javaSemantics, boolean forAndroidTest, JavaTargetAttributes.Builder attributes, + JavaCompilationArtifacts.Builder artifactsBuilder) throws InterruptedException; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ApplicationManifest.java b/src/main/java/com/google/devtools/build/lib/rules/android/ApplicationManifest.java index 2b5e999a66..0e79f5f299 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/ApplicationManifest.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/ApplicationManifest.java @@ -99,7 +99,8 @@ public final class ApplicationManifest { } } - public ApplicationManifest addStubApplication(RuleContext ruleContext) { + public ApplicationManifest addStubApplication(RuleContext ruleContext) + throws InterruptedException { Artifact stubManifest = ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.STUB_APPLICATON_MANIFEST); @@ -199,14 +200,15 @@ public final class ApplicationManifest { return builder.build(); } - /** Packages up the manifest with assets from the rule and dependent resources. */ + /** Packages up the manifest with assets from the rule and dependent resources. + * @throws InterruptedException */ public ResourceApk packWithAssets( Artifact resourceApk, RuleContext ruleContext, NestedSet<ResourceContainer> resourceContainers, Artifact rTxt, boolean incremental, - Artifact proguardCfg) { + Artifact proguardCfg) throws InterruptedException { try { LocalResourceContainer data = new LocalResourceContainer.Builder() .withAssets( @@ -237,7 +239,8 @@ public final class ApplicationManifest { } } - /** Packages up the manifest with resource and assets from the rule and dependent resources. */ + /** Packages up the manifest with resource and assets from the rule and dependent resources. + * @throws InterruptedException */ public ResourceApk packWithDataAndResources( Artifact resourceApk, RuleContext ruleContext, @@ -250,7 +253,7 @@ public final class ApplicationManifest { String applicationId, String versionCode, String versionName, - boolean incremental, Artifact proguardCfg) { + boolean incremental, Artifact proguardCfg) throws InterruptedException { try { LocalResourceContainer data = new LocalResourceContainer.Builder() .withAssets( @@ -301,7 +304,7 @@ public final class ApplicationManifest { String versionCode, String versionName, boolean incremental, - LocalResourceContainer data, Artifact proguardCfg) { + LocalResourceContainer data, Artifact proguardCfg) throws InterruptedException { ResourceContainer resourceContainer = checkForInlinedResources( new AndroidResourceContainerBuilder() .withData(data) @@ -395,6 +398,7 @@ public final class ApplicationManifest { /** * Packages up the manifest with resources, and generates the R.java. + * @throws InterruptedException * * @deprecated in favor of {@link ApplicationManifest#packWithDataAndResources}. */ @@ -404,7 +408,7 @@ public final class ApplicationManifest { RuleContext ruleContext, NestedSet<ResourceContainer> resourceContainers, boolean createSource, - Artifact proguardCfg) { + Artifact proguardCfg) throws InterruptedException { TransitiveInfoCollection resourcesPrerequisite = ruleContext.getPrerequisite("resources", Mode.TARGET); diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java index 2e4d497d65..663532ba2b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java @@ -145,12 +145,12 @@ public abstract class CcBinary implements RuleConfiguredTargetFactory { } @Override - public ConfiguredTarget create(RuleContext context) { + public ConfiguredTarget create(RuleContext context) throws InterruptedException { return CcBinary.init(semantics, context, /*fake =*/ false, /*useTestOnlyFlags =*/ false); } public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleContext, boolean fake, - boolean useTestOnlyFlags) { + boolean useTestOnlyFlags) throws InterruptedException { ruleContext.checkSrcsSamePackage(true); FeatureConfiguration featureConfiguration = CcCommon.configureFeatures(ruleContext); CcCommon common = new CcCommon(ruleContext, featureConfiguration); diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java index 63a2320ce7..48423fcaaf 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaBinary.java @@ -57,7 +57,7 @@ public class JavaBinary implements RuleConfiguredTargetFactory { } @Override - public ConfiguredTarget create(RuleContext ruleContext) { + public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException { final JavaCommon common = new JavaCommon(ruleContext, semantics); DeployArchiveBuilder deployArchiveBuilder = new DeployArchiveBuilder(semantics, ruleContext); Runfiles.Builder runfilesBuilder = new Runfiles.Builder(ruleContext.getWorkspaceName()); diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaImport.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaImport.java index 0b86405076..64d1b9b66d 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaImport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaImport.java @@ -46,7 +46,7 @@ public class JavaImport implements RuleConfiguredTargetFactory { } @Override - public ConfiguredTarget create(RuleContext ruleContext) { + public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException { ImmutableList<Artifact> srcJars = ImmutableList.of(); ImmutableList<Artifact> jars = collectJars(ruleContext); Artifact srcJar = ruleContext.getPrerequisiteArtifact("srcjar", Mode.TARGET); diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibrary.java index 5dcb16db29..2991afeba0 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaLibrary.java @@ -51,13 +51,14 @@ public class JavaLibrary implements RuleConfiguredTargetFactory { } @Override - public ConfiguredTarget create(RuleContext ruleContext) { + public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException { JavaCommon common = new JavaCommon(ruleContext, semantics); RuleConfiguredTargetBuilder builder = init(ruleContext, common); return builder != null ? builder.build() : null; } - public RuleConfiguredTargetBuilder init(RuleContext ruleContext, final JavaCommon common) { + public RuleConfiguredTargetBuilder init(RuleContext ruleContext, final JavaCommon common) + throws InterruptedException { common.initializeJavacOpts(); JavaTargetAttributes.Builder attributesBuilder = common.initCommon(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java index bb7cc83025..3bcbd73f9a 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java @@ -288,6 +288,7 @@ public interface JavaSemantics { /** * Adds extra providers to a Java target. + * @throws InterruptedException */ void addProviders(RuleContext ruleContext, JavaCommon javaCommon, @@ -299,7 +300,7 @@ public interface JavaSemantics { ImmutableMap<Artifact, Artifact> compilationToRuntimeJarMap, JavaCompilationHelper helper, NestedSetBuilder<Artifact> filesBuilder, - RuleConfiguredTargetBuilder ruleBuilder); + RuleConfiguredTargetBuilder ruleBuilder) throws InterruptedException; /** * Tell if a build with the given configuration should use strict java dependencies. This method @@ -324,10 +325,12 @@ public interface JavaSemantics { * @param attributesBuilder the builder to construct the list of attributes of this target * (mutable). * @return the launcher as an artifact + * @throws InterruptedException */ Artifact getLauncher(final RuleContext ruleContext, final JavaCommon common, DeployArchiveBuilder deployArchiveBuilder, Runfiles.Builder runfilesBuilder, - List<String> jvmFlags, JavaTargetAttributes.Builder attributesBuilder, boolean shouldStrip); + List<String> jvmFlags, JavaTargetAttributes.Builder attributesBuilder, boolean shouldStrip) + throws InterruptedException; /** * Add extra dependencies for runfiles of a Java binary. diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplication.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplication.java index 335acb8c3e..d287b62d76 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplication.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplication.java @@ -49,7 +49,7 @@ public class IosApplication extends ReleaseBundlingTargetFactory { @Override protected void configureTarget(RuleConfiguredTargetBuilder target, RuleContext ruleContext, - ReleaseBundlingSupport releaseBundlingSupport) { + ReleaseBundlingSupport releaseBundlingSupport) throws InterruptedException { // If this is an application built for the simulator, make it runnable. ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(ruleContext); if (objcConfiguration.getBundlingPlatform() == Platform.SIMULATOR) { diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtension.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtension.java index 821fa5e8e1..f90654d2af 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtension.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IosExtension.java @@ -59,7 +59,7 @@ public class IosExtension extends ReleaseBundlingTargetFactory { } @Override - protected ObjcProvider exposedObjcProvider(RuleContext ruleContext) { + protected ObjcProvider exposedObjcProvider(RuleContext ruleContext) throws InterruptedException { // Nest this target's bundle under final IPA return new ObjcProvider.Builder() .add(MERGE_ZIP, ruleContext.getImplicitOutputArtifact(ReleaseBundlingSupport.IPA)) diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosFramework.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosFramework.java index 0774559a35..d823621b20 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosFramework.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IosFramework.java @@ -100,7 +100,7 @@ public class IosFramework extends ReleaseBundlingTargetFactory { } @Override - protected ObjcProvider exposedObjcProvider(RuleContext ruleContext) { + protected ObjcProvider exposedObjcProvider(RuleContext ruleContext) throws InterruptedException { // Assemble framework binary and headers in the label-scoped location, so that it's possible to // pass -F X.framework to the compiler and -framework X to the linker. This mimics usage of // frameworks when built from Xcode. diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java index 61d22adcac..a7a476b9ff 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingSupport.java @@ -229,8 +229,9 @@ public final class ReleaseBundlingSupport { * multi-architecture binary. * * @return this application support + * @throws InterruptedException */ - ReleaseBundlingSupport registerActions() { + ReleaseBundlingSupport registerActions() throws InterruptedException { bundleSupport.registerActions(objcProvider); registerCombineArchitecturesAction(); @@ -329,7 +330,7 @@ public final class ReleaseBundlingSupport { .build(ruleContext)); } - private Artifact registerBundleSigningActions(Artifact ipaOutput) { + private Artifact registerBundleSigningActions(Artifact ipaOutput) throws InterruptedException { IntermediateArtifacts intermediateArtifacts = ObjcRuleClasses.intermediateArtifacts(ruleContext); Artifact teamPrefixFile = @@ -371,10 +372,13 @@ public final class ReleaseBundlingSupport { * top level target in a blaze invocation. * * @return this application support + * @throws InterruptedException */ - ReleaseBundlingSupport addFilesToBuild(NestedSetBuilder<Artifact> filesToBuild) { - NestedSetBuilder<Artifact> debugSymbolBuilder = NestedSetBuilder.<Artifact>stableOrder() - .addTransitive(objcProvider.get(ObjcProvider.DEBUG_SYMBOLS)); + ReleaseBundlingSupport addFilesToBuild(NestedSetBuilder<Artifact> filesToBuild) + throws InterruptedException { + NestedSetBuilder<Artifact> debugSymbolBuilder = + NestedSetBuilder.<Artifact>stableOrder().addTransitive( + objcProvider.get(ObjcProvider.DEBUG_SYMBOLS)); for (Artifact breakpadFile : getBreakpadFiles().values()) { filesToBuild.add(breakpadFile); @@ -399,8 +403,9 @@ public final class ReleaseBundlingSupport { /** * Creates the {@link XcTestAppProvider} that can be used if this application is used as an * {@code xctest_app}. + * @throws InterruptedException */ - XcTestAppProvider xcTestAppProvider() { + XcTestAppProvider xcTestAppProvider() throws InterruptedException { // We want access to #import-able things from our test rig's dependency graph, but we don't // want to link anything since that stuff is shared automatically by way of the // -bundle_loader linker flag. @@ -445,8 +450,9 @@ public final class ReleaseBundlingSupport { /** * Returns a {@link RunfilesSupport} that uses the provided runner script as the executable. + * @throws InterruptedException */ - RunfilesSupport runfilesSupport(Artifact runnerScript) { + RunfilesSupport runfilesSupport(Artifact runnerScript) throws InterruptedException { Artifact ipaFile = ruleContext.getImplicitOutputArtifact(ReleaseBundlingSupport.IPA); Runfiles runfiles = new Runfiles.Builder(ruleContext.getWorkspaceName()) .addArtifact(ipaFile) diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingTargetFactory.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingTargetFactory.java index b1d26cc9fa..54aeb675f3 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingTargetFactory.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ReleaseBundlingTargetFactory.java @@ -112,9 +112,10 @@ public abstract class ReleaseBundlingTargetFactory implements RuleConfiguredTarg /** * Performs additional configuration of the target. The default implementation does nothing, but * subclasses may override it to add logic. + * @throws InterruptedException */ protected void configureTarget(RuleConfiguredTargetBuilder target, RuleContext ruleContext, - ReleaseBundlingSupport releaseBundlingSupport) {} + ReleaseBundlingSupport releaseBundlingSupport) throws InterruptedException {} /** * Returns the name of this target's bundle. @@ -125,9 +126,10 @@ public abstract class ReleaseBundlingTargetFactory implements RuleConfiguredTarg /** * Returns an exposed {@code ObjcProvider} object. + * @throws InterruptedException */ @Nullable - protected ObjcProvider exposedObjcProvider(RuleContext ruleContext) { + protected ObjcProvider exposedObjcProvider(RuleContext ruleContext) throws InterruptedException { return null; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/TestSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/TestSupport.java index 4a5cb16d59..0b91cf4417 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/TestSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/TestSupport.java @@ -55,8 +55,9 @@ public class TestSupport { /** * Registers actions to create all files needed in order to actually run the test. + * @throws InterruptedException */ - public TestSupport registerTestRunnerActions() { + public TestSupport registerTestRunnerActions() throws InterruptedException { registerTestScriptSubstitutionAction(); return this; } @@ -68,7 +69,7 @@ public class TestSupport { return ObjcRuleClasses.artifactByAppendingToBaseName(ruleContext, "_test_script"); } - private void registerTestScriptSubstitutionAction() { + private void registerTestScriptSubstitutionAction() throws InterruptedException { // testIpa is the app actually containing the tests Artifact testIpa = testIpa(); @@ -130,7 +131,7 @@ public class TestSupport { "target_device", Mode.TARGET, IosTestSubstitutionProvider.class); } - private Artifact testIpa() { + private Artifact testIpa() throws InterruptedException { return ruleContext.getImplicitOutputArtifact(ReleaseBundlingSupport.IPA); } @@ -198,8 +199,10 @@ public class TestSupport { * Adds all files needed to run this test to the passed Runfiles builder. * * @param objcProvider common information about this rule's attributes and its dependencies + * @throws InterruptedException */ - public TestSupport addRunfiles(Builder runfilesBuilder, ObjcProvider objcProvider) { + public TestSupport addRunfiles(Builder runfilesBuilder, ObjcProvider objcProvider) + throws InterruptedException { runfilesBuilder .addArtifact(testIpa()) .addArtifacts(xctestIpa().asSet()) @@ -304,8 +307,10 @@ public class TestSupport { /** * Adds files which must be built in order to run this test to builder. + * @throws InterruptedException */ - public TestSupport addFilesToBuild(NestedSetBuilder<Artifact> builder) { + public TestSupport addFilesToBuild(NestedSetBuilder<Artifact> builder) + throws InterruptedException { builder.add(testIpa()).addAll(xctestIpa().asSet()); return this; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java index 45f9726009..d3979dcdce 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java @@ -63,8 +63,10 @@ public final class XcodeSupport { * Adds xcode project files to the given builder. * * @return this xcode support + * @throws InterruptedException */ - XcodeSupport addFilesToBuild(NestedSetBuilder<Artifact> filesToBuild) { + XcodeSupport addFilesToBuild(NestedSetBuilder<Artifact> filesToBuild) + throws InterruptedException { filesToBuild.add(ruleContext.getImplicitOutputArtifact(PBXPROJ)); return this; } @@ -94,8 +96,9 @@ public final class XcodeSupport { * * @param xcodeProvider information about this rule's xcode settings and that of its dependencies * @return this xcode support + * @throws InterruptedException */ - XcodeSupport registerActions(XcodeProvider xcodeProvider) { + XcodeSupport registerActions(XcodeProvider xcodeProvider) throws InterruptedException { registerXcodegenActions(XcodeProvider.Project.fromTopLevelTarget(xcodeProvider)); return this; } @@ -105,8 +108,9 @@ public final class XcodeSupport { * * @param xcodeProviders information about several rules' xcode settings * @return this xcode support + * @throws InterruptedException */ - XcodeSupport registerActions(Iterable<XcodeProvider> xcodeProviders) { + XcodeSupport registerActions(Iterable<XcodeProvider> xcodeProviders) throws InterruptedException { registerXcodegenActions(Project.fromTopLevelTargets(xcodeProviders)); return this; } @@ -199,7 +203,7 @@ public final class XcodeSupport { return this; } - private void registerXcodegenActions(XcodeProvider.Project project) { + private void registerXcodegenActions(XcodeProvider.Project project) throws InterruptedException { Artifact controlFile = ObjcRuleClasses.intermediateArtifacts(ruleContext).pbxprojControlArtifact(); @@ -220,7 +224,8 @@ public final class XcodeSupport { .build(ruleContext)); } - private ByteSource xcodegenControlFileBytes(final XcodeProvider.Project project) { + private ByteSource xcodegenControlFileBytes(final XcodeProvider.Project project) + throws InterruptedException { final Artifact pbxproj = ruleContext.getImplicitOutputArtifact(XcodeSupport.PBXPROJ); final ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(ruleContext); return new ByteSource() { diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java b/src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java index a60e0d7e88..9cd591a909 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java @@ -40,7 +40,7 @@ public abstract class PyBinary implements RuleConfiguredTargetFactory { protected abstract PythonSemantics createSemantics(); @Override - public ConfiguredTarget create(RuleContext ruleContext) { + public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException { PyCommon common = new PyCommon(ruleContext); common.initCommon(common.getDefaultPythonVersion()); @@ -51,8 +51,8 @@ public abstract class PyBinary implements RuleConfiguredTargetFactory { return builder.build(); } - static RuleConfiguredTargetBuilder init( - RuleContext ruleContext, PythonSemantics semantics, PyCommon common) { + static RuleConfiguredTargetBuilder init(RuleContext ruleContext, PythonSemantics semantics, + PyCommon common) throws InterruptedException { CcLinkParamsStore ccLinkParamsStore = initializeCcLinkParamStore(ruleContext); List<Artifact> srcs = common.validateSrcs(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PyTest.java b/src/main/java/com/google/devtools/build/lib/rules/python/PyTest.java index f433eb81e8..076005ab15 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/python/PyTest.java +++ b/src/main/java/com/google/devtools/build/lib/rules/python/PyTest.java @@ -30,7 +30,7 @@ public abstract class PyTest implements RuleConfiguredTargetFactory { protected abstract PythonSemantics createSemantics(); @Override - public ConfiguredTarget create(RuleContext ruleContext) { + public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException { PythonSemantics semantics = createSemantics(); PyCommon common = new PyCommon(ruleContext); common.initCommon(getDefaultPythonVersion(ruleContext)); diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PythonSemantics.java b/src/main/java/com/google/devtools/build/lib/rules/python/PythonSemantics.java index 357020029b..55d421ddc7 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/python/PythonSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/rules/python/PythonSemantics.java @@ -65,7 +65,8 @@ public interface PythonSemantics { /** * Called at the end of the analysis of {@code py_binary} rules. + * @throws InterruptedException */ void postInitBinary(RuleContext ruleContext, RunfilesSupport runfilesSupport, - PyCommon common); + PyCommon common) throws InterruptedException; } diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java index 87523c15bb..ede34cfdc6 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java @@ -61,7 +61,7 @@ public final class AspectFunction implements SkyFunction { @Nullable @Override public SkyValue compute(SkyKey skyKey, Environment env) - throws AspectFunctionException { + throws AspectFunctionException, InterruptedException { SkyframeBuildView view = buildViewProvider.getSkyframeBuildView(); NestedSetBuilder<Package> transitivePackages = NestedSetBuilder.stableOrder(); AspectKey key = (AspectKey) skyKey.argument(); 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 7fe19c5c78..ebc1fa72db 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 @@ -227,8 +227,7 @@ final class ConfiguredTargetFunction implements SkyFunction { AspectDefinition aspectDefinition, AspectParameters aspectParameters, Set<ConfigMatchingProvider> configConditions, RuleClassProvider ruleClassProvider, BuildConfiguration hostConfiguration, NestedSetBuilder<Package> transitivePackages) - throws DependencyEvaluationException, AspectCreationException { - + throws DependencyEvaluationException, AspectCreationException, InterruptedException { // Create the map from attributes to list of (target, configuration) pairs. ListMultimap<Attribute, Dependency> depValueNames; try { diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/PostConfiguredTargetFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/PostConfiguredTargetFunction.java index 315d9651e1..a9b226f7f9 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/PostConfiguredTargetFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/PostConfiguredTargetFunction.java @@ -71,7 +71,8 @@ public class PostConfiguredTargetFunction implements SkyFunction { @Nullable @Override - public SkyValue compute(SkyKey skyKey, Environment env) throws SkyFunctionException { + public SkyValue compute(SkyKey skyKey, Environment env) + throws SkyFunctionException, InterruptedException { ImmutableMap<Action, ConflictException> badActions = PrecomputedValue.BAD_ACTIONS.get(env); ConfiguredTargetValue ctValue = (ConfiguredTargetValue) env.getValue(ConfiguredTargetValue.key((ConfiguredTargetKey) skyKey.argument())); diff --git a/src/main/java/com/google/devtools/build/lib/syntax/ASTNode.java b/src/main/java/com/google/devtools/build/lib/syntax/ASTNode.java index 754035ef74..0ec6a98384 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/ASTNode.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/ASTNode.java @@ -41,16 +41,16 @@ public abstract class ASTNode implements Serializable { protected final EvalException handleException(Exception original) { // If there is already a non-empty stack trace, we only add this node iff it describes a // new scope (e.g. FuncallExpression). - if (original instanceof EvalExceptionWithStackTrace && isNewScope()) { + if (original instanceof EvalExceptionWithStackTrace) { EvalExceptionWithStackTrace real = (EvalExceptionWithStackTrace) original; - real.registerNode(this); + if (isNewScope()) { + real.registerNode(this); + } return real; } - // If the exception is an instance of a subclass of EvalException (such as - // ReturnStatement.ReturnException and FlowStatement.FlowException), we just return it - // unchanged. - if (original instanceof EvalException && !original.getClass().equals(EvalException.class)) { + // Returns the original exception if it cannot be attached to a stack trace. + if (original instanceof EvalException && !((EvalException) original).canBeAddedToStackTrace()) { return (EvalException) original; } diff --git a/src/main/java/com/google/devtools/build/lib/syntax/BaseFunction.java b/src/main/java/com/google/devtools/build/lib/syntax/BaseFunction.java index 450791d691..8ca1d1ab67 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/BaseFunction.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/BaseFunction.java @@ -410,7 +410,7 @@ public abstract class BaseFunction implements Serializable { * @param ast the expression for this function's definition * @param env the Environment in the function is called * @return the value resulting from evaluating the function with the given arguments - * @throws construction of EvalException-s containing source information. + * @throws EvalException-s containing source information. */ public Object call(List<Object> args, @Nullable Map<String, Object> kwargs, @@ -435,6 +435,7 @@ public abstract class BaseFunction implements Serializable { * @param args an array of argument values sorted as per the signature. * @param ast the source code for the function if user-defined * @param env the lexical environment of the function call + * @throws InterruptedException may be thrown in the function implementations. */ // Don't make it abstract, so that subclasses may be defined that @Override the outer call() only. protected Object call(Object[] args, diff --git a/src/main/java/com/google/devtools/build/lib/syntax/EvalException.java b/src/main/java/com/google/devtools/build/lib/syntax/EvalException.java index 186153e5b2..aec9f2b266 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/EvalException.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/EvalException.java @@ -159,6 +159,14 @@ public class EvalException extends Exception { } /** + * Returns whether this exception can be added to a stack trace created by {@link + * EvalExceptionWithStackTrace}. + */ + public boolean canBeAddedToStackTrace() { + return true; + } + + /** * A class to support a special case of EvalException when the cause of the error is an * Exception during a direct Java call. Allow the throwing code to provide context in a message. */ diff --git a/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java b/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java index 7300e4b46a..9ec686035f 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/EvalExceptionWithStackTrace.java @@ -34,6 +34,13 @@ public class EvalExceptionWithStackTrace extends EvalException { registerNode(culprit); } + @Override + public boolean canBeAddedToStackTrace() { + // Doesn't make any sense to add this exception to another instance of + // EvalExceptionWithStackTrace. + return false; + } + /** * Returns the appropriate location for this exception. * diff --git a/src/main/java/com/google/devtools/build/lib/syntax/FlowStatement.java b/src/main/java/com/google/devtools/build/lib/syntax/FlowStatement.java index 1af7bfad02..32b61c9456 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/FlowStatement.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/FlowStatement.java @@ -82,5 +82,10 @@ public final class FlowStatement extends Statement { public boolean mustTerminateLoop() { return terminateLoop; } + + @Override + public boolean canBeAddedToStackTrace() { + return false; + } } } diff --git a/src/main/java/com/google/devtools/build/lib/syntax/MethodLibrary.java b/src/main/java/com/google/devtools/build/lib/syntax/MethodLibrary.java index b1ca1f60a0..04adc5eeb6 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/MethodLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/MethodLibrary.java @@ -1082,7 +1082,7 @@ public class MethodLibrary { private static BuiltinFunction struct = new BuiltinFunction("struct") { @SuppressWarnings("unchecked") public SkylarkClassObject invoke(Map<String, Object> kwargs, Location loc) - throws EvalException, InterruptedException { + throws EvalException { return new SkylarkClassObject(kwargs, loc); } }; @@ -1183,7 +1183,7 @@ public class MethodLibrary { useEnvironment = true) private static BuiltinFunction enumerate = new BuiltinFunction("enumerate") { public Object invoke(Object input, Location loc, Environment env) - throws EvalException, ConversionException, InterruptedException { + throws EvalException, ConversionException { int count = 0; List<SkylarkList> result = Lists.newArrayList(); for (Object obj : Type.OBJECT_LIST.convert(input, "input")) { @@ -1217,7 +1217,7 @@ public class MethodLibrary { private static final BuiltinFunction range = new BuiltinFunction("range") { public Object invoke(Integer startOrStop, Object stopOrNone, Integer step, Location loc, Environment env) - throws EvalException, ConversionException, InterruptedException { + throws EvalException, ConversionException { int start; int stop; if (stopOrNone == Runtime.NONE) { @@ -1255,7 +1255,7 @@ public class MethodLibrary { mandatoryPositionals = { @Param(name = "x", type = Map.class, doc = "The parameter to convert.")}) private static final BuiltinFunction select = new BuiltinFunction("select") { - public Object invoke(Map<?, ?> dict) throws EvalException, InterruptedException { + public Object invoke(Map<?, ?> dict) throws EvalException { return SelectorList.of(new SelectorValue(dict)); } }; @@ -1412,7 +1412,7 @@ public class MethodLibrary { returnType = SkylarkList.class, useLocation = true) private static final BuiltinFunction zip = new BuiltinFunction("zip") { public SkylarkList invoke(SkylarkList args, Location loc) - throws EvalException, InterruptedException { + throws EvalException { Iterator<?>[] iterators = new Iterator<?>[args.size()]; for (int i = 0; i < args.size(); i++) { iterators[i] = EvalUtils.toIterable(args.get(i), loc).iterator(); diff --git a/src/main/java/com/google/devtools/build/lib/syntax/ReturnStatement.java b/src/main/java/com/google/devtools/build/lib/syntax/ReturnStatement.java index 0e377eb91f..d9302b668e 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/ReturnStatement.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/ReturnStatement.java @@ -34,6 +34,11 @@ public class ReturnStatement extends Statement { public Object getValue() { return value; } + + @Override + public boolean canBeAddedToStackTrace() { + return false; + } } private final Expression returnExpression; diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkCallbackFunction.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkCallbackFunction.java index 6140acb0b0..b22c45a8f8 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkCallbackFunction.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkCallbackFunction.java @@ -31,7 +31,8 @@ public class SkylarkCallbackFunction { this.funcallEnv = funcallEnv; } - public Object call(ClassObject ctx, Object... arguments) throws EvalException { + public Object call(ClassObject ctx, Object... arguments) + throws EvalException, InterruptedException { try (Mutability mutability = Mutability.create("callback %s", callback)) { Environment env = Environment.builder(mutability) .setSkylark() @@ -40,7 +41,7 @@ public class SkylarkCallbackFunction { .build(); return callback.call( ImmutableList.<Object>builder().add(ctx).add(arguments).build(), null, ast, env); - } catch (InterruptedException | ClassCastException | IllegalArgumentException e) { + } catch (ClassCastException | IllegalArgumentException e) { throw new EvalException(ast.getLocation(), e.getMessage()); } } |