diff options
author | 2017-03-09 22:24:24 +0000 | |
---|---|---|
committer | 2017-03-10 10:28:11 +0000 | |
commit | 1ac5b786f2fb361a92ef8582f5e06e0891c832d8 (patch) | |
tree | 29a934d0c1fa55dc973c6f337b118a922eba1582 | |
parent | 701ff40ad9d1b6c1e3beb52064e2ae2fe27b7e29 (diff) |
Remove bootclasspath fallback in Android desugaring tool
--
PiperOrigin-RevId: 149694683
MOS_MIGRATED_REVID=149694683
-rw-r--r-- | src/tools/android/java/com/google/devtools/build/android/desugar/Desugar.java | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/desugar/Desugar.java b/src/tools/android/java/com/google/devtools/build/android/desugar/Desugar.java index 116b2b5769..21fd98448e 100644 --- a/src/tools/android/java/com/google/devtools/build/android/desugar/Desugar.java +++ b/src/tools/android/java/com/google/devtools/build/android/desugar/Desugar.java @@ -162,16 +162,8 @@ class Desugar { System.out.printf("Lambda classes will be written under %s%n", dumpDirectory); } - boolean allowDefaultMethods = options.minSdkVersion >= 24; - - ClassLoader parent; - if (options.bootclasspath.isEmpty() && !options.allowEmptyBootclasspath) { - // TODO(b/31547323): Require bootclasspath once Bazel always provides it. Using the tool's - // bootclasspath as a fallback is iffy at best and produces wrong results at worst. - parent = ClassLoader.getSystemClassLoader(); - } else { - parent = new ThrowingClassLoader(); - } + checkState(!options.bootclasspath.isEmpty() || options.allowEmptyBootclasspath, + "Bootclasspath required to desugar %s", options.inputJar); CoreLibraryRewriter rewriter = new CoreLibraryRewriter(options.coreLibrary ? "__desugar__/" : ""); @@ -179,7 +171,8 @@ class Desugar { IndexedJars appIndexedJar = new IndexedJars(ImmutableList.of(options.inputJar)); IndexedJars appAndClasspathIndexedJars = new IndexedJars(options.classpath, appIndexedJar); ClassLoader loader = - createClassLoader(rewriter, options.bootclasspath, appAndClasspathIndexedJars, parent); + createClassLoader(rewriter, options.bootclasspath, appAndClasspathIndexedJars); + boolean allowDefaultMethods = options.minSdkVersion >= 24; boolean allowCallsToObjectsNonNull = options.minSdkVersion >= 19; try (ZipFile in = new ZipFile(options.inputJar.toFile()); ZipOutputStream out = @@ -299,14 +292,11 @@ class Desugar { out.closeEntry(); } - private static ClassLoader createClassLoader( - CoreLibraryRewriter rewriter, - List<Path> bootclasspath, - IndexedJars appAndClasspathIndexedJars, - ClassLoader parent) - throws IOException { + private static ClassLoader createClassLoader(CoreLibraryRewriter rewriter, + List<Path> bootclasspath, IndexedJars appAndClasspathIndexedJars) throws IOException { // Use a classloader that as much as possible uses the provided bootclasspath instead of // the tool's system classloader. Unfortunately we can't do that for java. classes. + ClassLoader parent = new ThrowingClassLoader(); if (!bootclasspath.isEmpty()) { parent = new HeaderClassLoader(new IndexedJars(bootclasspath), rewriter, parent); } |