blob: 81f6c5fcc3f6186b0eb3cefc9708040a682f649c [file] [log] [blame]
Christoffer Quist Adamsen53be22a2018-06-18 13:37:47 +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 RewritePinnedMethodTest {
8
9 public static void main(String[] args) {
10 C obj = new C();
11 obj.m();
12 }
13
14 // A.m is pinned by a keep rule, to prevent it from being merged into B.
15 public static class A {
16 public void m() {
17 System.out.println("In A.m");
18 }
19 }
20
21 // B is merged into C.
22 public static class B extends A {
23 @Override
24 public void m() {
25 System.out.println("In B.m");
26 super.m();
27 }
28 }
29
30 public static class C extends B {
31 @Override
32 public void m() {
33 System.out.println("In C.m");
34 // This invocation is changed from invoke-super to invoke-direct. It would be valid for this
Ian Zernyd37ed282020-08-06 13:21:04 +020035 // instruction to be on the form "invoke-super A.m". Therefore, the graph lens contains a
Christoffer Quist Adamsen53be22a2018-06-18 13:37:47 +020036 // mapping for "A.m" from (context: "C.m", type: SUPER) to C.m$B, where the method C.m$B is
37 // the direct method that gets created for B.m during vertical class merging.
38 super.m();
39 }
40 }
41}