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 BasicNestHostWithInnerClassFields { |
| 8 | |
clementbera | 9f34f40 | 2019-05-08 15:22:47 +0200 | [diff] [blame] | 9 | private String fieldWithoutBridge = "noBridge"; |
clementbera | a14f58b | 2019-04-29 10:58:16 +0200 | [diff] [blame] | 10 | private String field = "field"; |
| 11 | private static String staticField = "staticField"; |
| 12 | |
| 13 | @SuppressWarnings("static-access") // we want to test that too. |
| 14 | public String accessNested(BasicNestedClass o) { |
clementbera | 2a26873 | 2019-05-02 09:22:32 +0200 | [diff] [blame] | 15 | o.field = "RW" + o.field; |
| 16 | o.staticField = "RW" + o.field; |
clementbera | 9f34f40 | 2019-05-08 15:22:47 +0200 | [diff] [blame] | 17 | return o.field + o.staticField + BasicNestedClass.staticField + fieldWithoutBridge; |
clementbera | a14f58b | 2019-04-29 10:58:16 +0200 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | public static class BasicNestedClass { |
| 21 | |
| 22 | private String field = "nestField"; |
| 23 | private static String staticField = "staticNestField"; |
| 24 | |
| 25 | @SuppressWarnings("static-access") // we want to test that too. |
| 26 | public String accessOuter(BasicNestHostWithInnerClassFields o) { |
clementbera | 2a26873 | 2019-05-02 09:22:32 +0200 | [diff] [blame] | 27 | o.field = "RW" + o.field; |
| 28 | o.staticField = "RW" + o.field; |
clementbera | a14f58b | 2019-04-29 10:58:16 +0200 | [diff] [blame] | 29 | return o.field + o.staticField + BasicNestedClass.staticField; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | public static void main(String[] args) { |
| 34 | BasicNestHostWithInnerClassFields outer = new BasicNestHostWithInnerClassFields(); |
| 35 | BasicNestedClass inner = new BasicNestedClass(); |
| 36 | |
| 37 | System.out.println(outer.accessNested(inner)); |
| 38 | System.out.println(inner.accessOuter(outer)); |
| 39 | } |
| 40 | } |