blob: db216b3227fe1193cbf6a6d449f6cc0ab8df1343 [file] [log] [blame]
Sebastien Hertz964c5c22017-05-23 15:22:23 +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.
4
5public class DebugDefaultMethod {
6
7 interface I {
8 default void doSomething(String msg) {
9 String name = getClass().getName();
10 System.out.println(name + ": " + msg);
11 }
12 }
13
14 static class DefaultImpl implements I {
15 }
16
17 static class OverrideImpl implements I {
18
19 @Override
20 public void doSomething(String msg) {
21 String newMsg = "OVERRIDE" + msg;
22 System.out.println(newMsg);
23 }
24 }
25
26 private static void testDefaultMethod(I i) {
27 i.doSomething("Test");
28 }
29
30 public static void main(String[] args) {
31 testDefaultMethod(new DefaultImpl());
32 testDefaultMethod(new OverrideImpl());
33 }
34
35}