Sebastien Hertz | 964c5c2 | 2017-05-23 15:22:23 +0200 | [diff] [blame] | 1 | // 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. |
| 4 | |
Sebastien Hertz | ca75865 | 2017-06-16 18:18:04 +0200 | [diff] [blame] | 5 | public class DebugInterfaceMethod { |
Sebastien Hertz | 964c5c2 | 2017-05-23 15:22:23 +0200 | [diff] [blame] | 6 | |
Sebastien Hertz | 681eb29 | 2018-04-10 17:30:28 +0200 | [diff] [blame] | 7 | static class DefaultImpl implements InterfaceWithDefaultAndStaticMethods { |
Sebastien Hertz | 964c5c2 | 2017-05-23 15:22:23 +0200 | [diff] [blame] | 8 | } |
| 9 | |
Sebastien Hertz | 681eb29 | 2018-04-10 17:30:28 +0200 | [diff] [blame] | 10 | static class OverrideImpl implements InterfaceWithDefaultAndStaticMethods { |
Sebastien Hertz | 964c5c2 | 2017-05-23 15:22:23 +0200 | [diff] [blame] | 11 | |
| 12 | @Override |
| 13 | public void doSomething(String msg) { |
| 14 | String newMsg = "OVERRIDE" + msg; |
| 15 | System.out.println(newMsg); |
| 16 | } |
| 17 | } |
| 18 | |
Sebastien Hertz | 681eb29 | 2018-04-10 17:30:28 +0200 | [diff] [blame] | 19 | private static void testDefaultMethod(InterfaceWithDefaultAndStaticMethods i) { |
Sebastien Hertz | 964c5c2 | 2017-05-23 15:22:23 +0200 | [diff] [blame] | 20 | i.doSomething("Test"); |
| 21 | } |
| 22 | |
Sebastien Hertz | ca75865 | 2017-06-16 18:18:04 +0200 | [diff] [blame] | 23 | private static void testStaticMethod() { |
Sebastien Hertz | 681eb29 | 2018-04-10 17:30:28 +0200 | [diff] [blame] | 24 | InterfaceWithDefaultAndStaticMethods.printString("I'm a static method in interface"); |
Sebastien Hertz | ca75865 | 2017-06-16 18:18:04 +0200 | [diff] [blame] | 25 | } |
| 26 | |
Sebastien Hertz | 964c5c2 | 2017-05-23 15:22:23 +0200 | [diff] [blame] | 27 | public static void main(String[] args) { |
| 28 | testDefaultMethod(new DefaultImpl()); |
| 29 | testDefaultMethod(new OverrideImpl()); |
Sebastien Hertz | ca75865 | 2017-06-16 18:18:04 +0200 | [diff] [blame] | 30 | testStaticMethod(); |
Sebastien Hertz | 964c5c2 | 2017-05-23 15:22:23 +0200 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | } |