blob: fe7de76c6a5ea1834655d13cf773e1fcd0a0b77c [file] [log] [blame]
Christoffer Quist Adamsenbde428a2018-06-11 09:23:10 +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 TemplateMethodTest {
8
9 public static void main(String[] args) {
10 AbstractClass obj = new AbstractClassImpl();
11 obj.foo();
Christoffer Quist Adamsenbfdbe602019-10-18 12:03:31 +020012
13 // Ensure that the instantiations are not dead code eliminated.
14 escape(obj);
15 }
16
17 @NeverInline
18 static void escape(Object o) {
19 if (System.currentTimeMillis() < 0) {
20 System.out.println(o);
21 }
Christoffer Quist Adamsenbde428a2018-06-11 09:23:10 +020022 }
23
24 private abstract static class AbstractClass {
25
26 public void foo() {
27 System.out.println("In foo on AbstractClass");
28 bar();
29 }
30
31 protected abstract void bar();
32 }
33
34 public static final class AbstractClassImpl extends AbstractClass {
35
36 @Override
37 public void bar() {
38 System.out.println("In bar on AbstractClassImpl");
39 }
40 }
41}