blob: d3b2762ec481358790862a659c3711d91406b3b1 [file] [log] [blame]
Stephan Herhutd5aa0922017-05-22 16:06:14 +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 classmerging;
5
6public class Test {
7
8 public static void main(String... args) {
9 GenericInterface iface = new GenericInterfaceImpl();
10 callMethodOnIface(iface);
11 GenericAbstractClass clazz = new GenericAbstractClassImpl();
12 callMethodOnAbstractClass(clazz);
13 ConflictingInterfaceImpl impl = new ConflictingInterfaceImpl();
14 callMethodOnIface(impl);
15 System.out.println(new SubClassThatReferencesSuperMethod().referencedMethod());
Christoffer Quist Adamsenbfdbe602019-10-18 12:03:31 +020016 Outer outer = new Outer();
17 Outer.SubClass inner = outer.getInstance();
18 System.out.println(outer.getInstance().method());
Stephan Herhutd5aa0922017-05-22 16:06:14 +020019 System.out.println(new SubClass(42));
Christoffer Quist Adamsenbfdbe602019-10-18 12:03:31 +020020
21 // Ensure that the instantiations are not dead code eliminated.
22 escape(clazz);
23 escape(iface);
24 escape(impl);
25 escape(inner);
26 escape(outer);
Stephan Herhutd5aa0922017-05-22 16:06:14 +020027 }
28
29 private static void callMethodOnIface(GenericInterface iface) {
30 System.out.println(iface.method());
31 }
32
33 private static void callMethodOnAbstractClass(GenericAbstractClass clazz) {
34 System.out.println(clazz.method());
35 System.out.println(clazz.otherMethod());
36 }
37
38 private static void callMethodOnIface(ConflictingInterface iface) {
39 System.out.println(iface.method());
40 System.out.println(ClassWithConflictingMethod.conflict(null));
41 System.out.println(OtherClassWithConflictingMethod.conflict(null));
42 }
Christoffer Quist Adamsenbfdbe602019-10-18 12:03:31 +020043
44 @NeverInline
45 static void escape(Object o) {
46 if (System.currentTimeMillis() < 0) {
47 System.out.println(o);
48 }
49 }
Stephan Herhutd5aa0922017-05-22 16:06:14 +020050}