clementbera | a14f58b | 2019-04-29 10:58:16 +0200 | [diff] [blame] | 1 | // 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 | |
clementbera | be19d30 | 2019-05-23 17:23:21 +0200 | [diff] [blame] | 5 | package nesthostexample; |
clementbera | a14f58b | 2019-04-29 10:58:16 +0200 | [diff] [blame] | 6 | |
| 7 | public class BasicNestHostWithInnerClassMethods { |
| 8 | |
clementbera | 9f34f40 | 2019-05-08 15:22:47 +0200 | [diff] [blame] | 9 | private String methodWithoutBridge() { |
| 10 | return "noBridge"; |
| 11 | } |
| 12 | |
clementbera | a14f58b | 2019-04-29 10:58:16 +0200 | [diff] [blame] | 13 | 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) { |
clementbera | 9f34f40 | 2019-05-08 15:22:47 +0200 | [diff] [blame] | 23 | return o.method() + o.staticMethod() + BasicNestedClass.staticMethod() + methodWithoutBridge(); |
clementbera | a14f58b | 2019-04-29 10:58:16 +0200 | [diff] [blame] | 24 | } |
| 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 | } |