blob: 51582285cae26c22dd7ceee277171473195e7258 [file] [log] [blame]
Christoffer Quist Adamsen722c9f62018-07-04 16:23:25 +02001// Copyright (c) 2018, 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
5package classmerging;
6
7public class MergeDefaultMethodIntoClassTest {
8
9 public static void main(String[] args) {
10 // Note: Important that the static type of [obj] is A, such that the call to f becomes an
11 // invoke-interface instruction and not invoke-virtual instruction.
12 A obj = new B();
13 obj.f();
Christoffer Quist Adamsenbfdbe602019-10-18 12:03:31 +020014
15 // Ensure that the instantiations are not dead code eliminated.
16 escape(obj);
17 }
18
19 @NeverInline
20 static void escape(Object o) {
21 if (System.currentTimeMillis() < 0) {
22 System.out.println(o);
23 }
Christoffer Quist Adamsen722c9f62018-07-04 16:23:25 +020024 }
25
26 public interface A {
27 default void f() {
28 System.out.println("In A.f");
29 }
30 }
31
32 public static class B implements A {}
33}