blob: e22088ab1e3c48b456a8ec135b61b4df0b76d6d0 [file] [log] [blame]
clementberaa14f58b2019-04-29 10:58:16 +02001// Copyright (c) 2019, 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
clementberabe19d302019-05-23 17:23:21 +02005package nesthostexample;
clementberaa14f58b2019-04-29 10:58:16 +02006
7public class BasicNestHostWithInnerClassMethods {
8
clementbera9f34f402019-05-08 15:22:47 +02009 private String methodWithoutBridge() {
10 return "noBridge";
11 }
12
clementberaa14f58b2019-04-29 10:58:16 +020013 private String method() {
14 return "hostMethod";
15 }
16
17 private static String staticMethod() {
18 return "staticHostMethod";
19 }
20
21 @SuppressWarnings("static-access") // we want to test that too.
22 public String accessNested(BasicNestedClass o) {
clementbera9f34f402019-05-08 15:22:47 +020023 return o.method() + o.staticMethod() + BasicNestedClass.staticMethod() + methodWithoutBridge();
clementberaa14f58b2019-04-29 10:58:16 +020024 }
25
26 public static class BasicNestedClass {
27 private String method() {
28 return "nestMethod";
29 }
30
31 private static String staticMethod() {
32 return "staticNestMethod";
33 }
34
35 @SuppressWarnings("static-access") // we want to test that too.
36 public String accessOuter(BasicNestHostWithInnerClassMethods o) {
37 return o.method() + o.staticMethod() + BasicNestedClass.staticMethod();
38 }
39 }
40
41 public static void main(String[] args) {
42 BasicNestHostWithInnerClassMethods outer = new BasicNestHostWithInnerClassMethods();
43 BasicNestedClass inner = new BasicNestedClass();
44
45 System.out.println(outer.accessNested(inner));
46 System.out.println(inner.accessOuter(outer));
47 }
48}