blob: bec4e67315bef1f3336080663ea7c0e2809a8341 [file] [log] [blame]
Yohann Roussel390942c2017-09-06 15:28:39 +02001// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4package desugaringwithandroidjar25;
5
6import java.util.ArrayList;
7import java.util.Collection;
8import java.util.Iterator;
9import java.util.function.Predicate;
10
11public class DefaultMethodInAndroidJar25 {
12 public static void main(String[] args) throws Exception {
13 ClassWithDefaultPlatformMethods.test();
14 }
15}
16
17class ClassWithDefaultPlatformMethods implements Collection<String> {
18 private final ArrayList<String> list =
19 new ArrayList<String>() {{
20 add("First");
21 add("Second");
22 }};
23
24 static void test() {
25 ClassWithDefaultPlatformMethods instance = new ClassWithDefaultPlatformMethods();
26 instance.forEach(x -> System.out.println("BEFORE: " + x));
27 instance.removeIf(x -> true);
28 instance.forEach(x -> System.out.println("AFTER: " + x));
29 }
30
31 @Override
32 public int size() {
33 throw new AssertionError();
34 }
35
36 @Override
37 public boolean isEmpty() {
38 throw new AssertionError();
39 }
40
41 @Override
42 public boolean contains(Object o) {
43 throw new AssertionError();
44 }
45
46 @Override
47 public Iterator<String> iterator() {
48 return list.iterator();
49 }
50
51 @Override
52 public Object[] toArray() {
53 throw new AssertionError();
54 }
55
56 @Override
57 public <T> T[] toArray(T[] a) {
58 throw new AssertionError();
59 }
60
61 @Override
62 public boolean add(String s) {
63 throw new AssertionError();
64 }
65
66 @Override
67 public boolean remove(Object o) {
68 return list.remove(o);
69 }
70
71 @Override
72 public boolean containsAll(Collection<?> c) {
73 throw new AssertionError();
74 }
75
76 @Override
77 public boolean addAll(Collection<? extends String> c) {
78 throw new AssertionError();
79 }
80
81 @Override
82 public boolean removeAll(Collection<?> c) {
83 throw new AssertionError();
84 }
85
86 @Override
87 public boolean retainAll(Collection<?> c) {
88 throw new AssertionError();
89 }
90
91 @Override
92 public void clear() {
93 throw new AssertionError();
94 }
95
96 @Override
97 public boolean removeIf(Predicate<? super String> filter) {
98 return Collection.super.removeIf(filter);
99 }
100}