Christoffer Quist Adamsen | 53be22a | 2018-06-18 13:37:47 +0200 | [diff] [blame] | 1 | // 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 | |
| 5 | package classmerging; |
| 6 | |
| 7 | public 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 Zerny | d37ed28 | 2020-08-06 13:21:04 +0200 | [diff] [blame] | 35 | // instruction to be on the form "invoke-super A.m". Therefore, the graph lens contains a |
Christoffer Quist Adamsen | 53be22a | 2018-06-18 13:37:47 +0200 | [diff] [blame] | 36 | // 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 | } |