blob: 4ef0b3e9bfa10f6b7b2f6f7e7a6e772d10a66905 [file] [log] [blame]
Christoffer Quist Adamsen1cbc7642018-06-26 09:48: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 ConflictInGeneratedNameTest {
8 public static void main(String[] args) {
9 B obj = new B();
10 obj.run();
11 }
12
13 public static class A {
Rico Winde7dac292021-11-04 13:09:37 +010014 @NeverPropagateValue private String name = "A";
Christoffer Quist Adamsen1cbc7642018-06-26 09:48:25 +020015
16 public A() {
17 print("In A.<init>()");
Christoffer Quist Adamsen4fcaa652020-11-27 09:49:11 +010018 $r8$constructor$classmerging$ConflictInGeneratedNameTest$A();
Christoffer Quist Adamsen1cbc7642018-06-26 09:48:25 +020019 }
20
Christoffer Quist Adamsen4fcaa652020-11-27 09:49:11 +010021 private void $r8$constructor$classmerging$ConflictInGeneratedNameTest$A() {
22 print("In A.$r8$constructor$classmerging$ConflictInGeneratedNameTest$A()");
Christoffer Quist Adamsen1cbc7642018-06-26 09:48:25 +020023 }
24
25 public void printState() {
26 print("In A.printState()");
27 print("A=" + name + "=" + getName());
28 }
29
30 // This method is not overridden.
31 public void foo() {
32 print("In A.foo()");
33 }
34
35 // This method is overridden.
36 public void bar() {
37 print("In A.bar()");
38 }
39
40 // This method is overridden and there is a PUBLIC method in B with the same name
41 // as the direct version of this method in B.
42 public void baz() {
43 print("In A.baz()");
44 }
45
46 // This method is overridden and there is a PRIVATE method in B with the same name
47 // as the direct version of this method in B.
48 public void boo() {
49 print("In A.boo()");
50 }
51
52 // There is a private method in B with the same name as this one.
53 private String getName() {
54 return name;
55 }
56 }
57
58 public static class B extends A {
Rico Winde7dac292021-11-04 13:09:37 +010059 @NeverPropagateValue private String name = "B";
60 @NeverPropagateValue private String name$classmerging$ConflictInGeneratedNameTest$A = "C";
Christoffer Quist Adamsen1cbc7642018-06-26 09:48:25 +020061
62 public B() {
63 print("In B.<init>()");
64 print("A=" + super.name + "=" + super.getName());
65 print("B=" + name + "=" + getName());
66 print("C=" + name$classmerging$ConflictInGeneratedNameTest$A);
67 }
68
69 public void run() {
70 printState();
71 foo();
72 bar();
73 baz();
74 baz$classmerging$ConflictInGeneratedNameTest$A();
75 boo();
76 boo$classmerging$ConflictInGeneratedNameTest$A();
77 }
78
79 @Override
80 public void bar() {
81 print("In B.bar()");
82 super.bar();
83 }
84
85 @Override
86 public void baz() {
87 print("In B.baz()");
88 super.baz();
89 }
90
91 public void baz$classmerging$ConflictInGeneratedNameTest$A() {
92 print("In B.baz$classmerging$ConflictInGeneratedNameTest$A()");
93 }
94
95 @Override
96 public void boo() {
97 print("In B.boo()");
98 super.boo();
99 }
100
101 private void boo$classmerging$ConflictInGeneratedNameTest$A() {
102 print("In B.boo$classmerging$ConflictInGeneratedNameTest$A()");
103 }
104
105 private String getName() {
106 return name;
107 }
108 }
109
110 public static void print(String message) {
111 System.out.println(message);
112 }
113}