From ee5ea6bde9c774623c8083914b84f6a53dc82288 Mon Sep 17 00:00:00 2001 From: kmb Date: Thu, 24 May 2018 13:47:41 -0700 Subject: [PATCH] tolerate missing outer classes for interface desugaring PiperOrigin-RevId: 197946783 --- .../build/android/desugar/ClassVsInterface.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/tools/android/java/com/google/devtools/build/android/desugar/ClassVsInterface.java b/src/tools/android/java/com/google/devtools/build/android/desugar/ClassVsInterface.java index 272445451b5d32..205870a1b5f071 100644 --- a/src/tools/android/java/com/google/devtools/build/android/desugar/ClassVsInterface.java +++ b/src/tools/android/java/com/google/devtools/build/android/desugar/ClassVsInterface.java @@ -13,7 +13,6 @@ // limitations under the License. package com.google.devtools.build.android.desugar; -import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import com.google.devtools.build.android.desugar.io.BitFlags; @@ -54,9 +53,14 @@ public boolean isOuterInterface(String outerName, String innerName) { if (result == null) { // We could just load the outer class here, but this tolerates incomplete classpaths better. // Note the outer class should be in the Jar we're desugaring, so it should always be there. - ClassReader outerClass = checkNotNull(classpath.readIfKnown(outerName), - "Couldn't find outer class %s of %s", outerName, innerName); - result = BitFlags.isInterface(outerClass.getAccess()); + ClassReader outerClass = classpath.readIfKnown(outerName); + if (outerClass == null) { + System.err.printf("WARNING: Couldn't find outer class %s of %s%n", outerName, innerName); + // TODO(b/79155927): Make this an error when sources of this problem are fixed. + result = false; // assume it's a class if we can't find it (b/79155927) + } else { + result = BitFlags.isInterface(outerClass.getAccess()); + } known.put(outerName, result); } return result;