diff options
author | 2018-03-12 12:20:48 -0700 | |
---|---|---|
committer | 2018-03-12 12:22:30 -0700 | |
commit | bff3472e4013c053e452fad7948ad68c5cbd5692 (patch) | |
tree | 22cfc1b6dd7a5a05237f33ec82c3d35368ddc3d8 /src/tools/android/java/com/google/devtools/build/android/desugar/DefaultMethodClassFixer.java | |
parent | c626a933473576a8593317021fbec12100dd5677 (diff) |
Support custom implementations of emulated core interface methods
RELNOTES: None.
PiperOrigin-RevId: 188760099
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/desugar/DefaultMethodClassFixer.java')
-rw-r--r-- | src/tools/android/java/com/google/devtools/build/android/desugar/DefaultMethodClassFixer.java | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/desugar/DefaultMethodClassFixer.java b/src/tools/android/java/com/google/devtools/build/android/desugar/DefaultMethodClassFixer.java index 292e14204d..853ed092ad 100644 --- a/src/tools/android/java/com/google/devtools/build/android/desugar/DefaultMethodClassFixer.java +++ b/src/tools/android/java/com/google/devtools/build/android/desugar/DefaultMethodClassFixer.java @@ -203,7 +203,7 @@ public class DefaultMethodClassFixer extends ClassVisitor { } private void stubMissingDefaultAndBridgeMethods() { - TreeSet<Class<?>> allInterfaces = new TreeSet<>(InterfaceComparator.INSTANCE); + TreeSet<Class<?>> allInterfaces = new TreeSet<>(SubtypeComparator.INSTANCE); for (String direct : directInterfaces) { // Loading ensures all transitively implemented interfaces can be loaded, which is necessary // to produce correct default method stubs in all cases. We could do without classloading but @@ -647,18 +647,17 @@ public class DefaultMethodClassFixer extends ClassVisitor { } } - /** Comparator for interfaces that compares by whether interfaces extend one another. */ - enum InterfaceComparator implements Comparator<Class<?>> { + /** Comparator for classes and interfaces that compares by whether subtyping relationship. */ + enum SubtypeComparator implements Comparator<Class<?>> { /** Orders subtypes before supertypes and breaks ties lexicographically. */ INSTANCE; @Override public int compare(Class<?> o1, Class<?> o2) { - checkArgument(o1.isInterface()); - checkArgument(o2.isInterface()); if (o1 == o2) { return 0; } + // order subtypes before supertypes if (o1.isAssignableFrom(o2)) { // o1 is supertype of o2 return 1; // we want o1 to come after o2 } |