aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2017-02-10 17:57:42 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2017-02-10 18:19:36 +0000
commit0eaff4437cf23da52983a659456e707d6fd372e3 (patch)
tree3992796fa469c13a4da5c05df5ccd4062672ecc7 /src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
parent350a4166a8122d912773d9e93ea089f66b870ff5 (diff)
Install support for checking for 'one version' correctness of java_binary
rules: If the collection of jars for a java_binary contain more than one instance of the same class, one of them will be arbitrarily loaded at runtime. This is problematic if the instances of the class are not identical, as methods or fields from one class version might be missing in the other, leading to runtime failures when methods are missing. This change adds an experimental flag to enable one version enforcement. The actual enforcement tool will come later. -- PiperOrigin-RevId: 147166361 MOS_MIGRATED_REVID=147166361
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
index c345ff5826..a7b7086ee8 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java
@@ -340,6 +340,16 @@ public class JavaOptions extends FragmentOptions {
)
public boolean headerCompilationDirectClasspathFallbackError;
+ @Option(
+ name = "experimental_one_version_enforcement",
+ defaultValue = "false",
+ category = "undocumented",
+ help =
+ "When enabled, enforce that a java_binary rule can't contain more than one version "
+ + "of the same class file on the classpath"
+ )
+ public boolean enforceOneVersion;
+
@Override
public FragmentOptions getHost(boolean fallback) {
JavaOptions host = (JavaOptions) getDefault();
@@ -365,6 +375,8 @@ public class JavaOptions extends FragmentOptions {
host.strictJavaDeps = strictJavaDeps;
+ host.enforceOneVersion = enforceOneVersion;
+
return host;
}